1*c05d8e5dSAndroid Build Coastguard Worker# See www/CMake.html for instructions on how to build libcxxabi with CMake. 2*c05d8e5dSAndroid Build Coastguard Worker 3*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 4*c05d8e5dSAndroid Build Coastguard Worker# Setup Project 5*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 6*c05d8e5dSAndroid Build Coastguard Worker 7*c05d8e5dSAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.4.3) 8*c05d8e5dSAndroid Build Coastguard Worker 9*c05d8e5dSAndroid Build Coastguard Workerif(POLICY CMP0042) 10*c05d8e5dSAndroid Build Coastguard Worker cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default 11*c05d8e5dSAndroid Build Coastguard Workerendif() 12*c05d8e5dSAndroid Build Coastguard Worker 13*c05d8e5dSAndroid Build Coastguard Worker# Add path for custom modules 14*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_MODULE_PATH 15*c05d8e5dSAndroid Build Coastguard Worker "${CMAKE_CURRENT_SOURCE_DIR}/cmake" 16*c05d8e5dSAndroid Build Coastguard Worker "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" 17*c05d8e5dSAndroid Build Coastguard Worker ${CMAKE_MODULE_PATH} 18*c05d8e5dSAndroid Build Coastguard Worker ) 19*c05d8e5dSAndroid Build Coastguard Worker 20*c05d8e5dSAndroid Build Coastguard Workerif (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 21*c05d8e5dSAndroid Build Coastguard Worker project(libcxxabi CXX C) 22*c05d8e5dSAndroid Build Coastguard Worker 23*c05d8e5dSAndroid Build Coastguard Worker set(PACKAGE_NAME libcxxabi) 24*c05d8e5dSAndroid Build Coastguard Worker set(PACKAGE_VERSION 8.0.0svn) 25*c05d8e5dSAndroid Build Coastguard Worker set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") 26*c05d8e5dSAndroid Build Coastguard Worker set(PACKAGE_BUGREPORT "[email protected]") 27*c05d8e5dSAndroid Build Coastguard Worker 28*c05d8e5dSAndroid Build Coastguard Worker # Find the LLVM sources and simulate LLVM CMake options. 29*c05d8e5dSAndroid Build Coastguard Worker include(HandleOutOfTreeLLVM) 30*c05d8e5dSAndroid Build Coastguard Workerendif() 31*c05d8e5dSAndroid Build Coastguard Worker 32*c05d8e5dSAndroid Build Coastguard Worker# Require out of source build. 33*c05d8e5dSAndroid Build Coastguard Workerinclude(MacroEnsureOutOfSourceBuild) 34*c05d8e5dSAndroid Build Coastguard WorkerMACRO_ENSURE_OUT_OF_SOURCE_BUILD( 35*c05d8e5dSAndroid Build Coastguard Worker "${PROJECT_NAME} requires an out of source build. Please create a separate 36*c05d8e5dSAndroid Build Coastguard Worker build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." 37*c05d8e5dSAndroid Build Coastguard Worker ) 38*c05d8e5dSAndroid Build Coastguard Worker 39*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 40*c05d8e5dSAndroid Build Coastguard Worker# Setup CMake Options 41*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 42*c05d8e5dSAndroid Build Coastguard Workerinclude(CMakeDependentOption) 43*c05d8e5dSAndroid Build Coastguard Workerinclude(HandleCompilerRT) 44*c05d8e5dSAndroid Build Coastguard Worker 45*c05d8e5dSAndroid Build Coastguard Worker# Define options. 46*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON) 47*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) 48*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) 49*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) 50*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) 51*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) 52*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) 53*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON) 54*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) 55*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_HAS_EXTERNAL_THREAD_API 56*c05d8e5dSAndroid Build Coastguard Worker "Build libc++abi with an externalized threading API. 57*c05d8e5dSAndroid Build Coastguard Worker This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF) 58*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY 59*c05d8e5dSAndroid Build Coastguard Worker "Build libc++abi with an externalized threading library. 60*c05d8e5dSAndroid Build Coastguard Worker This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF) 61*c05d8e5dSAndroid Build Coastguard Worker 62*c05d8e5dSAndroid Build Coastguard Worker# FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link 63*c05d8e5dSAndroid Build Coastguard Worker# programs to due undefined references to new/delete in libc++abi. Once this 64*c05d8e5dSAndroid Build Coastguard Worker# has been fixed or worked around the default value should be changed. 65*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS 66*c05d8e5dSAndroid Build Coastguard Worker "Build libc++abi with definitions for operator new/delete. Normally libc++ 67*c05d8e5dSAndroid Build Coastguard Worker provides these definitions" ON) 68*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS}) 69*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS}) 70*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING 71*c05d8e5dSAndroid Build Coastguard Worker "Define suffix of library directory name (32/64)") 72*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON) 73*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") 74*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") 75*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") 76*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") 77*c05d8e5dSAndroid Build Coastguard Worker 78*c05d8e5dSAndroid Build Coastguard Worker# Default to building a shared library so that the default options still test 79*c05d8e5dSAndroid Build Coastguard Worker# the libc++abi that is being built. There are two problems with testing a 80*c05d8e5dSAndroid Build Coastguard Worker# static libc++abi. In the case of a standalone build, the tests will link the 81*c05d8e5dSAndroid Build Coastguard Worker# system's libc++, which might not have been built against our libc++abi. In the 82*c05d8e5dSAndroid Build Coastguard Worker# case of an in tree build, libc++ will prefer a dynamic libc++abi from the 83*c05d8e5dSAndroid Build Coastguard Worker# system over a static libc++abi from the output directory. 84*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON) 85*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON) 86*c05d8e5dSAndroid Build Coastguard Worker 87*c05d8e5dSAndroid Build Coastguard Workercmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY 88*c05d8e5dSAndroid Build Coastguard Worker "Install the static libc++abi library." ON 89*c05d8e5dSAndroid Build Coastguard Worker "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF) 90*c05d8e5dSAndroid Build Coastguard Workercmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY 91*c05d8e5dSAndroid Build Coastguard Worker "Install the shared libc++abi library." ON 92*c05d8e5dSAndroid Build Coastguard Worker "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF) 93*c05d8e5dSAndroid Build Coastguard Worker 94*c05d8e5dSAndroid Build Coastguard Workercmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY 95*c05d8e5dSAndroid Build Coastguard Worker "Statically link the LLVM unwinder to static library" ON 96*c05d8e5dSAndroid Build Coastguard Worker "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF) 97*c05d8e5dSAndroid Build Coastguard Workercmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY 98*c05d8e5dSAndroid Build Coastguard Worker "Statically link the LLVM unwinder to shared library" ON 99*c05d8e5dSAndroid Build Coastguard Worker "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF) 100*c05d8e5dSAndroid Build Coastguard Worker 101*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) 102*c05d8e5dSAndroid Build Coastguard Worker# The default terminate handler attempts to demangle uncaught exceptions, which 103*c05d8e5dSAndroid Build Coastguard Worker# causes extra I/O and demangling code to be pulled in. 104*c05d8e5dSAndroid Build Coastguard Workeroption(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF) 105*c05d8e5dSAndroid Build Coastguard Worker 106*c05d8e5dSAndroid Build Coastguard Workerif (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC) 107*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "libc++abi must be built as either a shared or static library.") 108*c05d8e5dSAndroid Build Coastguard Workerendif() 109*c05d8e5dSAndroid Build Coastguard Worker 110*c05d8e5dSAndroid Build Coastguard Workerif (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR) 111*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBCXX_SRC_DIRS ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}) 112*c05d8e5dSAndroid Build Coastguard Workerelse() 113*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBCXX_SRC_DIRS 114*c05d8e5dSAndroid Build Coastguard Worker "${LLVM_MAIN_SRC_DIR}/projects/libcxx" 115*c05d8e5dSAndroid Build Coastguard Worker "${LLVM_MAIN_SRC_DIR}/runtimes/libcxx" 116*c05d8e5dSAndroid Build Coastguard Worker "${LLVM_MAIN_SRC_DIR}/../libcxx" 117*c05d8e5dSAndroid Build Coastguard Worker ) 118*c05d8e5dSAndroid Build Coastguard Workerendif() 119*c05d8e5dSAndroid Build Coastguard Worker 120*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBCXX_INCLUDE_DIRS "") 121*c05d8e5dSAndroid Build Coastguard Workerforeach(dir ${LIBCXXABI_LIBCXX_SRC_DIRS}) 122*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_LIBCXX_INCLUDE_DIRS "${dir}/include") 123*c05d8e5dSAndroid Build Coastguard Workerendforeach() 124*c05d8e5dSAndroid Build Coastguard Worker 125*c05d8e5dSAndroid Build Coastguard Workerfind_path( 126*c05d8e5dSAndroid Build Coastguard Worker LIBCXXABI_LIBCXX_INCLUDES 127*c05d8e5dSAndroid Build Coastguard Worker __config 128*c05d8e5dSAndroid Build Coastguard Worker PATHS ${LIBCXXABI_LIBCXX_INCLUDES} 129*c05d8e5dSAndroid Build Coastguard Worker ${LIBCXXABI_LIBCXX_PATH}/include 130*c05d8e5dSAndroid Build Coastguard Worker ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES} 131*c05d8e5dSAndroid Build Coastguard Worker ${LIBCXXABI_LIBCXX_INCLUDE_DIRS} 132*c05d8e5dSAndroid Build Coastguard Worker ${LLVM_INCLUDE_DIR}/c++/v1 133*c05d8e5dSAndroid Build Coastguard Worker NO_DEFAULT_PATH 134*c05d8e5dSAndroid Build Coastguard Worker NO_CMAKE_FIND_ROOT_PATH 135*c05d8e5dSAndroid Build Coastguard Worker ) 136*c05d8e5dSAndroid Build Coastguard Worker 137*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH 138*c05d8e5dSAndroid Build Coastguard Worker "Specify path to libc++ includes." FORCE) 139*c05d8e5dSAndroid Build Coastguard Worker 140*c05d8e5dSAndroid Build Coastguard Workerfind_path( 141*c05d8e5dSAndroid Build Coastguard Worker LIBCXXABI_LIBCXX_PATH 142*c05d8e5dSAndroid Build Coastguard Worker utils/libcxx/test/__init__.py 143*c05d8e5dSAndroid Build Coastguard Worker PATHS ${LIBCXXABI_LIBCXX_PATH} 144*c05d8e5dSAndroid Build Coastguard Worker ${LIBCXXABI_LIBCXX_INCLUDES}/../ 145*c05d8e5dSAndroid Build Coastguard Worker ${LIBCXXABI_LIBCXX_SRC_DIRS} 146*c05d8e5dSAndroid Build Coastguard Worker NO_DEFAULT_PATH 147*c05d8e5dSAndroid Build Coastguard Worker NO_CMAKE_FIND_ROOT_PATH 148*c05d8e5dSAndroid Build Coastguard Worker ) 149*c05d8e5dSAndroid Build Coastguard Worker 150*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND") 151*c05d8e5dSAndroid Build Coastguard Worker message(WARNING "LIBCXXABI_LIBCXX_PATH was not specified and couldn't be infered.") 152*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBCXX_PATH "") 153*c05d8e5dSAndroid Build Coastguard Workerendif() 154*c05d8e5dSAndroid Build Coastguard Worker 155*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_LIBCXX_PATH}" CACHE PATH 156*c05d8e5dSAndroid Build Coastguard Worker "Specify path to libc++ source." FORCE) 157*c05d8e5dSAndroid Build Coastguard Worker 158*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 159*c05d8e5dSAndroid Build Coastguard Worker# Configure System 160*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 161*c05d8e5dSAndroid Build Coastguard Worker 162*c05d8e5dSAndroid Build Coastguard Worker# Add path for custom modules 163*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_MODULE_PATH 164*c05d8e5dSAndroid Build Coastguard Worker "${CMAKE_CURRENT_SOURCE_DIR}/cmake" 165*c05d8e5dSAndroid Build Coastguard Worker "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" 166*c05d8e5dSAndroid Build Coastguard Worker ${CMAKE_MODULE_PATH} 167*c05d8e5dSAndroid Build Coastguard Worker ) 168*c05d8e5dSAndroid Build Coastguard Worker 169*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER}) 170*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 171*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) 172*c05d8e5dSAndroid Build Coastguard Worker 173*c05d8e5dSAndroid Build Coastguard Workerstring(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION 174*c05d8e5dSAndroid Build Coastguard Worker ${PACKAGE_VERSION}) 175*c05d8e5dSAndroid Build Coastguard Worker 176*c05d8e5dSAndroid Build Coastguard Workerif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 177*c05d8e5dSAndroid Build Coastguard Worker set(DEFAULT_INSTALL_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/) 178*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXXABI_LIBDIR_SUFFIX}) 179*c05d8e5dSAndroid Build Coastguard Workerelseif(LLVM_LIBRARY_OUTPUT_INTDIR) 180*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 181*c05d8e5dSAndroid Build Coastguard Workerelse() 182*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) 183*c05d8e5dSAndroid Build Coastguard Workerendif() 184*c05d8e5dSAndroid Build Coastguard Worker 185*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_INSTALL_PREFIX ${DEFAULT_INSTALL_PREFIX} CACHE STRING 186*c05d8e5dSAndroid Build Coastguard Worker "Define libc++abi destination prefix.") 187*c05d8e5dSAndroid Build Coastguard Worker 188*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) 189*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) 190*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) 191*c05d8e5dSAndroid Build Coastguard Worker 192*c05d8e5dSAndroid Build Coastguard Worker# By default, for non-standalone builds, libcxx and libcxxabi share a library 193*c05d8e5dSAndroid Build Coastguard Worker# directory. 194*c05d8e5dSAndroid Build Coastguard Workerif (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) 195*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH 196*c05d8e5dSAndroid Build Coastguard Worker "The path to libc++ library.") 197*c05d8e5dSAndroid Build Coastguard Workerendif() 198*c05d8e5dSAndroid Build Coastguard Worker 199*c05d8e5dSAndroid Build Coastguard Worker# Check that we can build with 32 bits if requested. 200*c05d8e5dSAndroid Build Coastguard Workerif (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) 201*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM 202*c05d8e5dSAndroid Build Coastguard Worker message(STATUS "Building 32 bits executables and libraries.") 203*c05d8e5dSAndroid Build Coastguard Worker endif() 204*c05d8e5dSAndroid Build Coastguard Workerelseif(LIBCXXABI_BUILD_32_BITS) 205*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS=ON is not supported on this platform.") 206*c05d8e5dSAndroid Build Coastguard Workerendif() 207*c05d8e5dSAndroid Build Coastguard Worker 208*c05d8e5dSAndroid Build Coastguard Worker# Declare libc++abi configuration variables. 209*c05d8e5dSAndroid Build Coastguard Worker# They are intended for use as follows: 210*c05d8e5dSAndroid Build Coastguard Worker# LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker. 211*c05d8e5dSAndroid Build Coastguard Worker# LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker. 212*c05d8e5dSAndroid Build Coastguard Worker# LIBCXXABI_COMPILE_FLAGS: Compile only flags. 213*c05d8e5dSAndroid Build Coastguard Worker# LIBCXXABI_LINK_FLAGS: Linker only flags. 214*c05d8e5dSAndroid Build Coastguard Worker# LIBCXXABI_LIBRARIES: libraries libc++abi is linked to. 215*c05d8e5dSAndroid Build Coastguard Worker 216*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_C_FLAGS "") 217*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_CXX_FLAGS "") 218*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_COMPILE_FLAGS "") 219*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LINK_FLAGS "") 220*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBRARIES "") 221*c05d8e5dSAndroid Build Coastguard Worker 222*c05d8e5dSAndroid Build Coastguard Worker# Include macros for adding and removing libc++abi flags. 223*c05d8e5dSAndroid Build Coastguard Workerinclude(HandleLibcxxabiFlags) 224*c05d8e5dSAndroid Build Coastguard Worker 225*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 226*c05d8e5dSAndroid Build Coastguard Worker# Setup Compiler Flags 227*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 228*c05d8e5dSAndroid Build Coastguard Worker 229*c05d8e5dSAndroid Build Coastguard Worker# Configure target flags 230*c05d8e5dSAndroid Build Coastguard Workeradd_target_flags_if(LIBCXXABI_BUILD_32_BITS "-m32") 231*c05d8e5dSAndroid Build Coastguard Workeradd_target_flags_if(LIBCXXABI_TARGET_TRIPLE 232*c05d8e5dSAndroid Build Coastguard Worker "--target=${LIBCXXABI_TARGET_TRIPLE}") 233*c05d8e5dSAndroid Build Coastguard Workeradd_target_flags_if(LIBCXXABI_GCC_TOOLCHAIN 234*c05d8e5dSAndroid Build Coastguard Worker "--gcc-toolchain=${LIBCXXABI_GCC_TOOLCHAIN}") 235*c05d8e5dSAndroid Build Coastguard Workeradd_target_flags_if(LIBCXXABI_SYSROOT 236*c05d8e5dSAndroid Build Coastguard Worker "--sysroot=${LIBCXXABI_SYSROOT}") 237*c05d8e5dSAndroid Build Coastguard Worker 238*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_TARGET_TRIPLE) 239*c05d8e5dSAndroid Build Coastguard Worker set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}") 240*c05d8e5dSAndroid Build Coastguard Workerendif() 241*c05d8e5dSAndroid Build Coastguard Worker 242*c05d8e5dSAndroid Build Coastguard Worker# Configure compiler. Must happen after setting the target flags. 243*c05d8e5dSAndroid Build Coastguard Workerinclude(config-ix) 244*c05d8e5dSAndroid Build Coastguard Worker 245*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_HAS_NOSTDINCXX_FLAG) 246*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++) 247*c05d8e5dSAndroid Build Coastguard Worker # Remove -stdlib flags to prevent them from causing an unused flag warning. 248*c05d8e5dSAndroid Build Coastguard Worker string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 249*c05d8e5dSAndroid Build Coastguard Worker string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 250*c05d8e5dSAndroid Build Coastguard Workerendif() 251*c05d8e5dSAndroid Build Coastguard Worker 252*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_USE_COMPILER_RT) 253*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt") 254*c05d8e5dSAndroid Build Coastguard Workerendif() 255*c05d8e5dSAndroid Build Coastguard Worker 256*c05d8e5dSAndroid Build Coastguard Worker# Let the library headers know they are currently being used to build the 257*c05d8e5dSAndroid Build Coastguard Worker# library. 258*c05d8e5dSAndroid Build Coastguard Workeradd_definitions(-D_LIBCXXABI_BUILDING_LIBRARY) 259*c05d8e5dSAndroid Build Coastguard Worker 260*c05d8e5dSAndroid Build Coastguard Worker# Disable DLL annotations on Windows for static builds. 261*c05d8e5dSAndroid Build Coastguard Workerif (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED) 262*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) 263*c05d8e5dSAndroid Build Coastguard Workerendif() 264*c05d8e5dSAndroid Build Coastguard Worker 265*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Werror=return-type) 266*c05d8e5dSAndroid Build Coastguard Worker 267*c05d8e5dSAndroid Build Coastguard Worker# Get warning flags 268*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-W) 269*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wall) 270*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wchar-subscripts) 271*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wconversion) 272*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wmismatched-tags) 273*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wmissing-braces) 274*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wnewline-eof) 275*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wunused-function) 276*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wshadow) 277*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wshorten-64-to-32) 278*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wsign-compare) 279*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wsign-conversion) 280*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wstrict-aliasing=2) 281*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wstrict-overflow=4) 282*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wunused-parameter) 283*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wunused-variable) 284*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wwrite-strings) 285*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-Wundef) 286*c05d8e5dSAndroid Build Coastguard Worker 287*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_ENABLE_WERROR) 288*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-Werror) 289*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-WX) 290*c05d8e5dSAndroid Build Coastguard Workerelse() 291*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-Wno-error) 292*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-WX-) 293*c05d8e5dSAndroid Build Coastguard Workerendif() 294*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_ENABLE_PEDANTIC) 295*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-pedantic) 296*c05d8e5dSAndroid Build Coastguard Workerendif() 297*c05d8e5dSAndroid Build Coastguard Worker 298*c05d8e5dSAndroid Build Coastguard Worker# Get feature flags. 299*c05d8e5dSAndroid Build Coastguard Workeradd_compile_flags_if_supported(-fstrict-aliasing) 300*c05d8e5dSAndroid Build Coastguard Worker 301*c05d8e5dSAndroid Build Coastguard Worker# Exceptions 302*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_ENABLE_EXCEPTIONS) 303*c05d8e5dSAndroid Build Coastguard Worker # Catches C++ exceptions only and tells the compiler to assume that extern C 304*c05d8e5dSAndroid Build Coastguard Worker # functions never throw a C++ exception. 305*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-EHsc) 306*c05d8e5dSAndroid Build Coastguard Worker # Do we really need to be run through the C compiler ? 307*c05d8e5dSAndroid Build Coastguard Worker add_c_compile_flags_if_supported(-funwind-tables) 308*c05d8e5dSAndroid Build Coastguard Workerelse() 309*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCXXABI_NO_EXCEPTIONS) 310*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-fno-exceptions) 311*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-EHs-) 312*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-EHa-) 313*c05d8e5dSAndroid Build Coastguard Workerendif() 314*c05d8e5dSAndroid Build Coastguard Worker 315*c05d8e5dSAndroid Build Coastguard Worker# Assert 316*c05d8e5dSAndroid Build Coastguard Workerstring(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) 317*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_ENABLE_ASSERTIONS) 318*c05d8e5dSAndroid Build Coastguard Worker # MSVC doesn't like _DEBUG on release builds. See PR 4379. 319*c05d8e5dSAndroid Build Coastguard Worker if (NOT MSVC) 320*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG) 321*c05d8e5dSAndroid Build Coastguard Worker endif() 322*c05d8e5dSAndroid Build Coastguard Worker # On Release builds cmake automatically defines NDEBUG, so we 323*c05d8e5dSAndroid Build Coastguard Worker # explicitly undefine it: 324*c05d8e5dSAndroid Build Coastguard Worker if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") 325*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG) 326*c05d8e5dSAndroid Build Coastguard Worker endif() 327*c05d8e5dSAndroid Build Coastguard Workerelse() 328*c05d8e5dSAndroid Build Coastguard Worker if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") 329*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG) 330*c05d8e5dSAndroid Build Coastguard Worker endif() 331*c05d8e5dSAndroid Build Coastguard Workerendif() 332*c05d8e5dSAndroid Build Coastguard Worker# Static library 333*c05d8e5dSAndroid Build Coastguard Workerif (NOT LIBCXXABI_ENABLE_SHARED) 334*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC) 335*c05d8e5dSAndroid Build Coastguard Workerendif() 336*c05d8e5dSAndroid Build Coastguard Worker 337*c05d8e5dSAndroid Build Coastguard Worker# Threading 338*c05d8e5dSAndroid Build Coastguard Workerif (NOT LIBCXXABI_ENABLE_THREADS) 339*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_HAS_PTHREAD_API) 340*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only" 341*c05d8e5dSAndroid Build Coastguard Worker " be set to ON when LIBCXXABI_ENABLE_THREADS" 342*c05d8e5dSAndroid Build Coastguard Worker " is also set to ON.") 343*c05d8e5dSAndroid Build Coastguard Worker endif() 344*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) 345*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only" 346*c05d8e5dSAndroid Build Coastguard Worker " be set to ON when LIBCXXABI_ENABLE_THREADS" 347*c05d8e5dSAndroid Build Coastguard Worker " is also set to ON.") 348*c05d8e5dSAndroid Build Coastguard Worker endif() 349*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) 350*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only" 351*c05d8e5dSAndroid Build Coastguard Worker " be set to ON when LIBCXXABI_ENABLE_THREADS" 352*c05d8e5dSAndroid Build Coastguard Worker " is also set to ON.") 353*c05d8e5dSAndroid Build Coastguard Worker endif() 354*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) 355*c05d8e5dSAndroid Build Coastguard Workerendif() 356*c05d8e5dSAndroid Build Coastguard Worker 357*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_HAS_EXTERNAL_THREAD_API) 358*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_HAS_PTHREAD_API) 359*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" 360*c05d8e5dSAndroid Build Coastguard Worker " and LIBCXXABI_HAS_PTHREAD_API cannot be both" 361*c05d8e5dSAndroid Build Coastguard Worker " set to ON at the same time.") 362*c05d8e5dSAndroid Build Coastguard Worker endif() 363*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) 364*c05d8e5dSAndroid Build Coastguard Worker message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY" 365*c05d8e5dSAndroid Build Coastguard Worker " and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both" 366*c05d8e5dSAndroid Build Coastguard Worker " set to ON at the same time.") 367*c05d8e5dSAndroid Build Coastguard Worker endif() 368*c05d8e5dSAndroid Build Coastguard Workerendif() 369*c05d8e5dSAndroid Build Coastguard Worker 370*c05d8e5dSAndroid Build Coastguard Workerif (LLVM_ENABLE_MODULES) 371*c05d8e5dSAndroid Build Coastguard Worker # Ignore that the rest of the modules flags are now unused. 372*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags_if_supported(-Wno-unused-command-line-argument) 373*c05d8e5dSAndroid Build Coastguard Worker add_compile_flags(-fno-modules) 374*c05d8e5dSAndroid Build Coastguard Workerendif() 375*c05d8e5dSAndroid Build Coastguard Worker 376*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF) 377*c05d8e5dSAndroid Build Coastguard Workerif ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) 378*c05d8e5dSAndroid Build Coastguard Worker OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED) 379*c05d8e5dSAndroid Build Coastguard Worker OR MINGW) 380*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON) 381*c05d8e5dSAndroid Build Coastguard Workerendif() 382*c05d8e5dSAndroid Build Coastguard Worker 383*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_HAS_UNDEFINED_SYMBOLS) 384*c05d8e5dSAndroid Build Coastguard Worker # Need to allow unresolved symbols if this is to work with shared library builds 385*c05d8e5dSAndroid Build Coastguard Worker if (APPLE) 386*c05d8e5dSAndroid Build Coastguard Worker list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup") 387*c05d8e5dSAndroid Build Coastguard Worker else() 388*c05d8e5dSAndroid Build Coastguard Worker # Relax this restriction from HandleLLVMOptions 389*c05d8e5dSAndroid Build Coastguard Worker string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 390*c05d8e5dSAndroid Build Coastguard Worker endif() 391*c05d8e5dSAndroid Build Coastguard Workerendif() 392*c05d8e5dSAndroid Build Coastguard Worker 393*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_HAS_PTHREAD_API) 394*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD) 395*c05d8e5dSAndroid Build Coastguard Workerendif() 396*c05d8e5dSAndroid Build Coastguard Worker 397*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_HAS_EXTERNAL_THREAD_API) 398*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL) 399*c05d8e5dSAndroid Build Coastguard Workerendif() 400*c05d8e5dSAndroid Build Coastguard Worker 401*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) 402*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) 403*c05d8e5dSAndroid Build Coastguard Workerendif() 404*c05d8e5dSAndroid Build Coastguard Worker 405*c05d8e5dSAndroid Build Coastguard Worker# Prevent libc++abi from having library dependencies on libc++ 406*c05d8e5dSAndroid Build Coastguard Workeradd_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE) 407*c05d8e5dSAndroid Build Coastguard Worker 408*c05d8e5dSAndroid Build Coastguard Worker# Bring back `std::unexpected`, which is removed in C++17, to support 409*c05d8e5dSAndroid Build Coastguard Worker# pre-C++17. 410*c05d8e5dSAndroid Build Coastguard Workeradd_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) 411*c05d8e5dSAndroid Build Coastguard Worker 412*c05d8e5dSAndroid Build Coastguard Workerif (MSVC) 413*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-D_CRT_SECURE_NO_WARNINGS) 414*c05d8e5dSAndroid Build Coastguard Workerendif() 415*c05d8e5dSAndroid Build Coastguard Worker 416*c05d8e5dSAndroid Build Coastguard Worker# Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation. 417*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_USE_LLVM_UNWINDER) 418*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER) 419*c05d8e5dSAndroid Build Coastguard Workerendif() 420*c05d8e5dSAndroid Build Coastguard Worker 421*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_SILENT_TERMINATE) 422*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-DLIBCXXABI_SILENT_TERMINATE) 423*c05d8e5dSAndroid Build Coastguard Workerendif() 424*c05d8e5dSAndroid Build Coastguard Worker 425*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_BAREMETAL) 426*c05d8e5dSAndroid Build Coastguard Worker add_definitions(-DLIBCXXABI_BAREMETAL) 427*c05d8e5dSAndroid Build Coastguard Workerendif() 428*c05d8e5dSAndroid Build Coastguard Worker 429*c05d8e5dSAndroid Build Coastguard Workerstring(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}") 430*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}") 431*c05d8e5dSAndroid Build Coastguard Workerset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}") 432*c05d8e5dSAndroid Build Coastguard Worker 433*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 434*c05d8e5dSAndroid Build Coastguard Worker# Setup Source Code 435*c05d8e5dSAndroid Build Coastguard Worker#=============================================================================== 436*c05d8e5dSAndroid Build Coastguard Worker 437*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH 438*c05d8e5dSAndroid Build Coastguard Worker "Specify path to libunwind includes." FORCE) 439*c05d8e5dSAndroid Build Coastguard Workerset(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH 440*c05d8e5dSAndroid Build Coastguard Worker "Specify path to libunwind source." FORCE) 441*c05d8e5dSAndroid Build Coastguard Worker 442*c05d8e5dSAndroid Build Coastguard Workerinclude_directories(include) 443*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM) 444*c05d8e5dSAndroid Build Coastguard Worker find_path( 445*c05d8e5dSAndroid Build Coastguard Worker LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL 446*c05d8e5dSAndroid Build Coastguard Worker libunwind.h 447*c05d8e5dSAndroid Build Coastguard Worker PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES} 448*c05d8e5dSAndroid Build Coastguard Worker ${LIBCXXABI_LIBUNWIND_PATH}/include 449*c05d8e5dSAndroid Build Coastguard Worker ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES} 450*c05d8e5dSAndroid Build Coastguard Worker ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include 451*c05d8e5dSAndroid Build Coastguard Worker ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include 452*c05d8e5dSAndroid Build Coastguard Worker ${LLVM_MAIN_SRC_DIR}/../libunwind/include 453*c05d8e5dSAndroid Build Coastguard Worker NO_DEFAULT_PATH 454*c05d8e5dSAndroid Build Coastguard Worker NO_CMAKE_FIND_ROOT_PATH 455*c05d8e5dSAndroid Build Coastguard Worker ) 456*c05d8e5dSAndroid Build Coastguard Worker 457*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND") 458*c05d8e5dSAndroid Build Coastguard Worker set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "") 459*c05d8e5dSAndroid Build Coastguard Worker endif() 460*c05d8e5dSAndroid Build Coastguard Worker 461*c05d8e5dSAndroid Build Coastguard Worker if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "") 462*c05d8e5dSAndroid Build Coastguard Worker include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}") 463*c05d8e5dSAndroid Build Coastguard Worker endif() 464*c05d8e5dSAndroid Build Coastguard Workerendif() 465*c05d8e5dSAndroid Build Coastguard Worker 466*c05d8e5dSAndroid Build Coastguard Worker# Add source code. This also contains all of the logic for deciding linker flags 467*c05d8e5dSAndroid Build Coastguard Worker# soname, etc... 468*c05d8e5dSAndroid Build Coastguard Workeradd_subdirectory(src) 469*c05d8e5dSAndroid Build Coastguard Worker 470*c05d8e5dSAndroid Build Coastguard Workerif (LIBCXXABI_INCLUDE_TESTS) 471*c05d8e5dSAndroid Build Coastguard Worker if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED) 472*c05d8e5dSAndroid Build Coastguard Worker # We can't reasonably test the system C++ library with a static 473*c05d8e5dSAndroid Build Coastguard Worker # libc++abi. We either need to be able to replace libc++abi at 474*c05d8e5dSAndroid Build Coastguard Worker # run time (with a shared libc++abi), or we need to be able to 475*c05d8e5dSAndroid Build Coastguard Worker # replace the C++ runtime (with a non- standalone build). 476*c05d8e5dSAndroid Build Coastguard Worker message(WARNING "The libc++abi tests aren't valid when libc++abi " 477*c05d8e5dSAndroid Build Coastguard Worker "is built standalone (i.e. outside of " 478*c05d8e5dSAndroid Build Coastguard Worker "llvm/projects/libcxxabi ) and is built without " 479*c05d8e5dSAndroid Build Coastguard Worker "a shared library. Either build a shared " 480*c05d8e5dSAndroid Build Coastguard Worker "library, build libc++abi at the same time as " 481*c05d8e5dSAndroid Build Coastguard Worker "you build libc++, or do without testing. No " 482*c05d8e5dSAndroid Build Coastguard Worker "check target will be available!") 483*c05d8e5dSAndroid Build Coastguard Worker else() 484*c05d8e5dSAndroid Build Coastguard Worker add_subdirectory(test) 485*c05d8e5dSAndroid Build Coastguard Worker add_subdirectory(fuzz) 486*c05d8e5dSAndroid Build Coastguard Worker endif() 487*c05d8e5dSAndroid Build Coastguard Workerendif() 488