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