【发布时间】:2020-08-20 06:52:33
【问题描述】:
我正在使用 Cmake 构建我的 C++ 项目,并且我正在使用 conan 来维护我的 boost 库。 我的conanfile.txt很简单,
[requires]
boost/1.71.0@conan/stable
[generators]
cmake
当我从柯南安装 boost 时,我可以使用以下命令,
conan install ..
或者,
conan install .. -s build_type=Debug
这两个命令都将 bost 库安装在我的 C:/.conan 文件夹中的两个不同文件夹中。
在 CMakeLists.txt 我有以下几行来查找 boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DEBUG_LIBS ON)
set(Boost_USE_RELEASE_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS program_options)
但是,当我配置 cmake 时,
cmake .. -DBoost_DEBUG=ON
它没有找到 boost 库的调试版本。它总是显示它指向发布版本。所以很自然,下面的命令就起作用了,
cmake --build . --config Release
但是,以下命令失败,
cmake --build . --config Debug
因为它仍在尝试链接 ot 发布版本。
如何重新配置我的 cmake 和 conan 设置,以便在调试版本和发布版本之间轻松切换?有什么建议吗?
干杯, M
【问题讨论】:
-
旁注:我真的建议您使用
boost/1.71.0参考 (conan.io/center/boost/1.73.0)。这是与柯南中心索引 (github.com/conan-io/conan-center-index) 中社区策划食谱相对应的参考。