[RISCV] Remove unnecessary call to isSupportedExtensionFeature.
[llvm-project.git] / libcxxabi / CMakeLists.txt
blobefe830bd2ad6659b9262ba7109879f6e20a51485
1 # See www/CMake.html for instructions on how to build libcxxabi with CMake.
3 #===============================================================================
4 # Setup Project
5 #===============================================================================
7 cmake_minimum_required(VERSION 3.20.0)
9 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
11 # Add path for custom modules
12 list(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   )
20 set(CMAKE_FOLDER "libc++")
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.")
27 include(GNUInstallDirs)
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  )
36 #===============================================================================
37 # Setup CMake Options
38 #===============================================================================
39 include(CMakeDependentOption)
40 include(HandleCompilerRT)
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)
47 option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
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)
54 option(LIBCXXABI_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
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)
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)
65 option(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)
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()
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)")
77 option(LIBCXXABI_INSTALL_HEADERS "Install the libc++abi headers." ON)
78 option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
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.")
83 set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE STRING "Path to install the libc++abi headers at.")
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()
91 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
92 set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
93 "Version of libc++abi. This will be reflected in the name of the shared \
94 library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \
95 result in the library being named libc++abi.x.y.dylib, along with the \
96 usual symlinks pointing to that.")
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.
102 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
103 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
105 cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
106   "Install the static libc++abi library." ON
107   "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
108 cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
109   "Install the shared libc++abi library." ON
110   "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
112 cmake_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)
115 cmake_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)
119 option(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.
122 option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF)
123 option(LIBCXXABI_NON_DEMANGLING_TERMINATE "Set this to make the terminate handler
124 avoid demangling" OFF)
126 if (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.")
128 endif()
130 # TODO: Remove this, which shouldn't be necessary since we know we're being built
131 #       side-by-side with libc++.
132 set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
133     "Specify path to libc++ includes.")
135 set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF)
136 if (WIN32)
137   set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON)
138 endif()
139 option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
140   "Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
142 if(MINGW)
143   set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
144 elseif(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()
150 else()
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()
156 endif()
157 set(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'.")
160 if (NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}")
161   set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXXABI_TEST_CONFIG}")
162 endif()
163 message(STATUS "Using libc++abi testing configuration: ${LIBCXXABI_TEST_CONFIG}")
164 set(LIBCXXABI_TEST_PARAMS "" CACHE STRING
165     "A list of parameters to run the Lit test suite with.")
167 #===============================================================================
168 # Configure System
169 #===============================================================================
171 # Add path for custom modules
172 set(CMAKE_MODULE_PATH
173   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
174   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
175   ${CMAKE_MODULE_PATH}
176   )
178 set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
179     "Path where built libc++abi runtime libraries should be installed.")
181 if(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()
190 else()
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.")
200 endif()
202 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
203 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
204 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
206 # By default, libcxx and libcxxabi share a library directory.
207 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
208   set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
209       "The path to libc++ library." FORCE)
210 endif()
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.
220 set(LIBCXXABI_C_FLAGS "")
221 set(LIBCXXABI_CXX_FLAGS "")
222 set(LIBCXXABI_COMPILE_FLAGS "")
223 set(LIBCXXABI_LINK_FLAGS "")
224 set(LIBCXXABI_LIBRARIES "")
225 set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING
226     "Additional Compile only flags which can be provided in cache")
227 set(LIBCXXABI_ADDITIONAL_LIBRARIES "" CACHE STRING
228     "Additional libraries libc++abi is linked to which can be provided in cache")
230 # Include macros for adding and removing libc++abi flags.
231 include(HandleLibcxxabiFlags)
233 #===============================================================================
234 # Setup Compiler Flags
235 #===============================================================================
237 # Configure target flags
238 if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
239   add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
240   set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)
241 endif()
242 add_compile_flags("${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}")
243 add_library_flags("${LIBCXXABI_ADDITIONAL_LIBRARIES}")
245 # Configure compiler. Must happen after setting the target flags.
246 include(config-ix)
248 if (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}")
262 endif()
264 # Let the library headers know they are currently being used to build the
265 # library.
266 add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY)
268 # libcxxabi needs to, for various reasons, include the libcpp headers as if
269 # it is being built as part of libcxx.
270 add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
272 # Get feature flags.
273 add_compile_flags_if_supported(-fstrict-aliasing)
275 # Exceptions
276 if (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)
282 else()
283   add_compile_flags_if_supported(-fno-exceptions)
284   add_compile_flags_if_supported(-EHs-)
285   add_compile_flags_if_supported(-EHa-)
286 endif()
288 # Assert
289 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
290 if (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()
300 else()
301   if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
302     list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
303   endif()
304 endif()
306 # Threading
307 if (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)
324 endif()
326 if (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()
337 endif()
339 if (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()
345 endif()
347 if (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)
351 endif()
353 set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
354 if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) OR MINGW)
355   set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
356 endif()
358 if (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()
366 endif()
368 if (LIBCXXABI_HAS_PTHREAD_API)
369   add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
370 endif()
372 if (LIBCXXABI_HAS_WIN32_THREAD_API)
373   add_definitions(-D_LIBCPP_HAS_THREAD_API_WIN32)
374 endif()
376 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
377   add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL)
378 endif()
380 if (MSVC)
381   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
382 endif()
384 if (LIBCXXABI_SILENT_TERMINATE)
385   add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
386 endif()
388 if (LIBCXXABI_NON_DEMANGLING_TERMINATE)
389   add_definitions(-DLIBCXXABI_NON_DEMANGLING_TERMINATE)
390 endif()
392 if (LIBCXXABI_BAREMETAL)
393     add_definitions(-DLIBCXXABI_BAREMETAL)
394 endif()
396 if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
397   if (LIBCXXABI_HAS_PTHREAD_LIB)
398     add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
399   endif()
400 endif()
402 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
403 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
404 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
406 # On AIX, avoid picking up VMX extensions(i.e. vec_malloc) which would change
407 # the default alignment of the allocators here.
408 if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
409   add_definitions("-D_XOPEN_SOURCE=700")
410 endif()
412 #===============================================================================
413 # Setup Source Code
414 #===============================================================================
416 set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
417     "Specify path to libunwind includes." FORCE)
418 set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
419     "Specify path to libunwind source." FORCE)
421 if (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   )
433   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
434     set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
435   endif()
436 endif()
438 if (NOT "${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}" STREQUAL "")
439   include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
440 endif()
442 # Add source code. This also contains all of the logic for deciding linker flags
443 # soname, etc...
444 add_subdirectory(include)
445 add_subdirectory(src)
447 if (LIBCXXABI_INCLUDE_TESTS)
448   add_subdirectory(test)
449   add_subdirectory(fuzz)
450 endif()