[CMake] Custom transitive list-valued properties
Mark Stijnman
mark.stijnman at gmail.com
Tue Feb 28 12:39:30 EST 2017
Hi,
Is there a way to declare a target property to be transitive and accumulate
into a list? Similar to how COMPILE_DEFINITIONS works, but for custom
properties? I know about COMPATIBLE_INTERFACE_STRING etc, which create a
transitive property, but the values don't accumulate into a list.
As a minimal example, I would like the below code to generate
properties.txt with contents like “C;B;A” (I don’t really care about the
order), instead of just "C", which it currently generates. Can I do this
somehow? Thanks,
regards Mark
cmake_minimum_required(VERSION 3.7)
project(proptest)
# insert something like “add_transitive_property(MYPROP)” here?
add_library(lib1 INTERFACE)
set_property(TARGET lib1 PROPERTY INTERFACE_MYPROP "A")
add_library(lib2 STATIC lib2.cpp)
set_property(TARGET lib2 PROPERTY INTERFACE_MYPROP "B")
target_link_libraries(lib2 lib1)
add_executable(proptest main.cpp)
target_link_libraries(proptest lib2)
set_property(TARGET proptest PROPERTY MYPROP "C")
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/properties.txt
CONTENT "$<TARGET_PROPERTY:proptest,MYPROP>")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170228/07618a58/attachment.html>
More information about the CMake
mailing list