我对CMake使用conan_cmake_run()宏。当我添加两个具有相同外部dep的库时。它会导致一条错误消息。
示例:
conan_cmake_run(REQUIRES boost/1.74.0 BASIC_SETUP CMAKE_TARGETS)
conan_cmake_run(REQUIRES hdf5/1.10.6 BASIC_SETUP CMAKE_TARGETS)Boost和HDF5将添加zlib作为外部dep。因此,在CMake配置过程中,这会导致以下错误消息。
CMake Error at build/conanbuildinfo_multi.cmake:152 (add_library):
add_library cannot create imported target "CONAN_PKG::zlib" because another
target with the same name already exists.
Call Stack (most recent call first):
build/conanbuildinfo_multi.cmake:286 (conan_define_targets)
cmake/modules/conan.cmake:515 (conan_basic_setup)
CMakeLists.txt:104 (conan_cmake_run)有没有办法显式地不为boost/1.74.0或hdf5/1.10.6添加"CONAN_PKG::zlib“?
提前谢谢你!
最好的
发布于 2020-09-30 04:43:23
非常重要的一点是,不要运行两次cmake_conan_run,而是使用多个参数只运行一次,例如:
conan_cmake_run(REQUIRES boost/1.74.0 hdf5/1.10.6 BASIC_SETUP CMAKE_TARGETS)进行单独运行时,第二次运行将覆盖前一次运行的结果。此外,在安装过程中可能会出现一些冲突(比如boost/1.74依赖于zlib/1.2.8,hdf5/1.10.6依赖于zlib/1.2.11),而这些冲突是不会被注意到的。在安装项目的依赖项时,应该执行单个conan install或单个conan_cmake_run()。
https://stackoverflow.com/questions/64126038
复制相似问题