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