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