3 # Adds one or more values to the specified property of the specified target.
4 # Note that there are properties which require (semicolon-separated) lists,
5 # while others require space-separated strings. The function has a list of
6 # properties of the former variety and handles the values accordingly
7 function(add_target_property _module _propname)
8 list(APPEND _list_properties COMPILE_DEFINITIONS INCLUDE_DIRECTORIES LINK_DEPENDS)
10 get_target_property(_oldvalue ${_module} ${_propname})
12 set(_newvalue ${_oldvalue})
14 list(FIND _list_properties ${_propname} _list_index)
15 if(NOT _list_index EQUAL -1)
17 list(APPEND _newvalue ${ARGN})
20 foreach(_flag ${ARGN})
21 set(_newvalue "${_newvalue} ${_flag}")
24 set_property(TARGET ${_module} PROPERTY ${_propname} ${_newvalue})
27 # remove_target_compile_options
28 # Remove one option from the target COMPILE_OPTIONS property,
29 # previously added through add_compile_options
30 function(remove_target_compile_option _module _option)
31 get_target_property(_options ${_module} COMPILE_OPTIONS)
32 list(REMOVE_ITEM _options ${_option})
33 set_target_properties(${_module} PROPERTIES COMPILE_OPTIONS "${_options}")
36 # Wrapper functions for the important properties, using add_target_property
38 # Note that the functions for string properties take a single string
39 # argument while those for list properties can take a variable number of
40 # arguments, all of which will be added to the list
43 # add_target_link_flags(mymodule "-s --fatal-warnings")
45 function(add_target_link_flags _module _flags)
47 message(FATAL_ERROR "Excess arguments to add_target_link_flags! Module ${_module}, args ${ARGN}")
49 add_target_property(${_module} LINK_FLAGS ${_flags})