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