任务 -> 运行 Cmake 在 windows 中生成 dll,在 linux 中生成共享对象(.so 文件)。
我正在将代码从 windows 移植到 linux 。我已经对源代码进行了必要的更改。我曾尝试更改 CMakeLists.txt 文件,但是当我尝试这样做时,它会抱怨“找不到源文件”。请大家指出我在哪里犯了错误。CMakeList.txt 如下所示。cmake 在 Windows 中运行良好,但在 linux 中它抱怨错误。
我已经评论了几行并在 CMakeLIsts.txt 中添加了一行以使其在 Linux 中工作,但它不起作用。
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
CMAKE_POLICY( SET CMP0017 NEW )
PROJECT( disk_space_model )
INCLUDE( ../libs/helper_functions.cmake )
INCLUDE_THIRD_PARTY_SFC()
SET( HEADER_FILES
stdafx.h
INS_sensor_model.h
)
SET( SOURCE_FILES
Disk_space_model.cpp
)
SET( RESOURCE_FILES
"Disk Space DLL.rc"
resource.h
)
COMMON_SETUP()
SETUP_Lab_LIB_FILES( lib_foo lib_boo_files lib_platform lib_utils )
#ADD_DEFINITIONS(-D_USRDLL -DINSSENSORDLL_EXPORTS)
#ADD_LIBRARY( disk_space_model SHARED ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${CMAKE_HELPER_FILES} )
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
ADD_LIBRARY( disk_space_model [ STATIC | SHARED ] ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${CMAKE_HELPER_FILES} )
SET_OUTPUT_DIRS( disk_space_model )
TARGET_LINK_LIBRARIES( disk_space_model ${LIB_FILES} )
以下是我在配置后生成并在 CMake-gui 上生成时收到的以下错误
4 bit compiler
-- Configuring done
CMake Error at CMakeLists.txt:37 (ADD_LIBRARY):
Cannot find source file:
[
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error in CMakeLists.txt:
Cannot find source file:
STATIC
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error in CMakeLists.txt:
Cannot find source file:
|
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error in CMakeLists.txt:
Cannot find source file:
SHARED
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error in CMakeLists.txt:
Cannot find source file:
]
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
-- Build files have been written to: /home/mydir/svn/proj1/apps/disk space
make: *** [cmake_check_build_system] Error 1