【发布时间】:2012-09-11 17:52:19
【问题描述】:
我现在正在使用 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 中指示的所有源文件。谢谢!
【问题讨论】:
-
一切看起来都很好(除了结构图中的错字“thrid”)。我假设列出的 Boost.Filesystem 文件都实际存在于您指定的位置。您可以在设置
BOOST_LIST后尝试输出其内容:message("BOOST_LIST: ${BOOST_LIST}"),或者您可以获取boost目标get_target_property(BoostSources boost SOURCES)的源并输出:message("BoostSources: ${BoostSources}")以查看它是否对问题。 -
@Fraser 谢谢你的建议,看来只是在我的电脑上失败了,如果在另一台电脑上运行同样的脚本,那就没问题了。应该和我电脑的设置有关吧。
标签: c++ visual-c++ cmake