Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 1 | # See www/CMake.html for instructions on how to build libcxxabi with CMake. |
| 2 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 3 | #=============================================================================== |
| 4 | # Setup Project |
| 5 | #=============================================================================== |
| 6 | |
Louis Dionne | afa1afd | 2020-04-22 15:15:05 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.13.4) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 8 | |
John Ericson | 949bbd0 | 2022-01-01 07:03:31 | [diff] [blame] | 9 | set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") |
| 10 | |
Petr Hosek | 5f3d5be | 2017-04-07 20:10:41 | [diff] [blame] | 11 | # Add path for custom modules |
John Ericson | 949bbd0 | 2022-01-01 07:03:31 | [diff] [blame] | 12 | list(INSERT CMAKE_MODULE_PATH 0 |
Petr Hosek | 5f3d5be | 2017-04-07 20:10:41 | [diff] [blame] | 13 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 14 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
John Ericson | 949bbd0 | 2022-01-01 07:03:31 | [diff] [blame] | 15 | "${LLVM_COMMON_CMAKE_UTILS}" |
| 16 | "${LLVM_COMMON_CMAKE_UTILS}/Modules" |
Petr Hosek | 5f3d5be | 2017-04-07 20:10:41 | [diff] [blame] | 17 | ) |
| 18 | |
Marek Kurdej | 5e7a93a | 2021-01-25 08:50:03 | [diff] [blame] | 19 | set(CMAKE_FOLDER "libc++") |
| 20 | |
Dominik Montada | 8c03fdf | 2020-08-24 09:01:05 | [diff] [blame] | 21 | set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 22 | set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 23 | set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH |
| 24 | "Specify path to libc++ source.") |
| 25 | |
John Ericson | df31ff1 | 2022-01-19 06:45:07 | [diff] [blame] | 26 | include(GNUInstallDirs) |
| 27 | |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 28 | # Require out of source build. |
| 29 | include(MacroEnsureOutOfSourceBuild) |
| 30 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( |
| 31 | "${PROJECT_NAME} requires an out of source build. Please create a separate |
| 32 | build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." |
| 33 | ) |
| 34 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 35 | #=============================================================================== |
| 36 | # Setup CMake Options |
| 37 | #=============================================================================== |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 38 | include(CMakeDependentOption) |
Petr Hosek | 5f3d5be | 2017-04-07 20:10:41 | [diff] [blame] | 39 | include(HandleCompilerRT) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 40 | |
| 41 | # Define options. |
Petr Hosek | 2e398f1 | 2019-07-12 19:10:59 | [diff] [blame] | 42 | option(LIBCXXABI_ENABLE_EXCEPTIONS |
| 43 | "Provide support for exceptions in the runtime. |
| 44 | When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 45 | option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) |
| 46 | option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) |
| 47 | option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
Saleem Abdulrasool | e5f6e2b | 2015-04-28 02:09:53 | [diff] [blame] | 48 | option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) |
Petr Hosek | ef6f231 | 2017-02-09 02:19:30 | [diff] [blame] | 49 | option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) |
Saleem Abdulrasool | 6e2aa5e | 2016-07-15 00:49:42 | [diff] [blame] | 50 | option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) |
Eric Fiselier | 559f867 | 2014-11-24 22:42:03 | [diff] [blame] | 51 | option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON) |
Ben Craig | 24a9861 | 2016-05-25 17:37:38 | [diff] [blame] | 52 | option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) |
Markus Böck | 05b3716 | 2021-03-05 14:30:13 | [diff] [blame] | 53 | option(LIBCXXABI_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF) |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 54 | option(LIBCXXABI_HAS_EXTERNAL_THREAD_API |
| 55 | "Build libc++abi with an externalized threading API. |
| 56 | This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF) |
Asiri Rathnayake | a573fe2 | 2017-01-09 11:57:21 | [diff] [blame] | 57 | option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY |
| 58 | "Build libc++abi with an externalized threading library. |
| 59 | This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF) |
Louis Dionne | e5291c4 | 2020-04-22 20:17:58 | [diff] [blame] | 60 | option(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST |
| 61 | "Make dynamic_cast more forgiving when type_info's mistakenly have hidden \ |
| 62 | visibility, and thus multiple type_infos can exist for a single type. \ |
| 63 | When the dynamic_cast would normally fail, this option will cause the \ |
| 64 | library to try comparing the type_info names to see if they are equal \ |
| 65 | instead." OFF) |
Eric Fiselier | 38643b9 | 2017-03-02 21:55:17 | [diff] [blame] | 66 | |
Eric Fiselier | 2ee1d90 | 2017-03-02 19:34:35 | [diff] [blame] | 67 | option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS |
Louis Dionne | 9b40ee8 | 2019-10-01 13:34:58 | [diff] [blame] | 68 | "Build libc++abi with definitions for operator new/delete. These are normally |
| 69 | defined in libc++abi, but it is also possible to define them in libc++, in |
| 70 | which case the definition in libc++abi should be turned off." ON) |
Louis Dionne | fa1c077 | 2021-11-23 21:34:09 | [diff] [blame] | 71 | option(LIBCXXABI_BUILD_32_BITS "Build 32 bit multilib libc++abi. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS}) |
| 72 | if (LIBCXXABI_BUILD_32_BITS) |
Louis Dionne | dc1244d | 2021-12-01 17:57:30 | [diff] [blame] | 73 | message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.") |
Louis Dionne | fa1c077 | 2021-11-23 21:34:09 | [diff] [blame] | 74 | endif() |
| 75 | |
Bryant Wong | 66b5441 | 2017-01-07 22:14:04 | [diff] [blame] | 76 | option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS}) |
Ismail Donmez | dea7590 | 2017-06-13 08:16:44 | [diff] [blame] | 77 | set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING |
| 78 | "Define suffix of library directory name (32/64)") |
Louis Dionne | 6dfdf79 | 2022-02-17 16:19:45 | [diff] [blame] | 79 | option(LIBCXXABI_INSTALL_HEADERS "Install the libc++abi headers." ON) |
Petr Hosek | aa96d2e | 2017-11-17 23:25:09 | [diff] [blame] | 80 | option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON) |
Petr Hosek | 6f5f847 | 2022-05-14 02:23:52 | [diff] [blame] | 81 | |
| 82 | set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path to install the libc++abi headers at.") |
| 83 | |
| 84 | if(LLVM_LIBRARY_OUTPUT_INTDIR) |
| 85 | set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") |
| 86 | else() |
| 87 | set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") |
| 88 | endif() |
Louis Dionne | 72117f2 | 2021-10-12 19:59:08 | [diff] [blame] | 89 | |
Louis Dionne | 3ee0cec | 2021-10-12 19:59:08 | [diff] [blame] | 90 | # TODO: Remove this after branching for LLVM 15 |
| 91 | if(LIBCXXABI_SYSROOT OR LIBCXXABI_TARGET_TRIPLE OR LIBCXXABI_GCC_TOOLCHAIN) |
| 92 | message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") |
Louis Dionne | 641a141 | 2022-02-15 13:18:38 | [diff] [blame] | 93 | endif() |
Louis Dionne | 2e3bb91 | 2022-02-16 16:59:32 | [diff] [blame] | 94 | |
Ben Craig | 658310b | 2016-06-01 12:50:30 | [diff] [blame] | 95 | set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") |
Louis Dionne | be52ff9 | 2019-10-07 19:22:04 | [diff] [blame] | 96 | set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING |
| 97 | "Version of libc++abi. This will be reflected in the name of the shared \ |
| 98 | library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \ |
| 99 | result in the library being named libc++abi.x.y.dylib, along with the \ |
| 100 | usual symlinks pointing to that.") |
Dan Albert | a770f9d | 2014-07-10 02:20:11 | [diff] [blame] | 101 | |
| 102 | # Default to building a shared library so that the default options still test |
Louis Dionne | 0a22dfc | 2022-05-13 16:15:15 | [diff] [blame] | 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. |
Dan Albert | a770f9d | 2014-07-10 02:20:11 | [diff] [blame] | 106 | option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON) |
Eric Fiselier | 14dbeaa | 2015-03-03 15:59:09 | [diff] [blame] | 107 | option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON) |
| 108 | |
Sam Clegg | 77c99ee | 2018-07-25 23:13:00 | [diff] [blame] | 109 | cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY |
| 110 | "Install the static libc++abi library." ON |
| 111 | "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF) |
| 112 | cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY |
| 113 | "Install the shared libc++abi library." ON |
| 114 | "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF) |
| 115 | |
Petr Hosek | 058c04c | 2018-07-24 07:06:17 | [diff] [blame] | 116 | cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY |
| 117 | "Statically link the LLVM unwinder to static library" ON |
Louis Dionne | fa7ce8e | 2022-05-18 16:05:45 | [diff] [blame] | 118 | "LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF) |
Petr Hosek | 058c04c | 2018-07-24 07:06:17 | [diff] [blame] | 119 | cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY |
| 120 | "Statically link the LLVM unwinder to shared library" ON |
Louis Dionne | fa7ce8e | 2022-05-18 16:05:45 | [diff] [blame] | 121 | "LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF) |
Petr Hosek | 058c04c | 2018-07-24 07:06:17 | [diff] [blame] | 122 | |
Ranjeet Singh | ef6e672 | 2017-03-01 11:42:01 | [diff] [blame] | 123 | option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF) |
| 124 | # The default terminate handler attempts to demangle uncaught exceptions, which |
| 125 | # causes extra I/O and demangling code to be pulled in. |
| 126 | option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF) |
Dan Albert | 866d480 | 2021-01-21 21:27:14 | [diff] [blame] | 127 | option(LIBCXXABI_NON_DEMANGLING_TERMINATE "Set this to make the terminate handler |
| 128 | avoid demangling" OFF) |
Ranjeet Singh | ef6e672 | 2017-03-01 11:42:01 | [diff] [blame] | 129 | |
Eric Fiselier | 14dbeaa | 2015-03-03 15:59:09 | [diff] [blame] | 130 | if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC) |
| 131 | message(FATAL_ERROR "libc++abi must be built as either a shared or static library.") |
| 132 | endif() |
Dan Albert | a770f9d | 2014-07-10 02:20:11 | [diff] [blame] | 133 | |
Louis Dionne | 0a22dfc | 2022-05-13 16:15:15 | [diff] [blame] | 134 | # TODO: Remove this, which shouldn't be necessary since we know we're being built |
| 135 | # side-by-side with libc++. |
Petr Hosek | 1687f2b | 2021-03-10 19:21:41 | [diff] [blame] | 136 | set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH |
Louis Dionne | 48e4b0f | 2020-10-23 13:32:50 | [diff] [blame] | 137 | "Specify path to libc++ includes.") |
Louis Dionne | 529ac33 | 2020-10-22 23:11:33 | [diff] [blame] | 138 | |
Martin Storsjö | bedf657 | 2022-04-09 20:40:07 | [diff] [blame] | 139 | set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) |
| 140 | if (WIN32) |
| 141 | set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON) |
| 142 | endif() |
Petr Hosek | 8807db3 | 2019-01-24 03:18:29 | [diff] [blame] | 143 | option(LIBCXXABI_HERMETIC_STATIC_LIBRARY |
Martin Storsjö | bedf657 | 2022-04-09 20:40:07 | [diff] [blame] | 144 | "Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT}) |
Petr Hosek | 8807db3 | 2019-01-24 03:18:29 | [diff] [blame] | 145 | |
Louis Dionne | 33c9c10 | 2020-06-25 15:46:00 | [diff] [blame] | 146 | set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING |
Louis Dionne | 54a8a0d | 2021-09-29 19:26:05 | [diff] [blame] | 147 | "The path to the Lit testing configuration to use when running the tests. |
Louis Dionne | d1e0f02 | 2021-10-12 21:45:45 | [diff] [blame] | 148 | If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxxabi/test/configs'.") |
Louis Dionne | 54a8a0d | 2021-09-29 19:26:05 | [diff] [blame] | 149 | if (NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}") |
Louis Dionne | d1e0f02 | 2021-10-12 21:45:45 | [diff] [blame] | 150 | set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXXABI_TEST_CONFIG}") |
Louis Dionne | 54a8a0d | 2021-09-29 19:26:05 | [diff] [blame] | 151 | endif() |
Louis Dionne | c631e33 | 2022-05-11 14:16:29 | [diff] [blame] | 152 | message(STATUS "Using libc++abi testing configuration: ${LIBCXXABI_TEST_CONFIG}") |
Louis Dionne | 6f69318 | 2020-07-09 15:54:09 | [diff] [blame] | 153 | set(LIBCXXABI_TEST_PARAMS "" CACHE STRING |
| 154 | "A list of parameters to run the Lit test suite with.") |
Louis Dionne | 33c9c10 | 2020-06-25 15:46:00 | [diff] [blame] | 155 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 156 | #=============================================================================== |
| 157 | # Configure System |
| 158 | #=============================================================================== |
| 159 | |
| 160 | # Add path for custom modules |
| 161 | set(CMAKE_MODULE_PATH |
| 162 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 163 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
| 164 | ${CMAKE_MODULE_PATH} |
| 165 | ) |
| 166 | |
John Ericson | f16a4a0 | 2022-01-16 06:00:29 | [diff] [blame] | 167 | set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH |
John Ericson | 0a8d15a | 2022-01-11 03:03:21 | [diff] [blame] | 168 | "Path where built libc++abi runtime libraries should be installed.") |
| 169 | |
Petr Hosek | 887f26d | 2018-06-28 03:11:52 | [diff] [blame] | 170 | if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) |
Petr Hosek | 1687f2b | 2021-03-10 19:21:41 | [diff] [blame] | 171 | set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) |
Petr Hosek | f749550 | 2021-04-17 04:33:18 | [diff] [blame] | 172 | set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) |
John Ericson | 1e03c37 | 2021-04-28 22:36:47 | [diff] [blame] | 173 | set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH |
| 174 | "Path where built libc++abi libraries should be installed.") |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 | [diff] [blame] | 175 | if(LIBCXX_LIBDIR_SUBDIR) |
| 176 | string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) |
| 177 | string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) |
| 178 | endif() |
Jonas Hahnfeld | 57aa0d4 | 2017-05-04 06:04:49 | [diff] [blame] | 179 | else() |
John Ericson | 0a8d15a | 2022-01-11 03:03:21 | [diff] [blame] | 180 | if(LLVM_LIBRARY_OUTPUT_INTDIR) |
| 181 | set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) |
| 182 | set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) |
| 183 | else() |
| 184 | set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) |
| 185 | set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) |
| 186 | endif() |
John Ericson | 1e03c37 | 2021-04-28 22:36:47 | [diff] [blame] | 187 | set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH |
| 188 | "Path where built libc++abi libraries should be installed.") |
Jonas Hahnfeld | 57aa0d4 | 2017-05-04 06:04:49 | [diff] [blame] | 189 | endif() |
Chandler Carruth | 24a6b05 | 2014-12-29 12:22:04 | [diff] [blame] | 190 | |
Ben Craig | ab56c40 | 2016-04-18 13:30:38 | [diff] [blame] | 191 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) |
| 192 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 193 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) |
Ben Craig | ab56c40 | 2016-04-18 13:30:38 | [diff] [blame] | 194 | |
Louis Dionne | 0a22dfc | 2022-05-13 16:15:15 | [diff] [blame] | 195 | # By default, libcxx and libcxxabi share a library directory. |
Ben Craig | 658310b | 2016-06-01 12:50:30 | [diff] [blame] | 196 | if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) |
| 197 | set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH |
Sergej Jaskiewicz | fb76c79 | 2019-12-26 09:28:39 | [diff] [blame] | 198 | "The path to libc++ library." FORCE) |
Eugene Zelenko | 9d09275 | 2016-08-08 17:59:02 | [diff] [blame] | 199 | endif() |
Eric Fiselier | ffd1893 | 2016-06-02 02:18:31 | [diff] [blame] | 200 | |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 201 | # Declare libc++abi configuration variables. |
| 202 | # They are intended for use as follows: |
| 203 | # LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker. |
| 204 | # LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker. |
| 205 | # LIBCXXABI_COMPILE_FLAGS: Compile only flags. |
| 206 | # LIBCXXABI_LINK_FLAGS: Linker only flags. |
| 207 | # LIBCXXABI_LIBRARIES: libraries libc++abi is linked to. |
Eric Fiselier | ffd1893 | 2016-06-02 02:18:31 | [diff] [blame] | 208 | |
Logan Chien | dbcd7a3 | 2015-01-22 13:39:08 | [diff] [blame] | 209 | set(LIBCXXABI_C_FLAGS "") |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 210 | set(LIBCXXABI_CXX_FLAGS "") |
| 211 | set(LIBCXXABI_COMPILE_FLAGS "") |
| 212 | set(LIBCXXABI_LINK_FLAGS "") |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 213 | set(LIBCXXABI_LIBRARIES "") |
| 214 | |
| 215 | # Include macros for adding and removing libc++abi flags. |
| 216 | include(HandleLibcxxabiFlags) |
| 217 | |
| 218 | #=============================================================================== |
| 219 | # Setup Compiler Flags |
| 220 | #=============================================================================== |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 221 | |
Eric Fiselier | ffd1893 | 2016-06-02 02:18:31 | [diff] [blame] | 222 | # Configure target flags |
Muiez Ahmed | a1da739 | 2022-01-14 16:35:53 | [diff] [blame] | 223 | if(ZOS) |
| 224 | add_target_flags_if_supported("-fzos-le-char-mode=ebcdic") |
| 225 | endif() |
Eric Fiselier | ffd1893 | 2016-06-02 02:18:31 | [diff] [blame] | 226 | |
| 227 | # Configure compiler. Must happen after setting the target flags. |
| 228 | include(config-ix) |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 229 | |
Petr Hosek | b3df14b | 2022-03-10 09:47:09 | [diff] [blame] | 230 | if (CXX_SUPPORTS_NOSTDINCXX_FLAG) |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 231 | list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++) |
Sam Clegg | 4230fa9 | 2019-11-07 22:51:25 | [diff] [blame] | 232 | # cmake 3.14 and above remove system include paths that are explicitly |
| 233 | # passed on the command line. We build with -nostdinc++ and explicitly add |
| 234 | # just the libcxx system include paths with -I on the command line. |
| 235 | # Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effectively prevents cmake |
| 236 | # from removing these. |
| 237 | # See: https://gitlab.kitware.com/cmake/cmake/issues/19227 |
| 238 | set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "") |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 239 | # Remove -stdlib flags to prevent them from causing an unused flag warning. |
Raphael Isemann | 6b7a49b | 2020-10-13 14:05:00 | [diff] [blame] | 240 | string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 241 | string(REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 242 | string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 243 | string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 244 | endif() |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 245 | |
Shoaib Meenai | 88c6acf | 2016-09-27 03:44:09 | [diff] [blame] | 246 | # Let the library headers know they are currently being used to build the |
| 247 | # library. |
| 248 | add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY) |
| 249 | |
Martin Storsjö | 9c30baf | 2020-10-30 17:11:23 | [diff] [blame] | 250 | # libcxxabi needs to, for various reasons, include the libcpp headers as if |
| 251 | # it is being built as part of libcxx. |
| 252 | add_definitions(-D_LIBCPP_BUILDING_LIBRARY) |
| 253 | |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 254 | add_compile_flags_if_supported(-Werror=return-type) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 255 | |
| 256 | # Get warning flags |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 257 | add_compile_flags_if_supported(-W) |
| 258 | add_compile_flags_if_supported(-Wall) |
| 259 | add_compile_flags_if_supported(-Wchar-subscripts) |
| 260 | add_compile_flags_if_supported(-Wconversion) |
| 261 | add_compile_flags_if_supported(-Wmismatched-tags) |
| 262 | add_compile_flags_if_supported(-Wmissing-braces) |
| 263 | add_compile_flags_if_supported(-Wnewline-eof) |
| 264 | add_compile_flags_if_supported(-Wunused-function) |
| 265 | add_compile_flags_if_supported(-Wshadow) |
| 266 | add_compile_flags_if_supported(-Wshorten-64-to-32) |
| 267 | add_compile_flags_if_supported(-Wsign-compare) |
| 268 | add_compile_flags_if_supported(-Wsign-conversion) |
| 269 | add_compile_flags_if_supported(-Wstrict-aliasing=2) |
| 270 | add_compile_flags_if_supported(-Wstrict-overflow=4) |
| 271 | add_compile_flags_if_supported(-Wunused-parameter) |
| 272 | add_compile_flags_if_supported(-Wunused-variable) |
| 273 | add_compile_flags_if_supported(-Wwrite-strings) |
| 274 | add_compile_flags_if_supported(-Wundef) |
Dan Albert | 3c4780e | 2014-07-10 22:23:03 | [diff] [blame] | 275 | |
Logan Smith | 77e0e9e | 2020-07-23 00:44:52 | [diff] [blame] | 276 | add_compile_flags_if_supported(-Wno-suggest-override) |
| 277 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 278 | if (LIBCXXABI_ENABLE_WERROR) |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 279 | add_compile_flags_if_supported(-Werror) |
| 280 | add_compile_flags_if_supported(-WX) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 281 | else() |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 282 | add_compile_flags_if_supported(-Wno-error) |
| 283 | add_compile_flags_if_supported(-WX-) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 284 | endif() |
| 285 | if (LIBCXXABI_ENABLE_PEDANTIC) |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 286 | add_compile_flags_if_supported(-pedantic) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 287 | endif() |
| 288 | |
| 289 | # Get feature flags. |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 290 | add_compile_flags_if_supported(-fstrict-aliasing) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 291 | |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 | [diff] [blame] | 292 | # Exceptions |
| 293 | if (LIBCXXABI_ENABLE_EXCEPTIONS) |
| 294 | # Catches C++ exceptions only and tells the compiler to assume that extern C |
| 295 | # functions never throw a C++ exception. |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 296 | add_compile_flags_if_supported(-EHsc) |
| 297 | # Do we really need to be run through the C compiler ? |
| 298 | add_c_compile_flags_if_supported(-funwind-tables) |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 | [diff] [blame] | 299 | else() |
Martell Malone | 062f8f0 | 2017-06-01 00:09:20 | [diff] [blame] | 300 | add_compile_flags_if_supported(-fno-exceptions) |
| 301 | add_compile_flags_if_supported(-EHs-) |
| 302 | add_compile_flags_if_supported(-EHa-) |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 | [diff] [blame] | 303 | endif() |
Logan Chien | dbcd7a3 | 2015-01-22 13:39:08 | [diff] [blame] | 304 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 305 | # Assert |
| 306 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 307 | if (LIBCXXABI_ENABLE_ASSERTIONS) |
| 308 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
| 309 | if (NOT MSVC) |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 310 | list(APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 311 | endif() |
| 312 | # On Release builds cmake automatically defines NDEBUG, so we |
| 313 | # explicitly undefine it: |
| 314 | if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 315 | list(APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 316 | endif() |
| 317 | else() |
| 318 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 319 | list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 320 | endif() |
| 321 | endif() |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 322 | |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 323 | # Threading |
Eric Fiselier | 559f867 | 2014-11-24 22:42:03 | [diff] [blame] | 324 | if (NOT LIBCXXABI_ENABLE_THREADS) |
Ben Craig | 24a9861 | 2016-05-25 17:37:38 | [diff] [blame] | 325 | if (LIBCXXABI_HAS_PTHREAD_API) |
| 326 | message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only" |
| 327 | " be set to ON when LIBCXXABI_ENABLE_THREADS" |
| 328 | " is also set to ON.") |
| 329 | endif() |
Markus Böck | 05b3716 | 2021-03-05 14:30:13 | [diff] [blame] | 330 | if (LIBCXXABI_HAS_WIN32_THREAD_API) |
| 331 | message(FATAL_ERROR "LIBCXXABI_HAS_WIN32_THREAD_API can only" |
| 332 | " be set to ON when LIBCXXABI_ENABLE_THREADS" |
| 333 | " is also set to ON.") |
| 334 | endif() |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 335 | if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) |
| 336 | message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only" |
| 337 | " be set to ON when LIBCXXABI_ENABLE_THREADS" |
| 338 | " is also set to ON.") |
| 339 | endif() |
Asiri Rathnayake | a573fe2 | 2017-01-09 11:57:21 | [diff] [blame] | 340 | if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 341 | message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only" |
| 342 | " be set to ON when LIBCXXABI_ENABLE_THREADS" |
| 343 | " is also set to ON.") |
| 344 | endif() |
Asiri Rathnayake | 7c98baa | 2016-09-21 09:09:32 | [diff] [blame] | 345 | add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) |
Eric Fiselier | 559f867 | 2014-11-24 22:42:03 | [diff] [blame] | 346 | endif() |
| 347 | |
Asiri Rathnayake | a573fe2 | 2017-01-09 11:57:21 | [diff] [blame] | 348 | if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) |
| 349 | if (LIBCXXABI_HAS_PTHREAD_API) |
| 350 | message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" |
| 351 | " and LIBCXXABI_HAS_PTHREAD_API cannot be both" |
| 352 | " set to ON at the same time.") |
| 353 | endif() |
Markus Böck | 05b3716 | 2021-03-05 14:30:13 | [diff] [blame] | 354 | if (LIBCXXABI_HAS_WIN32_THREAD_API) |
| 355 | message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" |
| 356 | " and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both" |
| 357 | " set to ON at the same time.") |
| 358 | endif() |
Asiri Rathnayake | a573fe2 | 2017-01-09 11:57:21 | [diff] [blame] | 359 | if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 360 | message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY" |
| 361 | " and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both" |
| 362 | " set to ON at the same time.") |
| 363 | endif() |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 364 | endif() |
| 365 | |
Markus Böck | 05b3716 | 2021-03-05 14:30:13 | [diff] [blame] | 366 | if (LIBCXXABI_HAS_PTHREAD_API) |
| 367 | if (LIBCXXABI_HAS_WIN32_THREAD_API) |
| 368 | message(FATAL_ERROR "The options LIBCXXABI_HAS_PTHREAD_API" |
| 369 | "and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both" |
| 370 | "set to ON at the same time.") |
| 371 | endif() |
| 372 | endif() |
| 373 | |
NAKAMURA Takumi | 83105a4 | 2017-07-31 09:35:08 | [diff] [blame] | 374 | if (LLVM_ENABLE_MODULES) |
| 375 | # Ignore that the rest of the modules flags are now unused. |
| 376 | add_compile_flags_if_supported(-Wno-unused-command-line-argument) |
| 377 | add_compile_flags(-fno-modules) |
| 378 | endif() |
| 379 | |
Eric Fiselier | 6f8d62d | 2017-03-04 02:15:37 | [diff] [blame] | 380 | set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF) |
| 381 | if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) |
Eric Fiselier | 70c2b1c | 2017-05-11 03:49:48 | [diff] [blame] | 382 | OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED) |
| 383 | OR MINGW) |
Eric Fiselier | 6f8d62d | 2017-03-04 02:15:37 | [diff] [blame] | 384 | set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON) |
| 385 | endif() |
Eric Fiselier | 2ee1d90 | 2017-03-02 19:34:35 | [diff] [blame] | 386 | |
| 387 | if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS) |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 388 | # Need to allow unresolved symbols if this is to work with shared library builds |
| 389 | if (APPLE) |
Eric Fiselier | 6f8d62d | 2017-03-04 02:15:37 | [diff] [blame] | 390 | list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup") |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 391 | else() |
| 392 | # Relax this restriction from HandleLLVMOptions |
| 393 | string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") |
| 394 | endif() |
| 395 | endif() |
| 396 | |
Ben Craig | 24a9861 | 2016-05-25 17:37:38 | [diff] [blame] | 397 | if (LIBCXXABI_HAS_PTHREAD_API) |
| 398 | add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD) |
| 399 | endif() |
| 400 | |
Markus Böck | 05b3716 | 2021-03-05 14:30:13 | [diff] [blame] | 401 | if (LIBCXXABI_HAS_WIN32_THREAD_API) |
| 402 | add_definitions(-D_LIBCPP_HAS_THREAD_API_WIN32) |
| 403 | endif() |
| 404 | |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 405 | if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) |
Asiri Rathnayake | a573fe2 | 2017-01-09 11:57:21 | [diff] [blame] | 406 | add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL) |
| 407 | endif() |
| 408 | |
| 409 | if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 410 | add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) |
Asiri Rathnayake | 97ba9fa | 2017-01-03 12:58:34 | [diff] [blame] | 411 | endif() |
| 412 | |
Shoaib Meenai | f43726c | 2017-05-10 21:52:39 | [diff] [blame] | 413 | # Prevent libc++abi from having library dependencies on libc++ |
| 414 | add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE) |
| 415 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 416 | if (MSVC) |
| 417 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
| 418 | endif() |
| 419 | |
James Y Knight | 0d3145f | 2017-01-13 19:22:26 | [diff] [blame] | 420 | if (LIBCXXABI_SILENT_TERMINATE) |
Ranjeet Singh | ef6e672 | 2017-03-01 11:42:01 | [diff] [blame] | 421 | add_definitions(-DLIBCXXABI_SILENT_TERMINATE) |
| 422 | endif() |
| 423 | |
Dan Albert | 866d480 | 2021-01-21 21:27:14 | [diff] [blame] | 424 | if (LIBCXXABI_NON_DEMANGLING_TERMINATE) |
| 425 | add_definitions(-DLIBCXXABI_NON_DEMANGLING_TERMINATE) |
| 426 | endif() |
| 427 | |
Ranjeet Singh | ef6e672 | 2017-03-01 11:42:01 | [diff] [blame] | 428 | if (LIBCXXABI_BAREMETAL) |
| 429 | add_definitions(-DLIBCXXABI_BAREMETAL) |
James Y Knight | 0d3145f | 2017-01-13 19:22:26 | [diff] [blame] | 430 | endif() |
| 431 | |
Petr Hosek | b3df14b | 2022-03-10 09:47:09 | [diff] [blame] | 432 | if (C_SUPPORTS_COMMENT_LIB_PRAGMA) |
Michał Górny | a9b5fff | 2019-12-02 10:49:20 | [diff] [blame] | 433 | if (LIBCXXABI_HAS_PTHREAD_LIB) |
| 434 | add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB) |
| 435 | endif() |
Petr Hosek | 789b7f0 | 2019-05-30 04:40:21 | [diff] [blame] | 436 | endif() |
| 437 | |
Eric Fiselier | 5cb5051 | 2014-11-18 20:37:53 | [diff] [blame] | 438 | string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}") |
| 439 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}") |
Logan Chien | dbcd7a3 | 2015-01-22 13:39:08 | [diff] [blame] | 440 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}") |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 441 | |
David Tenty | 2b416b4 | 2021-11-09 17:44:44 | [diff] [blame] | 442 | # On AIX, avoid picking up VMX extensions(i.e. vec_malloc) which would change |
| 443 | # the default alignment of the allocators here. |
| 444 | if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") |
| 445 | add_definitions("-D_XOPEN_SOURCE=700") |
| 446 | endif() |
| 447 | |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 448 | #=============================================================================== |
| 449 | # Setup Source Code |
| 450 | #=============================================================================== |
| 451 | |
Anton Korobeynikov | d3b50dc | 2015-05-08 16:10:11 | [diff] [blame] | 452 | set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH |
| 453 | "Specify path to libunwind includes." FORCE) |
| 454 | set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH |
| 455 | "Specify path to libunwind source." FORCE) |
| 456 | |
Eric Fiselier | 9429684 | 2015-04-29 15:53:03 | [diff] [blame] | 457 | if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM) |
Petr Hosek | 4fe63c7 | 2019-05-02 17:29:39 | [diff] [blame] | 458 | find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h |
Anton Korobeynikov | d3b50dc | 2015-05-08 16:10:11 | [diff] [blame] | 459 | PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES} |
| 460 | ${LIBCXXABI_LIBUNWIND_PATH}/include |
| 461 | ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES} |
| 462 | ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include |
Petr Hosek | bfb371a | 2016-11-11 19:12:58 | [diff] [blame] | 463 | ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include |
Petr Hosek | 86a9ddc | 2018-04-04 17:40:59 | [diff] [blame] | 464 | ${LLVM_MAIN_SRC_DIR}/../libunwind/include |
Anton Korobeynikov | 1af9c7b | 2015-05-09 21:03:01 | [diff] [blame] | 465 | NO_DEFAULT_PATH |
Don Hinton | ae858bf | 2018-01-22 19:41:05 | [diff] [blame] | 466 | NO_CMAKE_FIND_ROOT_PATH |
Anton Korobeynikov | d3b50dc | 2015-05-08 16:10:11 | [diff] [blame] | 467 | ) |
| 468 | |
Asiri Rathnayake | 4cc78d7 | 2017-04-04 14:03:54 | [diff] [blame] | 469 | if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND") |
| 470 | set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "") |
| 471 | endif() |
| 472 | |
| 473 | if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "") |
Michal Gorny | 40180b0 | 2017-01-14 17:05:16 | [diff] [blame] | 474 | include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}") |
| 475 | endif() |
Eugene Zelenko | 9d09275 | 2016-08-08 17:59:02 | [diff] [blame] | 476 | endif() |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 477 | |
| 478 | # Add source code. This also contains all of the logic for deciding linker flags |
| 479 | # soname, etc... |
Louis Dionne | 6dfdf79 | 2022-02-17 16:19:45 | [diff] [blame] | 480 | add_subdirectory(include) |
Dan Albert | 0ed2e2f | 2014-07-03 19:35:48 | [diff] [blame] | 481 | add_subdirectory(src) |
Dan Albert | a770f9d | 2014-07-10 02:20:11 | [diff] [blame] | 482 | |
Don Hinton | 964ea50 | 2018-01-18 18:29:36 | [diff] [blame] | 483 | if (LIBCXXABI_INCLUDE_TESTS) |
Dominik Montada | 8c03fdf | 2020-08-24 09:01:05 | [diff] [blame] | 484 | add_subdirectory(test) |
| 485 | add_subdirectory(fuzz) |
Dan Albert | a770f9d | 2014-07-10 02:20:11 | [diff] [blame] | 486 | endif() |