我有两个库:
a
;b
: 一个仅头文件的库,它依赖于a
.
我不确定是否可以链接b
到a
. 如果是这样,我该怎么做?
事实上,我有一个c
依赖于两者的第三个库。此 CMake 脚本不起作用:
[...]
add_library(a ${a_SRC})
target_link_libraries(a CONAN_PKG::<foo>)
add_library(b INTERFACE)
target_sources(b INTERFACE ${b_SRC})
target_include_directories(b INTERFACE "${PROJECT_SOURCE_DIR}/src/include/b/")
target_link_libraries(b INTERFACE a) # This has no effect, I think!
add_executable(c ${c_SRC})
target_link_libraries(c b a)
我通过将源文件添加a
到c
.
[...]
add_executable(c ${c_SRC} ${a_SRC})
[...]