blob: 1eb8f2e3a23ef99fd9dde00b795a5ed29d872f08 [file] [log] [blame]
Alexey Samsonov163ab9d2013-01-18 16:05:21 +00001# Because compiler-rt spends a lot of time setting up custom compile flags,
2# define a handy helper function for it. The compile flags setting in CMake
3# has serious issues that make its syntax challenging at best.
4function(set_target_compile_flags target)
5 foreach(arg ${ARGN})
6 set(argstring "${argstring} ${arg}")
7 endforeach()
8 set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
9endfunction()
10
11function(set_target_link_flags target)
12 foreach(arg ${ARGN})
13 set(argstring "${argstring} ${arg}")
14 endforeach()
15 set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
16endfunction()
17
Peter Collingbournecbdea322013-10-25 23:03:34 +000018# Set the variable var_PYBOOL to True if var holds a true-ish string,
19# otherwise set it to False.
20macro(pythonize_bool var)
21 if (${var})
22 set(${var}_PYBOOL True)
23 else()
24 set(${var}_PYBOOL False)
25 endif()
26endmacro()
Alexey Samsonovb73db722014-02-18 07:52:40 +000027
Alexey Samsonov32956d62014-03-13 09:31:36 +000028# Appends value to all lists in ARGN, if the condition is true.
Kuba Brecka14c0c592014-10-15 22:47:54 +000029macro(append_list_if condition value)
Alexey Samsonov32956d62014-03-13 09:31:36 +000030 if(${condition})
31 foreach(list ${ARGN})
32 list(APPEND ${list} ${value})
33 endforeach()
Alexey Samsonovb73db722014-02-18 07:52:40 +000034 endif()
35endmacro()
36
Alexey Samsonovfe7e28c2014-03-13 11:31:10 +000037# Appends value to all strings in ARGN, if the condition is true.
38macro(append_string_if condition value)
39 if(${condition})
40 foreach(str ${ARGN})
41 set(${str} "${${str}} ${value}")
42 endforeach()
43 endif()
44endmacro()
45
Alexey Samsonovb73db722014-02-18 07:52:40 +000046macro(append_no_rtti_flag list)
Kuba Brecka14c0c592014-10-15 22:47:54 +000047 append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
48 append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
Alexey Samsonovb73db722014-02-18 07:52:40 +000049endmacro()