llvm-project
116 строк · 3.3 Кб
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)
15foreach(f ${ARGN})
16list(APPEND LIBUNWIND_COMPILE_FLAGS ${f})
17endforeach()
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)
23if (${condition})
24add_compile_flags(${ARGN})
25endif()
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)
31foreach(flag ${ARGN})
32mangle_name("${flag}" flagname)
33check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
34add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
35endforeach()
36endmacro()
37
38# Add a list of flags to 'LIBUNWIND_C_FLAGS'.
39macro(add_c_flags)
40foreach(f ${ARGN})
41list(APPEND LIBUNWIND_C_FLAGS ${f})
42endforeach()
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)
48if (${condition})
49add_c_flags(${ARGN})
50endif()
51endmacro()
52
53# Add a list of flags to 'LIBUNWIND_CXX_FLAGS'.
54macro(add_cxx_flags)
55foreach(f ${ARGN})
56list(APPEND LIBUNWIND_CXX_FLAGS ${f})
57endforeach()
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)
63if (${condition})
64add_cxx_flags(${ARGN})
65endif()
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)
71foreach(flag ${ARGN})
72mangle_name("${flag}" flagname)
73check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
74add_cxx_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
75endforeach()
76endmacro()
77
78# Add a list of flags to 'LIBUNWIND_LINK_FLAGS'.
79macro(add_link_flags)
80foreach(f ${ARGN})
81list(APPEND LIBUNWIND_LINK_FLAGS ${f})
82endforeach()
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)
88if (${condition})
89add_link_flags(${ARGN})
90endif()
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)
96foreach(flag ${ARGN})
97mangle_name("${flag}" flagname)
98check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
99add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
100endforeach()
101endmacro()
102
103# Add a list of libraries or link flags to 'LIBUNWIND_LIBRARIES'.
104macro(add_library_flags)
105foreach(lib ${ARGN})
106list(APPEND LIBUNWIND_LIBRARIES ${lib})
107endforeach()
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)
113if(${condition})
114add_library_flags(${ARGN})
115endif()
116endmacro()
117