[英]CMake not settings compile definitions transitively
I am working on a project that use cmake
build.我正在开发一个使用cmake
构建的项目。 I have my cmake
files like this:我有这样的cmake
文件:
dirA/CMakeLists.txt :
add_library(A STATIC ${SRC_FILES})
target_compile_definitions(A public -DABC)
dirB/CMakeLists.txt :
add_library(B STATIC ${SRC_FILES})
target_link_libraries(B PRIVATE A) //-DABC is passed to B
dirC/CMakeLists.txt :
add_library(C STATIC ${SRC_FILES})
target_link_libraries(C B) ////-DABC is not passed to C
I observe that flag -DABC
is being passed to library B
but not to library C
.我观察到标志-DABC
被传递给库B
而不是库C
。 Is there a way to pass the compile definitions in cmake
transitively?有没有办法在cmake
中传递编译定义?
Sure.当然。 Link A to B publicly.公开链接 A 到 B。
target_link_libraries(B PUBLIC A)
Private linkage explicitly halts transitive propagation of properties.私有链接明确地停止了属性的传递传播。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.