1# HandleLibcxxFlags - A set of macros used to setup the flags used to compile 2# and link libc++abi. These macros add flags to the following CMake variables. 3# - LIBUNWIND_COMPILE_FLAGS: flags used to compile libunwind 4# - LIBUNWIND_LINK_FLAGS: flags used to link libunwind 5# - LIBUNWIND_LIBRARIES: libraries to link libunwind to. 6 7include(CheckCCompilerFlag) 8include(CheckCXXCompilerFlag) 9include(HandleFlags) 10 11unset(add_flag_if_supported) 12 13# Add a list of flags to 'LIBUNWIND_COMPILE_FLAGS'. 14macro(add_compile_flags) 15 foreach(f ${ARGN}) 16 list(APPEND LIBUNWIND_COMPILE_FLAGS ${f}) 17 endforeach() 18endmacro() 19 20# If 'condition' is true then add the specified list of flags to 21# 'LIBUNWIND_COMPILE_FLAGS' 22macro(add_compile_flags_if condition) 23 if (${condition}) 24 add_compile_flags(${ARGN}) 25 endif() 26endmacro() 27 28# For each specified flag, add that flag to 'LIBUNWIND_COMPILE_FLAGS' if the 29# flag is supported by the C++ compiler. 30macro(add_compile_flags_if_supported) 31 foreach(flag ${ARGN}) 32 mangle_name("${flag}" flagname) 33 check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") 34 add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) 35 endforeach() 36endmacro() 37 38# Add a list of flags to 'LIBUNWIND_C_FLAGS'. 39macro(add_c_flags) 40 foreach(f ${ARGN}) 41 list(APPEND LIBUNWIND_C_FLAGS ${f}) 42 endforeach() 43endmacro() 44 45# If 'condition' is true then add the specified list of flags to 46# 'LIBUNWIND_C_FLAGS' 47macro(add_c_flags_if condition) 48 if (${condition}) 49 add_c_flags(${ARGN}) 50 endif() 51endmacro() 52 53# Add a list of flags to 'LIBUNWIND_CXX_FLAGS'. 54macro(add_cxx_flags) 55 foreach(f ${ARGN}) 56 list(APPEND LIBUNWIND_CXX_FLAGS ${f}) 57 endforeach() 58endmacro() 59 60# If 'condition' is true then add the specified list of flags to 61# 'LIBUNWIND_CXX_FLAGS' 62macro(add_cxx_flags_if condition) 63 if (${condition}) 64 add_cxx_flags(${ARGN}) 65 endif() 66endmacro() 67 68# For each specified flag, add that flag to 'LIBUNWIND_CXX_FLAGS' if the 69# flag is supported by the C compiler. 70macro(add_cxx_compile_flags_if_supported) 71 foreach(flag ${ARGN}) 72 mangle_name("${flag}" flagname) 73 check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") 74 add_cxx_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) 75 endforeach() 76endmacro() 77 78# Add a list of flags to 'LIBUNWIND_LINK_FLAGS'. 79macro(add_link_flags) 80 foreach(f ${ARGN}) 81 list(APPEND LIBUNWIND_LINK_FLAGS ${f}) 82 endforeach() 83endmacro() 84 85# If 'condition' is true then add the specified list of flags to 86# 'LIBUNWIND_LINK_FLAGS' 87macro(add_link_flags_if condition) 88 if (${condition}) 89 add_link_flags(${ARGN}) 90 endif() 91endmacro() 92 93# For each specified flag, add that flag to 'LIBUNWIND_LINK_FLAGS' if the 94# flag is supported by the C++ compiler. 95macro(add_link_flags_if_supported) 96 foreach(flag ${ARGN}) 97 mangle_name("${flag}" flagname) 98 check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG") 99 add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag}) 100 endforeach() 101endmacro() 102 103# Add a list of libraries or link flags to 'LIBUNWIND_LIBRARIES'. 104macro(add_library_flags) 105 foreach(lib ${ARGN}) 106 list(APPEND LIBUNWIND_LIBRARIES ${lib}) 107 endforeach() 108endmacro() 109 110# if 'condition' is true then add the specified list of libraries and flags 111# to 'LIBUNWIND_LIBRARIES'. 112macro(add_library_flags_if condition) 113 if(${condition}) 114 add_library_flags(${ARGN}) 115 endif() 116endmacro() 117