0

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

我需要做什么?

4

1 回答 1

1

制作!= CMake

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

于 2016-05-23T04:15:41.510 回答