问题描述
我正在尝试使用 conan.cmake
进行多配置 cmake 构建。我也在关注 cmake_multi
文档。
似乎在 cmake_multi
的文档中,它们要求您同时传递 -g cmake_multi
和 -s build_type={type}
({type} being Release/Debug/...
)。
然而,在 conan.cmake
中,当前的 build_type
在调用 conan install -g cmake_multi ...
时看起来并没有被传递。
我现在遇到的情况是,如果我使用配置 "Release;Debug"
conan 报告丢失了一堆包
Requirements
boost/1.71.0@conan/stable from 'my_repo' - Cache
libconfig/1.6@internal/custom from 'my_repo' - Cache
...
Packages
boost/1.71.0@conan/stable:5b939a5d59f5432d9263459d17f2acb1535629bd - Missing
libconfig/1.6@internal/custom:ef44119b64b51a15f7b334090b2ff53fddcc38df - Missing
...
但是,如果我编辑 conan.cmake
以在结尾处也传递 "-sbuild_type=${CMAKE_BUILD_TYPE}"
conan_args
,它能够找到我的 Release 和 Debug 包。
谁能看到我在这里做错了什么?我没有在我的柯南配置文件中指定 build_type
,也没有将其设置为我的设置的一部分。
解决方法
在多次阅读 conan.cmake
的源代码后,我发现可以让它传播构建类型,您只需要将 PROFILE_AUTO
参数用于 conan_cmake_run
.
conan_cmake_run(
PROFILE ${CONAN_PROFILE}
CONFIGURATION_TYPES ${CONFIGURATION_TYPES}
PROFILE_AUTO build_type # Use build_type as detected by CMake,override any values in the profile
BUILD outdated
)