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.
7 include(CheckCCompilerFlag)
8 include(CheckCXXCompilerFlag)
11 unset(add_flag_if_supported)
13 # Add a list of flags to 'LIBUNWIND_COMPILE_FLAGS'.
14 macro(add_compile_flags)
16 list(APPEND LIBUNWIND_COMPILE_FLAGS ${f})
20 # If 'condition' is true then add the specified list of flags to
21 # 'LIBUNWIND_COMPILE_FLAGS'
22 macro(add_compile_flags_if condition)
24 add_compile_flags(${ARGN})
28 # For each specified flag, add that flag to 'LIBUNWIND_COMPILE_FLAGS' if the
29 # flag is supported by the C++ compiler.
30 macro(add_compile_flags_if_supported)
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})
38 # Add a list of flags to 'LIBUNWIND_C_FLAGS'.
41 list(APPEND LIBUNWIND_C_FLAGS ${f})
45 # If 'condition' is true then add the specified list of flags to
47 macro(add_c_flags_if condition)
53 # Add a list of flags to 'LIBUNWIND_CXX_FLAGS'.
56 list(APPEND LIBUNWIND_CXX_FLAGS ${f})
60 # If 'condition' is true then add the specified list of flags to
61 # 'LIBUNWIND_CXX_FLAGS'
62 macro(add_cxx_flags_if condition)
64 add_cxx_flags(${ARGN})
68 # For each specified flag, add that flag to 'LIBUNWIND_CXX_FLAGS' if the
69 # flag is supported by the C compiler.
70 macro(add_cxx_compile_flags_if_supported)
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})
78 # Add a list of flags to 'LIBUNWIND_LINK_FLAGS'.
81 list(APPEND LIBUNWIND_LINK_FLAGS ${f})
85 # If 'condition' is true then add the specified list of flags to
86 # 'LIBUNWIND_LINK_FLAGS'
87 macro(add_link_flags_if condition)
89 add_link_flags(${ARGN})
93 # For each specified flag, add that flag to 'LIBUNWIND_LINK_FLAGS' if the
94 # flag is supported by the C++ compiler.
95 macro(add_link_flags_if_supported)
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})
103 # Add a list of libraries or link flags to 'LIBUNWIND_LIBRARIES'.
104 macro(add_library_flags)
106 list(APPEND LIBUNWIND_LIBRARIES ${lib})
110 # if 'condition' is true then add the specified list of libraries and flags
111 # to 'LIBUNWIND_LIBRARIES'.
112 macro(add_library_flags_if condition)
114 add_library_flags(${ARGN})