2011-06-13 10:36:40 +00:00
|
|
|
|
2011-09-03 14:57:27 +00:00
|
|
|
# add_target_property
|
|
|
|
# Adds one or more values to the specified property of the specified target.
|
|
|
|
# Note that there are properties which require (semicolon-separated) lists,
|
|
|
|
# while others require space-separated strings. The function has a list of
|
|
|
|
# properties of the former variety and handles the values accordingly
|
|
|
|
function(add_target_property _module _propname)
|
2019-04-27 09:33:37 +00:00
|
|
|
list(APPEND _list_properties COMPILE_DEFINITIONS INCLUDE_DIRECTORIES LINK_DEPENDS)
|
2011-09-03 14:57:27 +00:00
|
|
|
set(_newvalue "")
|
|
|
|
get_target_property(_oldvalue ${_module} ${_propname})
|
2011-10-02 18:59:33 +00:00
|
|
|
if(_oldvalue)
|
2011-09-03 14:57:27 +00:00
|
|
|
set(_newvalue ${_oldvalue})
|
|
|
|
endif()
|
|
|
|
list(FIND _list_properties ${_propname} _list_index)
|
2011-10-02 18:59:33 +00:00
|
|
|
if(NOT _list_index EQUAL -1)
|
2011-09-03 14:57:27 +00:00
|
|
|
# list property
|
|
|
|
list(APPEND _newvalue ${ARGN})
|
|
|
|
else()
|
|
|
|
# string property
|
|
|
|
foreach(_flag ${ARGN})
|
|
|
|
set(_newvalue "${_newvalue} ${_flag}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
set_property(TARGET ${_module} PROPERTY ${_propname} ${_newvalue})
|
|
|
|
endfunction()
|
|
|
|
|
2020-09-18 09:49:18 +00:00
|
|
|
# remove_target_compile_options
|
|
|
|
# Remove one option from the target COMPILE_OPTIONS property,
|
|
|
|
# previously added through add_compile_options
|
|
|
|
function(remove_target_compile_option _module _option)
|
|
|
|
get_target_property(_options ${_module} COMPILE_OPTIONS)
|
|
|
|
list(REMOVE_ITEM _options ${_option})
|
|
|
|
set_target_properties(${_module} PROPERTIES COMPILE_OPTIONS "${_options}")
|
|
|
|
endfunction()
|
|
|
|
|
2011-09-03 18:59:14 +00:00
|
|
|
# Wrapper functions for the important properties, using add_target_property
|
|
|
|
# where appropriate.
|
2011-09-03 14:57:27 +00:00
|
|
|
# Note that the functions for string properties take a single string
|
|
|
|
# argument while those for list properties can take a variable number of
|
|
|
|
# arguments, all of which will be added to the list
|
|
|
|
#
|
|
|
|
# Examples:
|
2013-06-22 12:15:50 +00:00
|
|
|
# add_target_link_flags(mymodule "-s --fatal-warnings")
|
2011-09-03 14:57:27 +00:00
|
|
|
|
|
|
|
function(add_target_link_flags _module _flags)
|
2011-10-02 18:59:33 +00:00
|
|
|
if(${ARGC} GREATER 2)
|
2013-06-22 12:15:50 +00:00
|
|
|
message(FATAL_ERROR "Excess arguments to add_target_link_flags! Module ${_module}, args ${ARGN}")
|
2011-09-03 14:57:27 +00:00
|
|
|
endif()
|
|
|
|
add_target_property(${_module} LINK_FLAGS ${_flags})
|
|
|
|
endfunction()
|