Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 1 | # 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. |
| 4 | function(set_target_compile_flags target) |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 5 | set(argstring "") |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 6 | foreach(arg ${ARGN}) |
| 7 | set(argstring "${argstring} ${arg}") |
| 8 | endforeach() |
| 9 | set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}") |
| 10 | endfunction() |
| 11 | |
| 12 | function(set_target_link_flags target) |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 13 | set(argstring "") |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 14 | foreach(arg ${ARGN}) |
| 15 | set(argstring "${argstring} ${arg}") |
| 16 | endforeach() |
| 17 | set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}") |
| 18 | endfunction() |
| 19 | |
Peter Collingbourne | 7e8db74 | 2013-10-25 23:03:34 +0000 | [diff] [blame] | 20 | # Set the variable var_PYBOOL to True if var holds a true-ish string, |
| 21 | # otherwise set it to False. |
| 22 | macro(pythonize_bool var) |
| 23 | if (${var}) |
| 24 | set(${var}_PYBOOL True) |
| 25 | else() |
| 26 | set(${var}_PYBOOL False) |
| 27 | endif() |
| 28 | endmacro() |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 29 | |
| 30 | # Appends value to all lists in ARGN, if the condition is true. |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 31 | macro(append_list_if condition value) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 32 | if(${condition}) |
| 33 | foreach(list ${ARGN}) |
| 34 | list(APPEND ${list} ${value}) |
| 35 | endforeach() |
| 36 | endif() |
| 37 | endmacro() |
| 38 | |
| 39 | # Appends value to all strings in ARGN, if the condition is true. |
| 40 | macro(append_string_if condition value) |
| 41 | if(${condition}) |
| 42 | foreach(str ${ARGN}) |
| 43 | set(${str} "${${str}} ${value}") |
| 44 | endforeach() |
| 45 | endif() |
| 46 | endmacro() |
| 47 | |
| 48 | macro(append_no_rtti_flag list) |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 49 | append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) |
| 50 | append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 51 | endmacro() |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame] | 52 | |
| 53 | macro(append_have_file_definition filename varname list) |
| 54 | check_include_file("${filename}" "${varname}") |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 55 | if (NOT ${varname}) |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame] | 56 | set("${varname}" 0) |
| 57 | endif() |
| 58 | list(APPEND ${list} "${varname}=${${varname}}") |
| 59 | endmacro() |