1 # See www/CMake.html for instructions on how to build libcxxabi with CMake.
3 if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxx")
4 message(FATAL_ERROR "libc++abi now requires being built in a monorepo layout with libcxx available")
7 #===============================================================================
9 #===============================================================================
11 cmake_minimum_required(VERSION 3.13.4)
14 cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
17 # Add path for custom modules
19 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
20 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
24 set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
25 set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
26 set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
27 "Specify path to libc++ source.")
29 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
30 project(libcxxabi CXX C)
32 set(PACKAGE_NAME libcxxabi)
33 set(PACKAGE_VERSION 11.0.0git)
34 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
35 set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
37 # Add the CMake module path of libcxx so we can reuse HandleOutOfTreeLLVM.cmake
38 set(LIBCXXABI_LIBCXX_CMAKE_PATH "${LIBCXXABI_LIBCXX_PATH}/cmake/Modules")
39 list(APPEND CMAKE_MODULE_PATH "${LIBCXXABI_LIBCXX_CMAKE_PATH}")
41 # In a standalone build, we don't have llvm to automatically generate the
42 # llvm-lit script for us. So we need to provide an explicit directory that
43 # the configurator should write the script into.
44 set(LIBCXXABI_STANDALONE_BUILD 1)
45 set(LLVM_LIT_OUTPUT_DIR "${LIBCXXABI_BINARY_DIR}/bin")
47 # Find the LLVM sources and simulate LLVM CMake options.
48 include(HandleOutOfTreeLLVM)
51 if (LIBCXXABI_STANDALONE_BUILD)
52 find_package(Python3 COMPONENTS Interpreter)
53 if(NOT Python3_Interpreter_FOUND)
54 message(WARNING "Python3 not found, using python2 as a fallback")
55 find_package(Python2 COMPONENTS Interpreter REQUIRED)
56 if(Python2_VERSION VERSION_LESS 2.7)
57 message(SEND_ERROR "Python 2.7 or newer is required")
60 # Treat python2 as python3
61 add_executable(Python3::Interpreter IMPORTED)
62 set_target_properties(Python3::Interpreter PROPERTIES
63 IMPORTED_LOCATION ${Python2_EXECUTABLE})
64 set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
68 # Require out of source build.
69 include(MacroEnsureOutOfSourceBuild)
70 MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
71 "${PROJECT_NAME} requires an out of source build. Please create a separate
72 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
75 #===============================================================================
77 #===============================================================================
78 include(CMakeDependentOption)
79 include(HandleCompilerRT)
82 option(LIBCXXABI_ENABLE_EXCEPTIONS
83 "Provide support for exceptions in the runtime.
84 When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON)
85 option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
86 option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
87 option(LIBCXXABI_ENABLE_PIC "Build Position-Independent Code, even in static library" ON)
88 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
89 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
90 option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
91 option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
92 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
93 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
94 option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
95 "Build libc++abi with an externalized threading API.
96 This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF)
97 option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
98 "Build libc++abi with an externalized threading library.
99 This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF)
100 option(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST
101 "Make dynamic_cast more forgiving when type_info's mistakenly have hidden \
102 visibility, and thus multiple type_infos can exist for a single type. \
103 When the dynamic_cast would normally fail, this option will cause the \
104 library to try comparing the type_info names to see if they are equal \
107 option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
108 "Build libc++abi with definitions for operator new/delete. These are normally
109 defined in libc++abi, but it is also possible to define them in libc++, in
110 which case the definition in libc++abi should be turned off." ON)
111 option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS})
112 option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS})
113 set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
114 "Define suffix of library directory name (32/64)")
115 option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
116 set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
117 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
118 set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
119 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
120 set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
121 "Version of libc++abi. This will be reflected in the name of the shared \
122 library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \
123 result in the library being named libc++abi.x.y.dylib, along with the \
124 usual symlinks pointing to that.")
126 # Default to building a shared library so that the default options still test
127 # the libc++abi that is being built. There are two problems with testing a
128 # static libc++abi. In the case of a standalone build, the tests will link the
129 # system's libc++, which might not have been built against our libc++abi. In the
130 # case of an in tree build, libc++ will prefer a dynamic libc++abi from the
131 # system over a static libc++abi from the output directory.
132 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
133 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
135 cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
136 "Install the static libc++abi library." ON
137 "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
138 cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
139 "Install the shared libc++abi library." ON
140 "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
142 cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
143 "Statically link the LLVM unwinder to static library" ON
144 "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)
145 cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
146 "Statically link the LLVM unwinder to shared library" ON
147 "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF)
149 option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
150 # The default terminate handler attempts to demangle uncaught exceptions, which
151 # causes extra I/O and demangling code to be pulled in.
152 option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF)
154 if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
155 message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
158 set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_PATH}/include" CACHE PATH
159 "Specify path to libc++ includes.")
160 message(STATUS "Libc++abi will be using libc++ includes from ${LIBCXXABI_LIBCXX_INCLUDES}")
162 option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
163 "Do not export any symbols from the static library." OFF)
165 set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING
166 "The Lit testing configuration to use when running the tests.")
167 set(LIBCXXABI_TEST_PARAMS "" CACHE STRING
168 "A list of parameters to run the Lit test suite with.")
170 #===============================================================================
172 #===============================================================================
174 # Add path for custom modules
175 set(CMAKE_MODULE_PATH
176 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
177 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
181 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
182 set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
183 set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
184 if(LIBCXX_LIBDIR_SUBDIR)
185 string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
186 string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
188 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
189 set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
190 set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
192 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
193 set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
196 set(LIBCXXABI_INSTALL_PREFIX "" CACHE STRING "Define libc++abi destination prefix.")
198 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
199 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
200 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
202 # By default, for non-standalone builds, libcxx and libcxxabi share a library
204 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
205 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
206 "The path to libc++ library." FORCE)
209 # Check that we can build with 32 bits if requested.
210 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
211 if (LIBCXXABI_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
212 message(STATUS "Building 32 bits executables and libraries.")
214 elseif(LIBCXXABI_BUILD_32_BITS)
215 message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS=ON is not supported on this platform.")
218 # Declare libc++abi configuration variables.
219 # They are intended for use as follows:
220 # LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker.
221 # LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker.
222 # LIBCXXABI_COMPILE_FLAGS: Compile only flags.
223 # LIBCXXABI_LINK_FLAGS: Linker only flags.
224 # LIBCXXABI_LIBRARIES: libraries libc++abi is linked to.
226 set(LIBCXXABI_C_FLAGS "")
227 set(LIBCXXABI_CXX_FLAGS "")
228 set(LIBCXXABI_COMPILE_FLAGS "")
229 set(LIBCXXABI_LINK_FLAGS "")
230 set(LIBCXXABI_LIBRARIES "")
232 # Include macros for adding and removing libc++abi flags.
233 include(HandleLibcxxabiFlags)
235 #===============================================================================
236 # Setup Compiler Flags
237 #===============================================================================
239 # Configure target flags
240 add_target_flags_if(LIBCXXABI_BUILD_32_BITS "-m32")
242 if(LIBCXXABI_TARGET_TRIPLE)
243 add_target_flags("--target=${LIBCXXABI_TARGET_TRIPLE}")
244 elseif(CMAKE_CXX_COMPILER_TARGET)
245 set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
247 if(LIBCXX_GCC_TOOLCHAIN)
248 add_target_flags("--gcc-toolchain=${LIBCXXABI_GCC_TOOLCHAIN}")
249 elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
250 set(LIBCXXABI_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
252 if(LIBCXXABI_SYSROOT)
253 add_target_flags("--sysroot=${LIBCXXABI_SYSROOT}")
254 elseif(CMAKE_SYSROOT)
255 set(LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}")
258 if (LIBCXXABI_TARGET_TRIPLE)
259 set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}")
262 # Configure compiler. Must happen after setting the target flags.
265 if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
266 list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
267 # cmake 3.14 and above remove system include paths that are explicitly
268 # passed on the command line. We build with -nostdinc++ and explicitly add
269 # just the libcxx system include paths with -I on the command line.
270 # Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effectively prevents cmake
271 # from removing these.
272 # See: https://gitlab.kitware.com/cmake/cmake/issues/19227
273 set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
274 # Remove -stdlib flags to prevent them from causing an unused flag warning.
275 string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
276 string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
277 string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
278 string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
281 # Let the library headers know they are currently being used to build the
283 add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY)
285 # Disable DLL annotations on Windows for static builds.
286 if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED)
287 add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS)
290 add_compile_flags_if_supported(-Werror=return-type)
293 add_compile_flags_if_supported(-W)
294 add_compile_flags_if_supported(-Wall)
295 add_compile_flags_if_supported(-Wchar-subscripts)
296 add_compile_flags_if_supported(-Wconversion)
297 add_compile_flags_if_supported(-Wmismatched-tags)
298 add_compile_flags_if_supported(-Wmissing-braces)
299 add_compile_flags_if_supported(-Wnewline-eof)
300 add_compile_flags_if_supported(-Wunused-function)
301 add_compile_flags_if_supported(-Wshadow)
302 add_compile_flags_if_supported(-Wshorten-64-to-32)
303 add_compile_flags_if_supported(-Wsign-compare)
304 add_compile_flags_if_supported(-Wsign-conversion)
305 add_compile_flags_if_supported(-Wstrict-aliasing=2)
306 add_compile_flags_if_supported(-Wstrict-overflow=4)
307 add_compile_flags_if_supported(-Wunused-parameter)
308 add_compile_flags_if_supported(-Wunused-variable)
309 add_compile_flags_if_supported(-Wwrite-strings)
310 add_compile_flags_if_supported(-Wundef)
312 add_compile_flags_if_supported(-Wno-suggest-override)
314 if (LIBCXXABI_ENABLE_WERROR)
315 add_compile_flags_if_supported(-Werror)
316 add_compile_flags_if_supported(-WX)
318 add_compile_flags_if_supported(-Wno-error)
319 add_compile_flags_if_supported(-WX-)
321 if (LIBCXXABI_ENABLE_PEDANTIC)
322 add_compile_flags_if_supported(-pedantic)
326 add_compile_flags_if_supported(-fstrict-aliasing)
329 if (LIBCXXABI_ENABLE_EXCEPTIONS)
330 # Catches C++ exceptions only and tells the compiler to assume that extern C
331 # functions never throw a C++ exception.
332 add_compile_flags_if_supported(-EHsc)
333 # Do we really need to be run through the C compiler ?
334 add_c_compile_flags_if_supported(-funwind-tables)
336 add_compile_flags_if_supported(-fno-exceptions)
337 add_compile_flags_if_supported(-EHs-)
338 add_compile_flags_if_supported(-EHa-)
342 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
343 if (LIBCXXABI_ENABLE_ASSERTIONS)
344 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
346 list(APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG)
348 # On Release builds cmake automatically defines NDEBUG, so we
349 # explicitly undefine it:
350 if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
351 list(APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG)
354 if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
355 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
360 if (NOT LIBCXXABI_ENABLE_THREADS)
361 if (LIBCXXABI_HAS_PTHREAD_API)
362 message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
363 " be set to ON when LIBCXXABI_ENABLE_THREADS"
364 " is also set to ON.")
366 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
367 message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only"
368 " be set to ON when LIBCXXABI_ENABLE_THREADS"
369 " is also set to ON.")
371 if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
372 message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only"
373 " be set to ON when LIBCXXABI_ENABLE_THREADS"
374 " is also set to ON.")
376 add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
377 add_definitions(-D_LIBCPP_HAS_NO_THREADS)
380 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
381 if (LIBCXXABI_HAS_PTHREAD_API)
382 message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
383 " and LIBCXXABI_HAS_PTHREAD_API cannot be both"
384 " set to ON at the same time.")
386 if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
387 message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY"
388 " and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both"
389 " set to ON at the same time.")
393 if (LLVM_ENABLE_MODULES)
394 # Ignore that the rest of the modules flags are now unused.
395 add_compile_flags_if_supported(-Wno-unused-command-line-argument)
396 add_compile_flags(-fno-modules)
399 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
400 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
401 OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)
403 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
406 if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS)
407 # Need to allow unresolved symbols if this is to work with shared library builds
409 list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup")
411 # Relax this restriction from HandleLLVMOptions
412 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
416 if (LIBCXXABI_HAS_PTHREAD_API)
417 add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
420 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
421 add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL)
424 if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
425 add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
428 # Prevent libc++abi from having library dependencies on libc++
429 add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE)
431 # Bring back `std::unexpected`, which is removed in C++17, to support
433 add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
436 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
439 # Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation.
440 if (LIBCXXABI_USE_LLVM_UNWINDER)
441 add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER)
444 if (LIBCXXABI_SILENT_TERMINATE)
445 add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
448 if (LIBCXXABI_BAREMETAL)
449 add_definitions(-DLIBCXXABI_BAREMETAL)
452 if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
453 if (LIBCXXABI_HAS_PTHREAD_LIB)
454 add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
458 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
459 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
460 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
462 #===============================================================================
464 #===============================================================================
466 set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
467 "Specify path to libunwind includes." FORCE)
468 set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
469 "Specify path to libunwind source." FORCE)
471 include_directories(include)
472 if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
473 find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
474 PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
475 ${LIBCXXABI_LIBUNWIND_PATH}/include
476 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
477 ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
478 ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
479 ${LLVM_MAIN_SRC_DIR}/../libunwind/include
481 NO_CMAKE_FIND_ROOT_PATH
484 if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
485 set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
488 if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
489 include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
493 # Add source code. This also contains all of the logic for deciding linker flags
495 add_subdirectory(src)
497 if (LIBCXXABI_INCLUDE_TESTS)
498 add_subdirectory(test)
499 add_subdirectory(fuzz)