Custom transitive list-valued properties

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Custom transitive list-valued properties

Mark Stijnman

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>")


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake