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