我现在正在使用CMake构建一个动态库,我现在遇到的问题与为库添加文件有关。我的项目结构如下:
----src
|
thrid_party---boost_1_50_0----boost
| --- | ----libs
| --- | ---- | --- filesystem
| --- | ---- | --- | ------src
我的CMakeLists.txt文件位于src
目录中,文件内容如下:
cmake_minimum_required( VERSION 2.6 )
project (temp)
#build the third party library
include_directories( ${irisimp_SOURCE_DIR}/../third_party/boost_1_50_0)
set (boost_path
${irisimp_SOURCE_DIR}/../third_party/boost_1_50_0/libs)
set (BOOST_LIST
${boost_path}/filesystem/src/codecvt_error_category.cpp
${boost_path}/filesystem/src/operations.cpp
${boost_path}/filesystem/src/path.cpp
${boost_path}/filesystem/src/path_traits.cpp
${boost_path}/filesystem/src/portability.cpp
${boost_path}/filesystem/src/unique_path.cpp
${boost_path}/filesystem/src/utf8_codecvt_facet.cpp
${boost_path}/filesystem/src/windows_file_codecvt.cpp
${boost_path}/filesystem/src/windows_file_codecvt.hpp
)
add_library ( boost SHARED ${BOOST_LIST})
运行此脚本没有问题,但输出Visual Studio 10项目不包含${boost_path}/filesystem/src
文件夹中的所有源文件。实际上只保留了windows_file_codecvt.cpp。因此,编译此项目将失败。我想知道我应该做些什么来确保Visual Studio 10项目可以按照CMakeLists.txt.Thanks中的指示包含所有源文件!
答案 0 :(得分:2)
尝试在路径之间添加分号,如下所示:
set (BOOST_LIST
${boost_path}/filesystem/src/codecvt_error_category.cpp;
${boost_path}/filesystem/src/operations.cpp;
${boost_path}/filesystem/src/path.cpp;
${boost_path}/filesystem/src/path_traits.cpp;
${boost_path}/filesystem/src/portability.cpp;
${boost_path}/filesystem/src/unique_path.cpp;
${boost_path}/filesystem/src/utf8_codecvt_facet.cpp;
${boost_path}/filesystem/src/windows_file_codecvt.cpp;
${boost_path}/filesystem/src/windows_file_codecvt.hpp;
)
如果这不起作用,请尝试
add_library(boost SHARED
${boost_path}/filesystem/src/codecvt_error_category.cpp
${boost_path}/filesystem/src/operations.cpp
${boost_path}/filesystem/src/path.cpp
${boost_path}/filesystem/src/path_traits.cpp
...
${boost_path}/filesystem/src/windows_file_codecvt.hpp)
这可能有助于调试问题所在。