我有一个CMake 3.1+项目,我在其中使用目标和链接接口:
add_library(Core src/Core.cpp include/Core/Core.h)
target_include_directories(Core PUBLIC include)
target_link_libraries(Core PUBLIC Otherlib)
但是,我还使用了一个框架,该框架使用旧版CMake命令提供宏,作为target_link_libraries
的纯签名:
# Call add_library and target_link_libraries plain singature
orocos_component(MyComponent src/MyComponent.cpp)
# Warning ! Policy CMP0023 is not set: Plain and keyword target_link_libraries
# signatures cannot be mixed.
# target_link_libraries(MyComponent PRIVATE Core)
# The INTERFACE_LINK_LIBRARIES, INTERFACE_INCLUDE_DIRECTORIES and other interface properties of Core are not used
# Cause error: Core/Core.h: No such file directory
target_link_libraries(MyComponent Core)
要使其正常工作,我有哪些选择? 我可以做类似的事情:
target_include_directories(MyComponent
$<TARGET_PROPERTY:Core,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(MyComponent
$<TARGET_PROPERTY:Core,INTERFACE_LINK_LIBRARIES>
)
#etc...
但是,我有很多组件,而且解决方案比较繁琐。有更好的尝试吗?我不想将CMP0023
设置为OLD
。