-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAddCompileLinkFlags.cmake
34 lines (30 loc) · 1.65 KB
/
AddCompileLinkFlags.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
############################################################################################################
# AddCompileLinkFlags.cmake
############################################################################################################
############################################################################################################
# Append str to a string property of a target.
# target: string: target name.
# property: name of target’s property. e.g: COMPILE_FLAGS, or LINK_FLAGS
# str: string: string to be appended to the property
macro(append_target_property target property str)
get_target_property(current_property ${target} ${property})
if(NOT current_property) # property non-existent or empty
set_target_properties(${target} PROPERTIES ${property} ${str})
else()
set_target_properties(${target} PROPERTIES ${property} "${current_property} ${str}")
endif()
endmacro(append_target_property)
############################################################################################################
# Add/append compile flags to a target.
# target: string: target name.
# flags : string: compile flags to be appended
macro(add_compile_flags target flags)
append_target_property(${target} COMPILE_FLAGS ${flags})
endmacro(add_compile_flags)
############################################################################################################
# Add/append link flags to a target.
# target: string: target name.
# flags : string: link flags to be appended
macro(add_link_flags target flags)
append_target_property(${target} LINK_FLAGS ${flags})
endmacro(add_link_flags)