我需要帮助将vcxproj转换为cmake

时间:2016-05-23 02:50:28

标签: c++ makefile vcxproj

有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:***缺少分隔符。停止。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

make!= CMake

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