gpt4 book ai didi

c++ - 我需要帮助将 vcxproj 转换为 cmake

转载 作者:行者123 更新时间:2023-11-28 05:39:48 29 4
gpt4 key购买 nike

有 Visual Studio 2015 项目。我需要为 Debian 编译它。我正在尝试使用 vcxproj2cmake 将其转换为 makefile。首先,我想在 Windows 上编译它。

perl vcxproj2cmake.pl project1.vcxproj "\Debug|Win32"生成文件

cmake_minimum_required(VERSION 2.8)

## section: Macro
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
IF(MSVC)
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
SET(Sources ${${SourcesVar}})

SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
OBJECT_OUTPUTS "${PrecompiledBinary}")
SET_SOURCE_FILES_PROPERTIES(${Sources}
PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
OBJECT_DEPENDS "${PrecompiledBinary}")
# Add precompiled header to SourcesVar
LIST(APPEND ${SourcesVar} ${PrecompiledSource})
ENDIF(MSVC)
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)

## start setting
SET (this_target project1)
PROJECT(${this_target})



## section: include directory
INCLUDE_DIRECTORIES(
$(BOOST_INCLUDE)
$(OPENSSL)/include
$(ZLIB_INCLUDE)
./..
)

## section: source files
# Add your source files here (one file per line), please SORT in alphabetical order for future maintenance
SET (${this_target}_SOURCE_FILES
# ...
)

## section: header files
# Add your header files here(one file per line), please SORT in alphabetical order for future maintenance!
SET(${this_target}_HEADER_FILES
# ...
)



## section: precompiled header
#ADD_MSVC_PRECOMPILED_HEADER("precompiled.h" "precompiled.cpp" MySources)
#ADD_LIBRARY(MyLibrary ${MySources})

SET_SOURCE_FILES_PROPERTIES(${this_target}_HEADER_FILES
PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND ${this_target}_SOURCE_FILES ${${this_target}_HEADER_FILES})

## section: add definitions
# add prefix -D. example> -DSHP
# - DO NOT add the following definitions(already defined in ${OSP_DEFINITIONS}:
# -DSHP, -DWIN32, -D_WINDOWS, -D_DEBUG, -D_USRDLL, -D_CRT_SECURE_NO_DEPRECATE
ADD_DEFINITIONS(
-D_CONSOLE
-DWIN32
-D_PROJECT_1
-DNDEBUG
)

## section: add target

ADD_EXECUTABLE(${this_target} ${${this_target}_SOURCE_FILES})

## section: add dependency
# dependency determines overall build order.
ADD_DEPENDENCIES(${this_target}
ws2_32.lib
zdll.lib
$(BOOST_LIB)/libboost_serialization-vc140-mt-1_61.lib
$(OPENSSL)/lib/libeay32.lib
$(OPENSSL)/lib/ssleay32.lib
)

## section: set link libraries
TARGET_LINK_LIBRARIES( ${this_target}
ws2_32.lib
zdll.lib
$(BOOST_LIB)/libboost_serialization-vc140-mt-1_61.lib
$(OPENSSL)/lib/libeay32.lib
$(OPENSSL)/lib/ssleay32.lib
)

将此文件重命名为 Makefile1 并输入 make -f Makefile-1
我明白了

Makefile.1:1: *** missing separator. Stop.

我需要做什么?

最佳答案

制作!=CMake

CMake是一个为其他构建系统(例如 make 或 VS 项目)生成代码的构建系统。您使用的工具发出 CMake 代码,必须由 CMake 解释。要构建项目(假设该工具成功),您可以先使用 make 生成器运行 CMake,然后在生成的 makefile 上运行 make

关于c++ - 我需要帮助将 vcxproj 转换为 cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37381959/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com