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