CMake: Add functions to safely append to cmake properties
Encapsulate the boilerplate logic of querying a property and setting it to an empty string instead of NOTFOUND, before appending a value, removing duplicates and assigning the values back to the property. Change-Id: I7aefd11e9bdd77090324ec50c682d62181d22076 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
0e984f41e8
commit
8fe9cabe16
@ -580,3 +580,25 @@ function(_qt_internal_remove_args out_var)
|
||||
set(${out_var} "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Append ${ARGN} to ${target}'s ${property_name} property, removing duplicates.
|
||||
function(_qt_internal_append_to_target_property_without_duplicates target property_name)
|
||||
get_target_property(property "${target}" "${property_name}")
|
||||
if(NOT property)
|
||||
set(property "")
|
||||
endif()
|
||||
list(APPEND property ${ARGN})
|
||||
list(REMOVE_DUPLICATES property)
|
||||
set_property(TARGET "${target}" PROPERTY "${property_name}" "${property}")
|
||||
endfunction()
|
||||
|
||||
# Append ${ARGN} to global CMake ${property_name} property, removing duplicates.
|
||||
function(_qt_internal_append_to_cmake_property_without_duplicates property_name)
|
||||
get_cmake_property(property "${property_name}")
|
||||
if(NOT property)
|
||||
set(property "")
|
||||
endif()
|
||||
list(APPEND property ${ARGN})
|
||||
list(REMOVE_DUPLICATES property)
|
||||
set_property(GLOBAL PROPERTY "${property_name}" "${property}")
|
||||
endfunction()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user