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) 5 set(argstring "") 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) 13 set(argstring "") 14 foreach(arg ${ARGN}) 15 set(argstring "${argstring} ${arg}") 16 endforeach() 17 set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}") 18 endfunction() 19 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() 29 30 # Appends value to all lists in ARGN, if the condition is true. 31 macro(append_list_if condition value) 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) 49 append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) 50 append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) 51 endmacro() 52 53 macro(append_have_file_definition filename varname list) 54 check_include_file("${filename}" "${varname}") 55 if (NOT ${varname}) 56 set("${varname}" 0) 57 endif() 58 list(APPEND ${list} "${varname}=${${varname}}") 59 endmacro() 60 61 macro(list_union output input1 input2) 62 set(${output}) 63 foreach(it ${${input1}}) 64 list(FIND ${input2} ${it} index) 65 if( NOT (index EQUAL -1)) 66 list(APPEND ${output} ${it}) 67 endif() 68 endforeach() 69 endmacro() 70