CONAN_PKG::spdlog 使用 CMake 生成构建配置时未找到。
我使用的conan包是spdlog/1.3.1@bincrafters/stable。我有一个 CMake 可执行目标,它引用了一个 conan 包spdlog。我收到此错误消息:
[build] CMake Error at src/apps/ResultObserver/CMakeLists.txt:10 (ADD_EXECUTABLE):
[build] Target "ResultObserver" links to target "CONAN_PKG::spdlog" but the target
[build] was not found. Perhaps a find_package() call is missing for an IMPORTED
[build] target, or an ALIAS target is missing?
Run Code Online (Sandbox Code Playgroud)
我的 CMakeLists.txt 中有这些行。
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
ADD_EXECUTABLE(ResultObserver src/ResultObserver.cpp)
TARGET_LINK_LIBRARIES(ResultObserver CONAN_PKG::spdlog)
Run Code Online (Sandbox Code Playgroud)
另外,安装conan包后,会在build目录下生成conanbuildinfo.cmake文件。
我检查了文件内部。它包含这些行。
add_library(CONAN_PKG::spdlog INTERFACE IMPORTED)
# Property INTERFACE_LINK_FLAGS do not work, necessary to add to INTERFACE_LINK_LIBRARIES
set_property(TARGET CONAN_PKG::spdlog PROPERTY INTERFACE_LINK_LIBRARIES .........
Run Code Online (Sandbox Code Playgroud)
有谁知道原因吗?
您正在寻找TARGETS方法。你需要传递TARGETS到conan_basic_setup()生成CONAN_PKG::。否则,${CONAN_LIBS}将仅可用。
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
ADD_EXECUTABLE(ResultObserver src/ResultObserver.cpp)
TARGET_LINK_LIBRARIES(ResultObserver CONAN_PKG::spdlog)
Run Code Online (Sandbox Code Playgroud)
关于 CMake 目标生成器的更多信息在这里:https : //docs.conan.io/en/latest/integrations/build_system/cmake/cmake_generator.html#targets-approach
| 归档时间: |
|
| 查看次数: |
1965 次 |
| 最近记录: |