150
|
1 # See www/CMake.html for instructions on how to build libcxxabi with CMake.
|
|
2
|
|
3 #===============================================================================
|
|
4 # Setup Project
|
|
5 #===============================================================================
|
|
6
|
252
|
7 cmake_minimum_required(VERSION 3.20.0)
|
150
|
8
|
236
|
9 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|
10
|
150
|
11 # Add path for custom modules
|
236
|
12 list(INSERT CMAKE_MODULE_PATH 0
|
150
|
13 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
14 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
252
|
15 "${CMAKE_CURRENT_SOURCE_DIR}/../runtimes/cmake/Modules"
|
236
|
16 "${LLVM_COMMON_CMAKE_UTILS}"
|
|
17 "${LLVM_COMMON_CMAKE_UTILS}/Modules"
|
150
|
18 )
|
|
19
|
221
|
20 set(CMAKE_FOLDER "libc++")
|
|
21
|
|
22 set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
23 set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
24 set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
|
|
25 "Specify path to libc++ source.")
|
|
26
|
236
|
27 include(GNUInstallDirs)
|
221
|
28
|
150
|
29 # Require out of source build.
|
|
30 include(MacroEnsureOutOfSourceBuild)
|
|
31 MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
|
|
32 "${PROJECT_NAME} requires an out of source build. Please create a separate
|
|
33 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
|
|
34 )
|
|
35
|
|
36 #===============================================================================
|
|
37 # Setup CMake Options
|
|
38 #===============================================================================
|
|
39 include(CMakeDependentOption)
|
|
40 include(HandleCompilerRT)
|
|
41
|
|
42 # Define options.
|
|
43 option(LIBCXXABI_ENABLE_EXCEPTIONS
|
|
44 "Provide support for exceptions in the runtime.
|
|
45 When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON)
|
|
46 option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
252
|
47 option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
|
150
|
48 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
|
49 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
|
|
50 option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
|
|
51 option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
|
52 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
|
|
53 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
|
221
|
54 option(LIBCXXABI_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
|
150
|
55 option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
|
|
56 "Build libc++abi with an externalized threading API.
|
|
57 This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF)
|
173
|
58 option(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST
|
|
59 "Make dynamic_cast more forgiving when type_info's mistakenly have hidden \
|
|
60 visibility, and thus multiple type_infos can exist for a single type. \
|
|
61 When the dynamic_cast would normally fail, this option will cause the \
|
|
62 library to try comparing the type_info names to see if they are equal \
|
|
63 instead." OFF)
|
150
|
64
|
|
65 option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
|
221
|
66 "Build libc++abi with definitions for operator new/delete. These are normally
|
|
67 defined in libc++abi, but it is also possible to define them in libc++, in
|
|
68 which case the definition in libc++abi should be turned off." ON)
|
236
|
69 option(LIBCXXABI_BUILD_32_BITS "Build 32 bit multilib libc++abi. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS})
|
|
70 if (LIBCXXABI_BUILD_32_BITS)
|
|
71 message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.")
|
|
72 endif()
|
|
73
|
150
|
74 option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS})
|
|
75 set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
76 "Define suffix of library directory name (32/64)")
|
236
|
77 option(LIBCXXABI_INSTALL_HEADERS "Install the libc++abi headers." ON)
|
150
|
78 option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
|
236
|
79
|
|
80 set(LIBCXXABI_SHARED_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the shared libc++abi runtime library.")
|
|
81 set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the static libc++abi runtime library.")
|
|
82
|
|
83 set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path to install the libc++abi headers at.")
|
|
84
|
|
85 if(LLVM_LIBRARY_OUTPUT_INTDIR)
|
|
86 set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
|
|
87 else()
|
|
88 set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
|
|
89 endif()
|
|
90
|
|
91 # TODO: Remove this after branching for LLVM 15
|
|
92 if(LIBCXXABI_SYSROOT OR LIBCXXABI_TARGET_TRIPLE OR LIBCXXABI_GCC_TOOLCHAIN)
|
|
93 message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead")
|
|
94 endif()
|
|
95
|
150
|
96 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
|
|
97 set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
|
|
98 "Version of libc++abi. This will be reflected in the name of the shared \
|
|
99 library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \
|
|
100 result in the library being named libc++abi.x.y.dylib, along with the \
|
|
101 usual symlinks pointing to that.")
|
|
102
|
|
103 # Default to building a shared library so that the default options still test
|
236
|
104 # the libc++abi that is being built. The problem with testing a static libc++abi
|
|
105 # is that libc++ will prefer a dynamic libc++abi from the system over a static
|
|
106 # libc++abi from the output directory.
|
150
|
107 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
|
|
108 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
|
|
109
|
|
110 cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
|
|
111 "Install the static libc++abi library." ON
|
|
112 "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
|
|
113 cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
|
|
114 "Install the shared libc++abi library." ON
|
|
115 "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
|
|
116
|
|
117 cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
|
|
118 "Statically link the LLVM unwinder to static library" ON
|
236
|
119 "LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF)
|
150
|
120 cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
|
|
121 "Statically link the LLVM unwinder to shared library" ON
|
236
|
122 "LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF)
|
150
|
123
|
|
124 option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
|
|
125 # The default terminate handler attempts to demangle uncaught exceptions, which
|
|
126 # causes extra I/O and demangling code to be pulled in.
|
|
127 option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF)
|
221
|
128 option(LIBCXXABI_NON_DEMANGLING_TERMINATE "Set this to make the terminate handler
|
|
129 avoid demangling" OFF)
|
150
|
130
|
|
131 if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
|
|
132 message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
|
|
133 endif()
|
|
134
|
236
|
135 # TODO: Remove this, which shouldn't be necessary since we know we're being built
|
|
136 # side-by-side with libc++.
|
221
|
137 set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
|
|
138 "Specify path to libc++ includes.")
|
236
|
139
|
|
140 set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF)
|
|
141 if (WIN32)
|
|
142 set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON)
|
|
143 endif()
|
|
144 option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
|
|
145 "Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
|
|
146
|
|
147 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
148 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared-gcc.cfg.in")
|
|
149 elseif(MINGW)
|
|
150 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
|
|
151 elseif(WIN32) # clang-cl
|
|
152 if (LIBCXXABI_ENABLE_SHARED)
|
|
153 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared-clangcl.cfg.in")
|
|
154 else()
|
|
155 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-static-clangcl.cfg.in")
|
221
|
156 endif()
|
236
|
157 else()
|
|
158 if (LIBCXXABI_ENABLE_SHARED)
|
|
159 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared.cfg.in")
|
221
|
160 else()
|
236
|
161 set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-static.cfg.in")
|
221
|
162 endif()
|
150
|
163 endif()
|
236
|
164 set(LIBCXXABI_TEST_CONFIG "${LIBCXXABI_DEFAULT_TEST_CONFIG}" CACHE STRING
|
|
165 "The path to the Lit testing configuration to use when running the tests.
|
|
166 If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxxabi/test/configs'.")
|
|
167 if (NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}")
|
|
168 set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXXABI_TEST_CONFIG}")
|
|
169 endif()
|
|
170 message(STATUS "Using libc++abi testing configuration: ${LIBCXXABI_TEST_CONFIG}")
|
221
|
171 set(LIBCXXABI_TEST_PARAMS "" CACHE STRING
|
|
172 "A list of parameters to run the Lit test suite with.")
|
|
173
|
150
|
174 #===============================================================================
|
|
175 # Configure System
|
|
176 #===============================================================================
|
|
177
|
|
178 # Add path for custom modules
|
|
179 set(CMAKE_MODULE_PATH
|
|
180 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
181 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
182 ${CMAKE_MODULE_PATH}
|
|
183 )
|
|
184
|
236
|
185 set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
|
|
186 "Path where built libc++abi runtime libraries should be installed.")
|
|
187
|
150
|
188 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
221
|
189 set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
|
|
190 set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
|
223
|
191 set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
|
|
192 "Path where built libc++abi libraries should be installed.")
|
150
|
193 if(LIBCXX_LIBDIR_SUBDIR)
|
|
194 string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
|
|
195 string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
|
|
196 endif()
|
|
197 else()
|
236
|
198 if(LLVM_LIBRARY_OUTPUT_INTDIR)
|
|
199 set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
|
|
200 set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
|
201 else()
|
|
202 set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
|
|
203 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
|
|
204 endif()
|
223
|
205 set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
|
|
206 "Path where built libc++abi libraries should be installed.")
|
150
|
207 endif()
|
|
208
|
|
209 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
|
210 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
|
211 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
|
212
|
236
|
213 # By default, libcxx and libcxxabi share a library directory.
|
150
|
214 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
|
|
215 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
|
|
216 "The path to libc++ library." FORCE)
|
|
217 endif()
|
|
218
|
|
219 # Declare libc++abi configuration variables.
|
|
220 # They are intended for use as follows:
|
|
221 # LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker.
|
|
222 # LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker.
|
|
223 # LIBCXXABI_COMPILE_FLAGS: Compile only flags.
|
|
224 # LIBCXXABI_LINK_FLAGS: Linker only flags.
|
|
225 # LIBCXXABI_LIBRARIES: libraries libc++abi is linked to.
|
|
226
|
|
227 set(LIBCXXABI_C_FLAGS "")
|
|
228 set(LIBCXXABI_CXX_FLAGS "")
|
|
229 set(LIBCXXABI_COMPILE_FLAGS "")
|
|
230 set(LIBCXXABI_LINK_FLAGS "")
|
|
231 set(LIBCXXABI_LIBRARIES "")
|
236
|
232 set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
|
|
233 "Additional Compile only flags which can be provided in cache")
|
|
234 set(LIBCXXABI_ADDITIONAL_LIBRARIES "" CACHE STRING
|
|
235 "Additional libraries libc++abi is linked to which can be provided in cache")
|
150
|
236
|
|
237 # Include macros for adding and removing libc++abi flags.
|
|
238 include(HandleLibcxxabiFlags)
|
|
239
|
|
240 #===============================================================================
|
|
241 # Setup Compiler Flags
|
|
242 #===============================================================================
|
|
243
|
|
244 # Configure target flags
|
236
|
245 if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
252
|
246 add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
|
236
|
247 set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)
|
150
|
248 endif()
|
236
|
249 add_compile_flags("${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
|
|
250 add_library_flags("${LIBCXXABI_ADDITIONAL_LIBRARIES}")
|
150
|
251
|
|
252 # Configure compiler. Must happen after setting the target flags.
|
|
253 include(config-ix)
|
|
254
|
236
|
255 if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
150
|
256 list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
|
|
257 # cmake 3.14 and above remove system include paths that are explicitly
|
|
258 # passed on the command line. We build with -nostdinc++ and explicitly add
|
|
259 # just the libcxx system include paths with -I on the command line.
|
|
260 # Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effectively prevents cmake
|
|
261 # from removing these.
|
|
262 # See: https://gitlab.kitware.com/cmake/cmake/issues/19227
|
|
263 set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
|
|
264 # Remove -stdlib flags to prevent them from causing an unused flag warning.
|
221
|
265 string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
266 string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
150
|
267 string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
268 string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
269 endif()
|
|
270
|
|
271 # Let the library headers know they are currently being used to build the
|
|
272 # library.
|
|
273 add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY)
|
|
274
|
221
|
275 # libcxxabi needs to, for various reasons, include the libcpp headers as if
|
|
276 # it is being built as part of libcxx.
|
|
277 add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
|
|
278
|
150
|
279 # Get feature flags.
|
|
280 add_compile_flags_if_supported(-fstrict-aliasing)
|
|
281
|
|
282 # Exceptions
|
|
283 if (LIBCXXABI_ENABLE_EXCEPTIONS)
|
|
284 # Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
285 # functions never throw a C++ exception.
|
|
286 add_compile_flags_if_supported(-EHsc)
|
|
287 # Do we really need to be run through the C compiler ?
|
|
288 add_c_compile_flags_if_supported(-funwind-tables)
|
|
289 else()
|
|
290 add_compile_flags_if_supported(-fno-exceptions)
|
|
291 add_compile_flags_if_supported(-EHs-)
|
|
292 add_compile_flags_if_supported(-EHa-)
|
|
293 endif()
|
|
294
|
|
295 # Assert
|
|
296 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
297 if (LIBCXXABI_ENABLE_ASSERTIONS)
|
|
298 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
|
299 if (NOT MSVC)
|
|
300 list(APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG)
|
|
301 endif()
|
|
302 # On Release builds cmake automatically defines NDEBUG, so we
|
|
303 # explicitly undefine it:
|
|
304 if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
305 list(APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG)
|
|
306 endif()
|
|
307 else()
|
|
308 if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
|
309 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
|
|
310 endif()
|
|
311 endif()
|
|
312
|
|
313 # Threading
|
|
314 if (NOT LIBCXXABI_ENABLE_THREADS)
|
|
315 if (LIBCXXABI_HAS_PTHREAD_API)
|
|
316 message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
|
|
317 " be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
318 " is also set to ON.")
|
|
319 endif()
|
221
|
320 if (LIBCXXABI_HAS_WIN32_THREAD_API)
|
|
321 message(FATAL_ERROR "LIBCXXABI_HAS_WIN32_THREAD_API can only"
|
|
322 " be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
323 " is also set to ON.")
|
|
324 endif()
|
150
|
325 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
326 message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only"
|
|
327 " be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
328 " is also set to ON.")
|
|
329 endif()
|
|
330 add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
|
|
331 endif()
|
|
332
|
|
333 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
334 if (LIBCXXABI_HAS_PTHREAD_API)
|
|
335 message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
|
|
336 " and LIBCXXABI_HAS_PTHREAD_API cannot be both"
|
|
337 " set to ON at the same time.")
|
|
338 endif()
|
221
|
339 if (LIBCXXABI_HAS_WIN32_THREAD_API)
|
|
340 message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
|
|
341 " and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both"
|
|
342 " set to ON at the same time.")
|
|
343 endif()
|
150
|
344 endif()
|
|
345
|
221
|
346 if (LIBCXXABI_HAS_PTHREAD_API)
|
|
347 if (LIBCXXABI_HAS_WIN32_THREAD_API)
|
|
348 message(FATAL_ERROR "The options LIBCXXABI_HAS_PTHREAD_API"
|
|
349 "and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both"
|
|
350 "set to ON at the same time.")
|
|
351 endif()
|
|
352 endif()
|
|
353
|
150
|
354 if (LLVM_ENABLE_MODULES)
|
|
355 # Ignore that the rest of the modules flags are now unused.
|
|
356 add_compile_flags_if_supported(-Wno-unused-command-line-argument)
|
|
357 add_compile_flags(-fno-modules)
|
|
358 endif()
|
|
359
|
|
360 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
|
252
|
361 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) OR MINGW)
|
150
|
362 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
|
|
363 endif()
|
|
364
|
|
365 if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS)
|
|
366 # Need to allow unresolved symbols if this is to work with shared library builds
|
|
367 if (APPLE)
|
|
368 list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup")
|
|
369 else()
|
|
370 # Relax this restriction from HandleLLVMOptions
|
|
371 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
|
372 endif()
|
|
373 endif()
|
|
374
|
|
375 if (LIBCXXABI_HAS_PTHREAD_API)
|
|
376 add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
|
|
377 endif()
|
|
378
|
221
|
379 if (LIBCXXABI_HAS_WIN32_THREAD_API)
|
|
380 add_definitions(-D_LIBCPP_HAS_THREAD_API_WIN32)
|
|
381 endif()
|
|
382
|
150
|
383 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
384 add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL)
|
|
385 endif()
|
|
386
|
|
387 if (MSVC)
|
|
388 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
389 endif()
|
|
390
|
|
391 if (LIBCXXABI_SILENT_TERMINATE)
|
|
392 add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
|
|
393 endif()
|
|
394
|
221
|
395 if (LIBCXXABI_NON_DEMANGLING_TERMINATE)
|
|
396 add_definitions(-DLIBCXXABI_NON_DEMANGLING_TERMINATE)
|
|
397 endif()
|
|
398
|
150
|
399 if (LIBCXXABI_BAREMETAL)
|
|
400 add_definitions(-DLIBCXXABI_BAREMETAL)
|
|
401 endif()
|
|
402
|
236
|
403 if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
150
|
404 if (LIBCXXABI_HAS_PTHREAD_LIB)
|
|
405 add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
|
|
406 endif()
|
|
407 endif()
|
|
408
|
|
409 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
|
|
410 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
|
|
411 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
|
|
412
|
236
|
413 # On AIX, avoid picking up VMX extensions(i.e. vec_malloc) which would change
|
|
414 # the default alignment of the allocators here.
|
|
415 if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
|
416 add_definitions("-D_XOPEN_SOURCE=700")
|
|
417 endif()
|
|
418
|
150
|
419 #===============================================================================
|
|
420 # Setup Source Code
|
|
421 #===============================================================================
|
|
422
|
|
423 set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
|
|
424 "Specify path to libunwind includes." FORCE)
|
|
425 set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
|
|
426 "Specify path to libunwind source." FORCE)
|
|
427
|
|
428 if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
|
|
429 find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
|
|
430 PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
|
|
431 ${LIBCXXABI_LIBUNWIND_PATH}/include
|
|
432 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
|
|
433 ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
|
|
434 ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
|
|
435 ${LLVM_MAIN_SRC_DIR}/../libunwind/include
|
|
436 NO_DEFAULT_PATH
|
|
437 NO_CMAKE_FIND_ROOT_PATH
|
|
438 )
|
|
439
|
|
440 if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
|
|
441 set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
|
|
442 endif()
|
252
|
443 endif()
|
150
|
444
|
252
|
445 if (NOT "${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}" STREQUAL "")
|
|
446 include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
|
150
|
447 endif()
|
|
448
|
|
449 # Add source code. This also contains all of the logic for deciding linker flags
|
|
450 # soname, etc...
|
236
|
451 add_subdirectory(include)
|
150
|
452 add_subdirectory(src)
|
|
453
|
|
454 if (LIBCXXABI_INCLUDE_TESTS)
|
221
|
455 add_subdirectory(test)
|
|
456 add_subdirectory(fuzz)
|
150
|
457 endif()
|