Eric Fiselier | 145df5c | 2020-03-24 21:33:42 -0400 | [diff] [blame] | 1 | # See https://libcxx.llvm.org/docs/BuildingLibcxx.html for instructions on how |
| 2 | # to build libcxx with CMake. |
Eric Fiselier | 5baa387 | 2017-05-04 06:28:34 +0000 | [diff] [blame] | 3 | |
Louis Dionne | a9d217b | 2020-03-12 18:01:20 -0400 | [diff] [blame] | 4 | if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxxabi") |
| 5 | message(FATAL_ERROR "libc++ now requires being built in a monorepo layout with libcxxabi available") |
| 6 | endif() |
| 7 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 8 | #=============================================================================== |
| 9 | # Setup Project |
| 10 | #=============================================================================== |
Chris Bieneman | e490006 | 2016-05-31 20:21:52 +0000 | [diff] [blame] | 11 | cmake_minimum_required(VERSION 3.4.3) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 12 | |
Eric Fiselier | 9af31a4 | 2015-01-26 21:56:45 +0000 | [diff] [blame] | 13 | if(POLICY CMP0042) |
| 14 | cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default |
| 15 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 16 | if(POLICY CMP0022) |
| 17 | cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang |
| 18 | endif() |
Eric Fiselier | 7886b53 | 2018-07-26 05:08:30 +0000 | [diff] [blame] | 19 | if(POLICY CMP0068) |
| 20 | cmake_policy(SET CMP0068 NEW) |
| 21 | set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) |
| 22 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 23 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 24 | # Add path for custom modules |
| 25 | set(CMAKE_MODULE_PATH |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 26 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 27 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
Eric Fiselier | 0f932cb | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 28 | ${CMAKE_MODULE_PATH} |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 29 | ) |
| 30 | |
Jonas Hahnfeld | dc2bf5e | 2019-02-17 12:16:20 +0000 | [diff] [blame] | 31 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 32 | project(libcxx CXX C) |
| 33 | |
| 34 | set(PACKAGE_NAME libcxx) |
Hans Wennborg | fc14f4e | 2020-01-15 10:02:56 +0100 | [diff] [blame] | 35 | set(PACKAGE_VERSION 11.0.0git) |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 36 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 37 | set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") |
Eric Fiselier | 95353d5 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 38 | |
| 39 | # Find the LLVM sources and simulate LLVM CMake options. |
| 40 | include(HandleOutOfTreeLLVM) |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 41 | endif() |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 42 | |
Petr Hosek | 8e112a4 | 2017-01-16 00:33:07 +0000 | [diff] [blame] | 43 | if (LIBCXX_STANDALONE_BUILD) |
| 44 | include(FindPythonInterp) |
| 45 | if( NOT PYTHONINTERP_FOUND ) |
| 46 | message(WARNING "Failed to find python interpreter. " |
| 47 | "The libc++ test suite will be disabled.") |
| 48 | set(LLVM_INCLUDE_TESTS OFF) |
| 49 | endif() |
| 50 | endif() |
| 51 | |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 52 | # Require out of source build. |
| 53 | include(MacroEnsureOutOfSourceBuild) |
| 54 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( |
| 55 | "${PROJECT_NAME} requires an out of source build. Please create a separate |
| 56 | build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." |
| 57 | ) |
Eric Fiselier | b26c2fe | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 58 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") |
| 59 | message(STATUS "Configuring for clang-cl") |
| 60 | set(LIBCXX_TARGETING_CLANG_CL ON) |
| 61 | endif() |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 62 | |
Eric Fiselier | 1e6fdc0 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 63 | if (MSVC) |
| 64 | set(LIBCXX_TARGETING_MSVC ON) |
Eric Fiselier | 66fd431 | 2018-10-01 01:00:11 +0000 | [diff] [blame] | 65 | message(STATUS "Configuring for MSVC") |
Eric Fiselier | 1e6fdc0 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 66 | else() |
| 67 | set(LIBCXX_TARGETING_MSVC OFF) |
| 68 | endif() |
| 69 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 70 | #=============================================================================== |
| 71 | # Setup CMake Options |
| 72 | #=============================================================================== |
Eric Fiselier | 121594e | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 73 | include(CMakeDependentOption) |
Eric Fiselier | 58bd12a | 2017-03-11 03:24:18 +0000 | [diff] [blame] | 74 | include(HandleCompilerRT) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 75 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 76 | # Basic options --------------------------------------------------------------- |
Eric Fiselier | 59cd98b | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 77 | option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 78 | option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) |
Petr Hosek | 1362005 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 79 | option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) |
Eric Fiselier | 35950a5 | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 80 | option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) |
Eric Fiselier | 72e2dd8 | 2019-03-21 00:04:31 +0000 | [diff] [blame] | 81 | set(ENABLE_FILESYSTEM_DEFAULT ON) |
| 82 | if (WIN32) |
| 83 | set(ENABLE_FILESYSTEM_DEFAULT OFF) |
| 84 | endif() |
| 85 | option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library" |
| 86 | ${ENABLE_FILESYSTEM_DEFAULT}) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 87 | option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) |
Louis Dionne | 59d0b3c | 2019-08-05 18:29:14 +0000 | [diff] [blame] | 88 | option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) |
Sterling Augustine | 35285a8 | 2019-10-04 22:15:28 +0000 | [diff] [blame] | 89 | option(LIBCXX_TEST_GDB_PRETTY_PRINTERS "Test gdb pretty printers." OFF) |
Eric Fiselier | 18d2fa3 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 90 | |
Eric Fiselier | 18d2fa3 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 91 | # Benchmark options ----------------------------------------------------------- |
Louis Dionne | 818d41b | 2018-09-22 21:30:12 +0000 | [diff] [blame] | 92 | option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) |
Eric Fiselier | 453bc18 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 93 | |
| 94 | set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) |
| 95 | set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING |
| 96 | "Arguments to pass when running the benchmarks using check-cxx-benchmarks") |
| 97 | |
Eric Fiselier | 18d2fa3 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 98 | set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING |
| 99 | "Build the benchmarks against the specified native STL. |
| 100 | The value must be one of libc++/libstdc++") |
| 101 | set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING |
| 102 | "Use alternate GCC toolchain when building the native benchmarks") |
| 103 | |
| 104 | if (LIBCXX_BENCHMARK_NATIVE_STDLIB) |
| 105 | if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" |
| 106 | OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) |
| 107 | message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " |
| 108 | "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") |
| 109 | endif() |
| 110 | endif() |
| 111 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 112 | option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 113 | set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING |
| 114 | "Define suffix of library directory name (32/64)") |
| 115 | option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) |
Eric Fiselier | 68205ee | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 116 | option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) |
Petr Hosek | b74fd16 | 2018-07-24 23:27:51 +0000 | [diff] [blame] | 117 | cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY |
| 118 | "Install the static libc++ library." ON |
| 119 | "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF) |
| 120 | cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY |
| 121 | "Install the shared libc++ library." ON |
| 122 | "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 123 | option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) |
Eric Fiselier | 121594e | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 124 | cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY |
| 125 | "Install libc++experimental.a" ON |
| 126 | "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) |
Eric Fiselier | 02cea5e | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 127 | |
Louis Dionne | 0e445c0 | 2018-09-26 08:24:51 +0000 | [diff] [blame] | 128 | set(LIBCXX_ABI_VERSION "1" CACHE STRING "ABI version of libc++. Can be either 1 or 2, where 2 is currently not stable. Defaults to 1.") |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 129 | set(LIBCXX_ABI_NAMESPACE "" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") |
Evgeniy Stepanov | da2ff7e | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 130 | option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) |
Shoaib Meenai | 56943f8 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 131 | option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.") |
| 132 | option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.") |
Eric Fiselier | f356629 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 133 | |
| 134 | |
| 135 | set(LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT "" CACHE STRING |
| 136 | "Whether typeinfo names are expected to be unique. Defining this option overrides the default configuration in the library.") |
| 137 | set(MERGED_TYPEINFO_VALUES ";ON;OFF") |
| 138 | set_property(CACHE LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT PROPERTY STRINGS ${MERGED_TYPEINFO_DEFAULTS}) |
| 139 | list(FIND MERGED_TYPEINFO_VALUES "${LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT}" IS_VALID_DEFAULT) |
| 140 | if (${IS_VALID_DEFAULT} EQUAL -1) |
| 141 | message(FATAL_ERROR "Value '${LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT}' is not a valid value for |
| 142 | LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT") |
| 143 | endif() |
| 144 | |
Louis Dionne | 1821de4 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 145 | option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF) |
Shoaib Meenai | d980352 | 2017-10-04 23:51:57 +0000 | [diff] [blame] | 146 | set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.") |
Saleem Abdulrasool | bac3482 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 147 | option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) |
Louis Dionne | 55011e1 | 2019-03-20 18:16:24 +0000 | [diff] [blame] | 148 | set(LIBCXX_LIBCPPABI_VERSION "2" CACHE STRING "Version of libc++abi's ABI to re-export from libc++ when re-exporting is enabled. |
| 149 | Note that this is not related to the version of libc++'s ABI itself!") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 150 | |
| 151 | # ABI Library options --------------------------------------------------------- |
Louis Dionne | 83a5f58 | 2020-04-02 02:09:23 -0400 | [diff] [blame] | 152 | set(LIBCXX_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.") |
Eric Fiselier | 830c792 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 153 | set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 154 | set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) |
| 155 | |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 156 | # Setup the default options if LIBCXX_CXX_ABI is not specified. |
Eric Fiselier | b0da5fa | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 157 | if (LIBCXX_CXX_ABI STREQUAL "default") |
Shoaib Meenai | 4db0b0f | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 158 | if (LIBCXX_TARGETING_MSVC) |
| 159 | # FIXME: Figure out how to configure the ABI library on Windows. |
| 160 | set(LIBCXX_CXX_ABI_LIBNAME "vcruntime") |
Dimitry Andric | 2f4a111 | 2018-02-11 22:31:05 +0000 | [diff] [blame] | 161 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") |
| 162 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxrt") |
Louis Dionne | 83a5f58 | 2020-04-02 02:09:23 -0400 | [diff] [blame] | 163 | elseif (NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) |
| 164 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 165 | else() |
Shoaib Meenai | 4db0b0f | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 166 | set(LIBCXX_CXX_ABI_LIBNAME "default") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 167 | endif() |
| 168 | else() |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 169 | set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 170 | endif() |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 171 | |
Louis Dionne | 748a8b6 | 2019-03-18 18:18:01 +0000 | [diff] [blame] | 172 | option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY |
| 173 | "Use a static copy of the ABI library when linking libc++. |
| 174 | This option cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 175 | |
Petr Hosek | 416b1b6 | 2018-07-24 07:06:17 +0000 | [diff] [blame] | 176 | cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY |
| 177 | "Statically link the ABI library to static library" ON |
| 178 | "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) |
| 179 | |
| 180 | cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY |
| 181 | "Statically link the ABI library to shared library" ON |
Martin Storsjo | 1abf384 | 2018-08-14 17:33:10 +0000 | [diff] [blame] | 182 | "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF) |
Petr Hosek | 416b1b6 | 2018-07-24 07:06:17 +0000 | [diff] [blame] | 183 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 184 | # Generate and install a linker script inplace of libc++.so. The linker script |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 185 | # will link libc++ to the correct ABI library. This option is on by default |
Shoaib Meenai | f43645b | 2017-03-25 03:22:35 +0000 | [diff] [blame] | 186 | # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' |
Eric Fiselier | ea5fc6c | 2015-10-22 20:50:07 +0000 | [diff] [blame] | 187 | # is on. This option is also disabled when the ABI library is not specified |
| 188 | # or is specified to be "none". |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 189 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) |
Petr Hosek | 1647171 | 2018-07-26 05:10:24 +0000 | [diff] [blame] | 190 | if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 191 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" |
Eric Fiselier | b0da5fa | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 192 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" |
Asiri Rathnayake | 4fa5b8c | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 193 | AND PYTHONINTERP_FOUND |
| 194 | AND LIBCXX_ENABLE_SHARED) |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 195 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) |
| 196 | endif() |
| 197 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 198 | option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 199 | "Use and install a linker script for the given ABI library" |
Eric Fiselier | 16a3c82 | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 200 | ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 201 | |
Eric Fiselier | 95555c9 | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 202 | option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS |
| 203 | "Build libc++ with definitions for operator new/delete. This option can |
Louis Dionne | 1f99c1d | 2019-04-18 14:47:46 +0000 | [diff] [blame] | 204 | be used to disable the definitions when libc++abi is expected to provide |
| 205 | them" ON) |
Eric Fiselier | 95555c9 | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 206 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 207 | # Build libc++abi with libunwind. We need this option to determine whether to |
| 208 | # link with libunwind or libgcc_s while running the test cases. |
| 209 | option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) |
| 210 | |
| 211 | # Target options -------------------------------------------------------------- |
| 212 | option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) |
Petr Hosek | 6704f67 | 2019-02-04 20:02:26 +0000 | [diff] [blame] | 213 | set(LIBCXX_TARGET_TRIPLE "" CACHE STRING "Use alternate target triple.") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 214 | set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") |
| 215 | set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") |
| 216 | |
| 217 | # Feature options ------------------------------------------------------------- |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 218 | option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) |
| 219 | option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) |
Ed Schouten | 7009f4e | 2015-03-12 15:44:39 +0000 | [diff] [blame] | 220 | option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 221 | option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) |
| 222 | option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) |
Eric Fiselier | 5b9755b | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 223 | option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) |
Ed Schouten | 137c863 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 224 | option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) |
Eric Fiselier | 5b9755b | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 225 | option(LIBCXX_ENABLE_MONOTONIC_CLOCK |
| 226 | "Build libc++ with support for a monotonic clock. |
Jonathan Roelofs | b6a8286 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 227 | This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 228 | option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 229 | option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) |
Martin Storsjo | 8b25456 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 230 | option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF) |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 231 | option(LIBCXX_HAS_EXTERNAL_THREAD_API |
| 232 | "Build libc++ with an externalized threading API. |
| 233 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) |
Eric Fiselier | 2ba7b05 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 234 | option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY |
| 235 | "Build libc++ with an externalized threading library. |
| 236 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 237 | |
| 238 | # Misc options ---------------------------------------------------------------- |
Eric Fiselier | 62b5097 | 2015-10-10 03:34:52 +0000 | [diff] [blame] | 239 | # FIXME: Turn -pedantic back ON. It is currently off because it warns |
| 240 | # about #include_next which is used everywhere. |
| 241 | option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 242 | option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
Saleem Abdulrasool | be06cfe | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 243 | option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 244 | |
Eric Fiselier | bcd5d26 | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 245 | option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) |
| 246 | set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 247 | "The Profile-rt library used to build with code coverage") |
| 248 | |
Eric Fiselier | 68205ee | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 249 | # Don't allow a user to accidentally overwrite the system libc++ installation on Darwin. |
| 250 | # If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++ |
| 251 | # will not be generated and a warning will be issued. |
| 252 | option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF) |
| 253 | mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default. |
| 254 | |
| 255 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL) |
| 256 | if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") |
| 257 | message(WARNING "Disabling libc++ install rules because installation would " |
| 258 | "overwrite the systems installation. Configure with " |
| 259 | "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.") |
| 260 | mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option. |
| 261 | set(LIBCXX_INSTALL_HEADERS OFF) |
| 262 | set(LIBCXX_INSTALL_LIBRARY OFF) |
| 263 | endif() |
| 264 | endif() |
| 265 | |
Eric Fiselier | 884539e | 2015-12-16 23:41:05 +0000 | [diff] [blame] | 266 | set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) |
| 267 | if (XCODE OR MSVC_IDE) |
| 268 | set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) |
| 269 | endif() |
| 270 | option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" |
| 271 | ${LIBCXX_CONFIGURE_IDE_DEFAULT}) |
| 272 | |
Petr Hosek | b42e349 | 2019-01-06 06:14:31 +0000 | [diff] [blame] | 273 | option(LIBCXX_HERMETIC_STATIC_LIBRARY |
| 274 | "Do not export any symbols from the static library." OFF) |
| 275 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 276 | #=============================================================================== |
| 277 | # Check option configurations |
| 278 | #=============================================================================== |
| 279 | |
| 280 | # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when |
| 281 | # LIBCXX_ENABLE_THREADS is on. |
| 282 | if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) |
| 283 | message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" |
| 284 | " when LIBCXX_ENABLE_THREADS is also set to OFF.") |
Eric Fiselier | 2ff6e5a | 2014-08-18 05:03:46 +0000 | [diff] [blame] | 285 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 286 | |
Asiri Rathnayake | a375894 | 2017-01-03 12:59:50 +0000 | [diff] [blame] | 287 | if(NOT LIBCXX_ENABLE_THREADS) |
| 288 | if(LIBCXX_HAS_PTHREAD_API) |
| 289 | message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" |
| 290 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 291 | endif() |
| 292 | if(LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 293 | message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" |
| 294 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 295 | endif() |
Eric Fiselier | 2ba7b05 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 296 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 297 | message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " |
| 298 | "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 299 | endif() |
Martin Storsjo | 8b25456 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 300 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 301 | message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON" |
| 302 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 303 | endif() |
Eric Fiselier | 2ba7b05 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 304 | |
| 305 | endif() |
| 306 | |
Asiri Rathnayake | 35071df | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 307 | if (LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 308 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 309 | message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " |
| 310 | "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " |
| 311 | "the same time") |
| 312 | endif() |
| 313 | if (LIBCXX_HAS_PTHREAD_API) |
| 314 | message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" |
| 315 | "and LIBCXX_HAS_PTHREAD_API cannot be both" |
| 316 | "set to ON at the same time.") |
| 317 | endif() |
Martin Storsjo | 8b25456 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 318 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 319 | message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" |
| 320 | "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" |
| 321 | "set to ON at the same time.") |
| 322 | endif() |
| 323 | endif() |
| 324 | |
| 325 | if (LIBCXX_HAS_PTHREAD_API) |
| 326 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 327 | message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API" |
| 328 | "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" |
| 329 | "set to ON at the same time.") |
| 330 | endif() |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 331 | endif() |
| 332 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 333 | # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE |
| 334 | # is ON. |
| 335 | if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) |
| 336 | message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") |
| 337 | endif() |
| 338 | |
| 339 | # Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) |
| 340 | # and check that we can build with 32 bits if requested. |
| 341 | if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) |
| 342 | if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM |
| 343 | message(STATUS "Building 32 bits executables and libraries.") |
| 344 | endif() |
| 345 | elseif(LIBCXX_BUILD_32_BITS) |
| 346 | message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") |
| 347 | endif() |
| 348 | |
Louis Dionne | 116e137 | 2019-03-25 14:56:29 +0000 | [diff] [blame] | 349 | # Warn users that LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option. |
Eric Fiselier | 070ed9a | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 350 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
Louis Dionne | 116e137 | 2019-03-25 14:56:29 +0000 | [diff] [blame] | 351 | message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") |
Eric Fiselier | 55c1172 | 2016-11-18 19:53:45 +0000 | [diff] [blame] | 352 | if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND) |
| 353 | message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.") |
| 354 | endif() |
Eric Fiselier | 070ed9a | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 355 | endif() |
| 356 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 357 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 358 | if (APPLE) |
| 359 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") |
| 360 | endif() |
Asiri Rathnayake | 4fa5b8c | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 361 | if (NOT LIBCXX_ENABLE_SHARED) |
| 362 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") |
| 363 | endif() |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 364 | endif() |
| 365 | |
Petr Hosek | 1647171 | 2018-07-26 05:10:24 +0000 | [diff] [blame] | 366 | if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 367 | message(FATAL_ERROR "Conflicting options given. |
| 368 | LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with |
| 369 | LIBCXX_ENABLE_ABI_LINKER_SCRIPT") |
| 370 | endif() |
| 371 | |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 372 | if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) |
| 373 | message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off" |
| 374 | "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") |
| 375 | endif() |
| 376 | |
Shoaib Meenai | 56943f8 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 377 | if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) |
| 378 | message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") |
Shoaib Meenai | 69cebe7 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 379 | endif () |
| 380 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 381 | #=============================================================================== |
| 382 | # Configure System |
| 383 | #=============================================================================== |
| 384 | |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 385 | set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) |
| 386 | set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 387 | set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
Eric Fiselier | 830c792 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 388 | set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") |
Petr Hosek | 28e74cc | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 389 | |
| 390 | string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION |
| 391 | ${PACKAGE_VERSION}) |
| 392 | |
| 393 | if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) |
Petr Hosek | ee832ba | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 394 | set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) |
| 395 | set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) |
| 396 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) |
| 397 | if(LIBCXX_LIBDIR_SUBDIR) |
| 398 | string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) |
| 399 | string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) |
| 400 | endif() |
Petr Hosek | 28e74cc | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 401 | elseif(LLVM_LIBRARY_OUTPUT_INTDIR) |
Jonas Hahnfeld | 3627677 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 402 | set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) |
Petr Hosek | 72dd238 | 2018-07-24 15:49:29 +0000 | [diff] [blame] | 403 | set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) |
Petr Hosek | ee832ba | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 404 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) |
Jonas Hahnfeld | 3627677 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 405 | else() |
| 406 | set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) |
Petr Hosek | ee832ba | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 407 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) |
Jonas Hahnfeld | 3627677 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 408 | endif() |
Petr Hosek | 28e74cc | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 409 | |
Eric Fiselier | 830c792 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 410 | file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 411 | |
Petr Hosek | ee832ba | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 412 | set(LIBCXX_INSTALL_PREFIX "" CACHE STRING "Define libc++ destination prefix.") |
| 413 | set(LIBCXX_INSTALL_HEADER_PREFIX "" CACHE STRING "Define libc++ header destination prefix.") |
Petr Hosek | 3975d8d | 2017-07-11 02:39:50 +0000 | [diff] [blame] | 414 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 415 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
| 416 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Shoaib Meenai | c2d2a96 | 2017-04-13 16:27:38 +0000 | [diff] [blame] | 417 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 418 | |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 419 | # Declare libc++ configuration variables. |
| 420 | # They are intended for use as follows: |
| 421 | # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. |
| 422 | # LIBCXX_COMPILE_FLAGS: Compile only flags. |
| 423 | # LIBCXX_LINK_FLAGS: Linker only flags. |
Eric Fiselier | cdb497b | 2016-10-09 21:34:03 +0000 | [diff] [blame] | 424 | # LIBCXX_LIBRARIES: libraries libc++ is linked to. |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 425 | set(LIBCXX_COMPILE_FLAGS "") |
| 426 | set(LIBCXX_LINK_FLAGS "") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 427 | set(LIBCXX_LIBRARIES "") |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 428 | |
Eric Fiselier | 96addd3 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 429 | # Include macros for adding and removing libc++ flags. |
| 430 | include(HandleLibcxxFlags) |
| 431 | |
| 432 | # Target flags ================================================================ |
| 433 | # These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that |
| 434 | # 'config-ix' use them during feature checks. It also adds them to both |
| 435 | # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' |
| 436 | add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") |
Petr Hosek | 6704f67 | 2019-02-04 20:02:26 +0000 | [diff] [blame] | 437 | |
| 438 | if(LIBCXX_TARGET_TRIPLE) |
| 439 | add_target_flags("--target=${LIBCXX_TARGET_TRIPLE}") |
| 440 | elseif(CMAKE_CXX_COMPILER_TARGET) |
| 441 | set(LIBCXX_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") |
| 442 | endif() |
| 443 | if(LIBCXX_SYSROOT) |
| 444 | add_target_flags("--sysroot=${LIBCXX_SYSROOT}") |
| 445 | elseif(CMAKE_SYSROOT) |
| 446 | set(LIBCXX_SYSROOT "${CMAKE_SYSROOT}") |
| 447 | endif() |
| 448 | if(LIBCXX_GCC_TOOLCHAIN) |
| 449 | add_target_flags("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") |
| 450 | elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) |
| 451 | set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") |
| 452 | endif() |
| 453 | |
| 454 | if(LIBCXX_TARGET_TRIPLE) |
Eric Fiselier | 7e1226e | 2016-11-13 22:27:00 +0000 | [diff] [blame] | 455 | set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") |
| 456 | endif() |
Eric Fiselier | 96addd3 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 457 | |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 458 | # Configure compiler. |
| 459 | include(config-ix) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 460 | |
Eric Fiselier | bcd5d26 | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 461 | # Configure coverage options. |
| 462 | if (LIBCXX_GENERATE_COVERAGE) |
| 463 | include(CodeCoverage) |
| 464 | set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) |
| 465 | endif() |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 466 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 467 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
Eric Fiselier | c01ae75 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 468 | if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") |
| 469 | set(LIBCXX_DEBUG_BUILD ON) |
| 470 | else() |
| 471 | set(LIBCXX_DEBUG_BUILD OFF) |
| 472 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 473 | |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 474 | #=============================================================================== |
| 475 | # Setup Compiler Flags |
| 476 | #=============================================================================== |
| 477 | |
JF Bastien | bffc6cf | 2016-03-05 14:22:02 +0000 | [diff] [blame] | 478 | include(HandleLibCXXABI) # Setup the ABI library flags |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 479 | |
Michal Gorny | 349b552 | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 480 | if (NOT LIBCXX_STANDALONE_BUILD) |
| 481 | # Remove flags that may have snuck in. |
| 482 | remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG |
Eric Fiselier | 5938391 | 2017-01-17 23:27:56 +0000 | [diff] [blame] | 483 | -lc++abi) |
Michal Gorny | 349b552 | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 484 | endif() |
| 485 | remove_flags(-stdlib=libc++ -stdlib=libstdc++) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 486 | |
Eric Fiselier | 1e6fdc0 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 487 | # FIXME: Remove all debug flags and flags that change which Windows |
| 488 | # default libraries are linked. Currently we only support linking the |
| 489 | # non-debug DLLs |
Eric Fiselier | c01ae75 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 490 | remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") |
Eric Fiselier | 1e6fdc0 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 491 | |
Shoaib Meenai | 8ab5635 | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 492 | # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. |
Eric Fiselier | cadda54 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 493 | # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors |
Shoaib Meenai | 8ab5635 | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 494 | # so they don't get transformed into -Wno and -errors respectively. |
Eric Fiselier | cadda54 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 495 | remove_flags(-Wno-pedantic -pedantic-errors -pedantic) |
Eric Fiselier | 25426b9 | 2015-10-13 23:56:33 +0000 | [diff] [blame] | 496 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 497 | # Required flags ============================================================== |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 498 | function(cxx_add_basic_build_flags target) |
Eric Fiselier | 7132bfb | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 499 | |
Louis Dionne | 6bd2edf | 2020-03-24 22:53:47 -0400 | [diff] [blame] | 500 | # Require C++14 for all targets. C++14 is needed to ensure constant |
| 501 | # initialization for certain globals (ex global memory resources). |
Eric Fiselier | 7132bfb | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 502 | set_target_properties(${target} PROPERTIES |
Louis Dionne | 6bd2edf | 2020-03-24 22:53:47 -0400 | [diff] [blame] | 503 | CXX_STANDARD 14 |
Eric Fiselier | 7132bfb | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 504 | CXX_STANDARD_REQUIRED YES |
| 505 | CXX_EXTENSIONS NO) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 506 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 507 | # On all systems the system c++ standard library headers need to be excluded. |
| 508 | # MSVC only has -X, which disables all default includes; including the crt. |
| 509 | # Thus, we do nothing and hope we don't accidentally include any of the C++ |
| 510 | # headers |
| 511 | target_add_compile_flags_if_supported(${target} PUBLIC -nostdinc++) |
Eric Fiselier | 285e796 | 2015-07-29 21:07:28 +0000 | [diff] [blame] | 512 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 513 | # Hide all inline function definitions which have not explicitly been marked |
| 514 | # visible. This prevents new definitions for inline functions from appearing in |
| 515 | # the dylib when get ODR used by another function. |
| 516 | target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility-inlines-hidden) |
Eric Fiselier | 155ce85 | 2016-10-25 19:43:44 +0000 | [diff] [blame] | 517 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 518 | # Our visibility annotations are not quite right for non-Clang compilers, |
| 519 | # so we end up not exporting all the symbols we should. In the future, we |
| 520 | # can improve the situation by providing an explicit list of exported |
| 521 | # symbols on all compilers. |
| 522 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 523 | target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden) |
| 524 | endif() |
Eric Fiselier | 082eeb2 | 2017-05-25 04:36:24 +0000 | [diff] [blame] | 525 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 526 | if (LIBCXX_CONFIGURE_IDE) |
| 527 | # This simply allows IDE to process <experimental/coroutine> |
| 528 | target_add_compile_flags_if_supported(${target} PRIVATE -fcoroutines-ts) |
| 529 | endif() |
Eric Fiselier | 815ed73 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 530 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 531 | # Let the library headers know they are currently being used to build the |
| 532 | # library. |
| 533 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY) |
Eric Fiselier | 95555c9 | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 534 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 535 | if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) |
| 536 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) |
| 537 | endif() |
| 538 | |
| 539 | if (LIBCXX_HAS_COMMENT_LIB_PRAGMA) |
Michał Górny | 8d676fb | 2019-12-02 11:49:20 +0100 | [diff] [blame] | 540 | if (LIBCXX_HAS_PTHREAD_LIB) |
| 541 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB) |
| 542 | endif() |
| 543 | if (LIBCXX_HAS_RT_LIB) |
| 544 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB) |
| 545 | endif() |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 546 | endif() |
| 547 | endfunction() |
Petr Hosek | 10ed428 | 2019-05-30 04:40:21 +0000 | [diff] [blame] | 548 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 549 | # Warning flags =============================================================== |
Louis Dionne | 1dfc21e | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 550 | function(cxx_add_warning_flags target) |
| 551 | target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 552 | target_add_compile_flags_if_supported(${target} PRIVATE -Wall -Wextra -W -Wwrite-strings |
| 553 | -Wno-unused-parameter -Wno-long-long |
| 554 | -Werror=return-type -Wextra-semi) |
| 555 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 556 | target_add_compile_flags_if_supported(${target} PRIVATE |
| 557 | -Wno-user-defined-literals |
| 558 | -Wno-covered-switch-default |
| 559 | -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs |
| 560 | ) |
Eric Fiselier | 69850ae | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 561 | if (LIBCXX_TARGETING_CLANG_CL) |
Louis Dionne | 1dfc21e | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 562 | target_add_compile_flags_if_supported(${target} PRIVATE |
Eric Fiselier | 69850ae | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 563 | -Wno-c++98-compat |
Eric Fiselier | b26c2fe | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 564 | -Wno-c++98-compat-pedantic |
Eric Fiselier | 69850ae | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 565 | -Wno-c++11-compat |
| 566 | -Wno-undef |
Eric Fiselier | b26c2fe | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 567 | -Wno-reserved-id-macro |
| 568 | -Wno-gnu-include-next |
| 569 | -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings |
Eric Fiselier | 3d0fbb1 | 2018-10-01 01:47:23 +0000 | [diff] [blame] | 570 | -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences. |
| 571 | -Wno-deprecated-dynamic-exception-spec # For auto_ptr |
| 572 | -Wno-sign-conversion |
| 573 | -Wno-old-style-cast |
| 574 | -Wno-deprecated # FIXME: Remove this and fix all occurrences. |
Eric Fiselier | b41db9a | 2018-10-01 01:59:37 +0000 | [diff] [blame] | 575 | -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang? |
Eric Fiselier | cb4e2f8 | 2018-10-01 03:59:05 +0000 | [diff] [blame] | 576 | -Wno-double-promotion # FIXME: remove me |
Eric Fiselier | 69850ae | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 577 | ) |
| 578 | endif() |
Louis Dionne | 1dfc21e | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 579 | elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") |
| 580 | target_add_compile_flags_if_supported(${target} PRIVATE |
| 581 | -Wno-literal-suffix |
| 582 | -Wno-c++14-compat |
| 583 | -Wno-noexcept-type) |
| 584 | endif() |
| 585 | if (LIBCXX_ENABLE_WERROR) |
| 586 | target_add_compile_flags_if_supported(${target} PRIVATE -Werror) |
| 587 | target_add_compile_flags_if_supported(${target} PRIVATE -WX) |
| 588 | else() |
| 589 | # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is |
| 590 | # added elsewhere. |
| 591 | target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error) |
| 592 | endif() |
| 593 | if (LIBCXX_ENABLE_PEDANTIC) |
| 594 | target_add_compile_flags_if_supported(${target} PRIVATE -pedantic) |
| 595 | endif() |
| 596 | if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 597 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 598 | endif() |
| 599 | endfunction() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 600 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 601 | # Exception flags ============================================================= |
Louis Dionne | 7e4dcd5 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 602 | function(cxx_add_exception_flags target) |
| 603 | if (LIBCXX_ENABLE_EXCEPTIONS) |
| 604 | # Catches C++ exceptions only and tells the compiler to assume that extern C |
| 605 | # functions never throw a C++ exception. |
| 606 | target_add_compile_flags_if_supported(${target} PUBLIC -EHsc) |
| 607 | else() |
| 608 | target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_EXCEPTIONS) |
| 609 | target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-) |
| 610 | target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions) |
| 611 | endif() |
| 612 | endfunction() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 613 | |
| 614 | # RTTI flags ================================================================== |
Louis Dionne | 7e4dcd5 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 615 | function(cxx_add_rtti_flags target) |
| 616 | if (NOT LIBCXX_ENABLE_RTTI) |
| 617 | target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_RTTI) |
| 618 | target_add_compile_flags_if_supported(${target} PUBLIC -GR-) |
| 619 | target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti) |
| 620 | endif() |
| 621 | endfunction() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 622 | |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 623 | # Threading flags ============================================================= |
Asiri Rathnayake | 35071df | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 624 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 625 | # Need to allow unresolved symbols if this is to work with shared library builds |
| 626 | if (APPLE) |
| 627 | add_link_flags("-undefined dynamic_lookup") |
| 628 | else() |
| 629 | # Relax this restriction from HandleLLVMOptions |
| 630 | string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") |
| 631 | endif() |
| 632 | endif() |
| 633 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 634 | # Assertion flags ============================================================= |
| 635 | define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) |
| 636 | define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) |
Eric Fiselier | 59cd98b | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 637 | define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) |
Eric Fiselier | c01ae75 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 638 | define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) |
| 639 | if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 640 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
Eric Fiselier | 1e6fdc0 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 641 | define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) |
Howard Hinnant | 807d633 | 2013-02-25 15:50:36 +0000 | [diff] [blame] | 642 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 643 | |
Eric Fiselier | 4a29a11 | 2016-10-14 12:56:52 +0000 | [diff] [blame] | 644 | # Modules flags =============================================================== |
| 645 | # FIXME The libc++ sources are fundamentally non-modular. They need special |
| 646 | # versions of the headers in order to provide C++03 and legacy ABI definitions. |
| 647 | # NOTE: The public headers can be used with modules in all other contexts. |
Louis Dionne | 7e4dcd5 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 648 | function(cxx_add_module_flags target) |
| 649 | if (LLVM_ENABLE_MODULES) |
| 650 | # Ignore that the rest of the modules flags are now unused. |
Louis Dionne | 82e5d75 | 2019-10-04 19:10:56 +0000 | [diff] [blame] | 651 | target_add_compile_flags_if_supported(${target} PUBLIC -Wno-unused-command-line-argument) |
| 652 | target_compile_options(${target} PUBLIC -fno-modules) |
Louis Dionne | 7e4dcd5 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 653 | endif() |
| 654 | endfunction() |
Eric Fiselier | 4a29a11 | 2016-10-14 12:56:52 +0000 | [diff] [blame] | 655 | |
Jonathan Roelofs | b6a8286 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 656 | # Sanitizer flags ============================================================= |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 657 | |
Eric Fiselier | 1116a82 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 658 | function(get_sanitizer_flags OUT_VAR USE_SANITIZER) |
| 659 | set(SANITIZER_FLAGS) |
| 660 | set(USE_SANITIZER "${USE_SANITIZER}") |
| 661 | # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. |
| 662 | # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. |
| 663 | if (USE_SANITIZER AND NOT MSVC) |
| 664 | append_flags_if_supported(SANITIZER_FLAGS "-fno-omit-frame-pointer") |
| 665 | append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") |
| 666 | |
| 667 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND |
| 668 | NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") |
| 669 | append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") |
| 670 | endif() |
| 671 | if (USE_SANITIZER STREQUAL "Address") |
| 672 | append_flags(SANITIZER_FLAGS "-fsanitize=address") |
| 673 | elseif (USE_SANITIZER MATCHES "Memory(WithOrigins)?") |
| 674 | append_flags(SANITIZER_FLAGS -fsanitize=memory) |
| 675 | if (USE_SANITIZER STREQUAL "MemoryWithOrigins") |
| 676 | append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins") |
| 677 | endif() |
| 678 | elseif (USE_SANITIZER STREQUAL "Undefined") |
| 679 | append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Brian Gesiak | b2741bd | 2020-04-04 13:01:32 -0400 | [diff] [blame] | 680 | elseif (USE_SANITIZER STREQUAL "Address;Undefined" OR |
| 681 | USE_SANITIZER STREQUAL "Undefined;Address") |
| 682 | append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Eric Fiselier | 1116a82 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 683 | elseif (USE_SANITIZER STREQUAL "Thread") |
| 684 | append_flags(SANITIZER_FLAGS -fsanitize=thread) |
Zola Bridges | 381ede3 | 2020-04-17 10:15:58 -0700 | [diff] [blame^] | 685 | elseif (USE_SANITIZER STREQUAL "DataFlow") |
| 686 | append_flags(SANITIZER_FLAGS -fsanitize=dataflow) |
Eric Fiselier | 1116a82 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 687 | else() |
| 688 | message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${USE_SANITIZER}") |
| 689 | endif() |
| 690 | elseif(USE_SANITIZER AND MSVC) |
| 691 | message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") |
| 692 | endif() |
| 693 | set(${OUT_VAR} "${SANITIZER_FLAGS}" PARENT_SCOPE) |
| 694 | endfunction() |
| 695 | |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 696 | # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 697 | # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 698 | if (LIBCXX_STANDALONE_BUILD) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 699 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 700 | "Define the sanitizer used to build the library and tests") |
Eric Fiselier | 1116a82 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 701 | endif() |
| 702 | get_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}") |
| 703 | if (LIBCXX_STANDALONE_BUILD AND SANITIZER_FLAGS) |
| 704 | add_flags(${SANITIZER_FLAGS}) |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 705 | endif() |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 706 | |
Louis Dionne | 51e50d5 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 707 | # Link system libraries ======================================================= |
| 708 | function(cxx_link_system_libraries target) |
| 709 | target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") |
| 710 | target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") |
| 711 | target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") |
| 712 | |
| 713 | if (LIBCXX_HAS_SYSTEM_LIB) |
| 714 | target_link_libraries(${target} PRIVATE System) |
| 715 | endif() |
| 716 | |
| 717 | if (LIBCXX_HAS_PTHREAD_LIB) |
| 718 | target_link_libraries(${target} PRIVATE pthread) |
| 719 | endif() |
| 720 | |
| 721 | if (LIBCXX_HAS_C_LIB) |
| 722 | target_link_libraries(${target} PRIVATE c) |
| 723 | endif() |
| 724 | |
| 725 | if (LIBCXX_HAS_M_LIB) |
| 726 | target_link_libraries(${target} PRIVATE m) |
| 727 | endif() |
| 728 | |
| 729 | if (LIBCXX_HAS_RT_LIB) |
| 730 | target_link_libraries(${target} PRIVATE rt) |
| 731 | endif() |
| 732 | |
| 733 | if (LIBCXX_USE_COMPILER_RT) |
| 734 | find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) |
| 735 | if (LIBCXX_BUILTINS_LIBRARY) |
| 736 | target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}") |
| 737 | endif() |
| 738 | elseif (LIBCXX_HAS_GCC_S_LIB) |
| 739 | target_link_libraries(${target} PRIVATE gcc_s) |
| 740 | endif() |
| 741 | |
| 742 | if (LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) |
| 743 | target_link_libraries(${target} PRIVATE atomic) |
| 744 | endif() |
| 745 | |
| 746 | if (MINGW) |
| 747 | target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}") |
| 748 | endif() |
| 749 | |
| 750 | if (LIBCXX_TARGETING_MSVC) |
| 751 | if (LIBCXX_DEBUG_BUILD) |
| 752 | set(LIB_SUFFIX "d") |
| 753 | else() |
| 754 | set(LIB_SUFFIX "") |
| 755 | endif() |
| 756 | |
| 757 | target_link_libraries(${target} PRIVATE ucrt${LIB_SUFFIX}) # Universal C runtime |
| 758 | target_link_libraries(${target} PRIVATE vcruntime${LIB_SUFFIX}) # C++ runtime |
| 759 | target_link_libraries(${target} PRIVATE msvcrt${LIB_SUFFIX}) # C runtime startup files |
| 760 | target_link_libraries(${target} PRIVATE msvcprt${LIB_SUFFIX}) # C++ standard library. Required for exception_ptr internals. |
| 761 | # Required for standards-complaint wide character formatting functions |
| 762 | # (e.g. `printfw`/`scanfw`) |
| 763 | target_link_libraries(${target} PRIVATE iso_stdio_wide_specifiers) |
| 764 | endif() |
Shoaib Meenai | 338305c | 2020-01-27 17:29:41 -0800 | [diff] [blame] | 765 | |
| 766 | if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21) |
| 767 | target_link_libraries(${target} PUBLIC android_support) |
| 768 | endif() |
Louis Dionne | 51e50d5 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 769 | endfunction() |
| 770 | |
Louis Dionne | 5dbc35f | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 771 | # Windows-related flags ======================================================= |
| 772 | function(cxx_add_windows_flags target) |
| 773 | if(WIN32 AND NOT MINGW) |
| 774 | target_compile_definitions(${target} PRIVATE |
| 775 | # Ignore the -MSC_VER mismatch, as we may build |
| 776 | # with a different compatibility version. |
| 777 | _ALLOW_MSC_VER_MISMATCH |
| 778 | # Don't check the msvcprt iterator debug levels |
| 779 | # as we will define the iterator types; libc++ |
| 780 | # uses a different macro to identify the debug |
| 781 | # level. |
| 782 | _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH |
| 783 | # We are building the c++ runtime, don't pull in |
| 784 | # msvcprt. |
| 785 | _CRTBLD |
| 786 | # Don't warn on the use of "deprecated" |
| 787 | # "insecure" functions which are standards |
| 788 | # specified. |
| 789 | _CRT_SECURE_NO_WARNINGS |
| 790 | # Use the ISO conforming behaviour for conversion |
| 791 | # in printf, scanf. |
| 792 | _CRT_STDIO_ISO_WIDE_SPECIFIERS) |
| 793 | endif() |
| 794 | endfunction() |
| 795 | |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 796 | # Configuration file flags ===================================================== |
Louis Dionne | 0e445c0 | 2018-09-26 08:24:51 +0000 | [diff] [blame] | 797 | if (NOT LIBCXX_ABI_VERSION EQUAL 1) |
Evgeniy Stepanov | da2ff7e | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 798 | config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) |
| 799 | endif() |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 800 | if (NOT LIBCXX_ABI_NAMESPACE STREQUAL "") |
| 801 | if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*") |
Louis Dionne | 09c7044 | 2019-10-24 14:16:37 -0700 | [diff] [blame] | 802 | message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier.") |
Eric Fiselier | b33778a | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 803 | endif() |
| 804 | if (LIBCXX_ABI_NAMESPACE MATCHES "__[0-9]+$") |
| 805 | message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE '${LIBCXX_ABI_NAMESPACE}' is reserved for use by libc++.") |
| 806 | endif() |
| 807 | config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE) |
| 808 | endif() |
Evgeniy Stepanov | da2ff7e | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 809 | config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) |
Shoaib Meenai | 56943f8 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 810 | config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM) |
| 811 | config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT) |
Louis Dionne | 1821de4 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 812 | config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT) |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 813 | config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) |
| 814 | config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) |
| 815 | config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) |
| 816 | config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) |
| 817 | config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) |
| 818 | config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) |
Eric Fiselier | f356629 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 819 | if (NOT LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT STREQUAL "") |
| 820 | config_define("${LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT}" _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT) |
| 821 | endif() |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 822 | |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 823 | config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) |
Asiri Rathnayake | 94340d2 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 824 | config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) |
Martin Storsjo | 8b25456 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 825 | config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32) |
Eric Fiselier | 2ba7b05 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 826 | config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 827 | config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) |
Shoaib Meenai | cfd1960 | 2017-10-09 19:25:17 +0000 | [diff] [blame] | 828 | config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) |
Louis Dionne | 59d0b3c | 2019-08-05 18:29:14 +0000 | [diff] [blame] | 829 | config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITHMS) |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 830 | |
Shoaib Meenai | 4ca4b7c | 2017-10-04 23:17:12 +0000 | [diff] [blame] | 831 | if (LIBCXX_ABI_DEFINES) |
| 832 | set(abi_defines) |
| 833 | foreach (abi_define ${LIBCXX_ABI_DEFINES}) |
| 834 | if (NOT abi_define MATCHES "^_LIBCPP_ABI_") |
| 835 | message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES") |
| 836 | endif() |
| 837 | list(APPEND abi_defines "#define ${abi_define}") |
| 838 | endforeach() |
| 839 | string(REPLACE ";" "\n" abi_defines "${abi_defines}") |
| 840 | config_define(${abi_defines} _LIBCPP_ABI_DEFINES) |
| 841 | endif() |
| 842 | |
Eric Fiselier | 51e8d2f | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 843 | # By default libc++ on Windows expects to use a shared library, which requires |
| 844 | # the headers to use DLL import/export semantics. However when building a |
| 845 | # static library only we modify the headers to disable DLL import/export. |
| 846 | if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) |
| 847 | message(STATUS "Generating custom __config for non-DLL Windows build") |
Shoaib Meenai | f36e988 | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 848 | config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Eric Fiselier | 51e8d2f | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 849 | endif() |
| 850 | |
Shoaib Meenai | 53bc968 | 2017-09-14 18:23:43 +0000 | [diff] [blame] | 851 | set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site") |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 852 | if (LIBCXX_NEEDS_SITE_CONFIG) |
Saleem Abdulrasool | a556397 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 853 | configure_file("include/__config_site.in" |
Shoaib Meenai | 53bc968 | 2017-09-14 18:23:43 +0000 | [diff] [blame] | 854 | "${site_config_path}" |
Saleem Abdulrasool | a556397 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 855 | @ONLY) |
Louis Dionne | 053059a | 2019-10-03 17:20:50 +0000 | [diff] [blame] | 856 | elseif(EXISTS "${site_config_path}") |
| 857 | message(STATUS "Removing stale site configuration ${site_config_path}") |
| 858 | file(REMOVE "${site_config_path}") |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 859 | endif() |
| 860 | |
Louis Dionne | 053059a | 2019-10-03 17:20:50 +0000 | [diff] [blame] | 861 | function(cxx_add_config_site target) |
| 862 | if (LIBCXX_NEEDS_SITE_CONFIG) |
| 863 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") |
Petr Hosek | b9487d8 | 2020-01-27 19:28:59 -0800 | [diff] [blame] | 864 | target_compile_options(${target} PUBLIC /FI "${site_config_path}") |
Louis Dionne | 053059a | 2019-10-03 17:20:50 +0000 | [diff] [blame] | 865 | else() |
Louis Dionne | 8edc59b | 2019-11-18 16:27:42 -0500 | [diff] [blame] | 866 | target_compile_options(${target} PUBLIC -include "${site_config_path}") |
Louis Dionne | 053059a | 2019-10-03 17:20:50 +0000 | [diff] [blame] | 867 | endif() |
| 868 | endif() |
| 869 | endfunction() |
| 870 | |
Louis Dionne | 69e5bc7 | 2019-10-04 22:50:23 +0000 | [diff] [blame] | 871 | # Setup all common build flags ================================================= |
| 872 | function(cxx_add_common_build_flags target) |
| 873 | cxx_add_basic_build_flags(${target}) |
| 874 | cxx_add_warning_flags(${target}) |
| 875 | cxx_add_windows_flags(${target}) |
| 876 | cxx_add_config_site(${target}) |
| 877 | cxx_add_exception_flags(${target}) |
| 878 | cxx_add_rtti_flags(${target}) |
| 879 | cxx_add_module_flags(${target}) |
Louis Dionne | 51e50d5 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 880 | cxx_link_system_libraries(${target}) |
Louis Dionne | 69e5bc7 | 2019-10-04 22:50:23 +0000 | [diff] [blame] | 881 | endfunction() |
| 882 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 883 | #=============================================================================== |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 884 | # Setup Source Code And Tests |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 885 | #=============================================================================== |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 886 | include_directories(include) |
Howard Hinnant | 6e207d5 | 2013-11-15 17:18:57 +0000 | [diff] [blame] | 887 | add_subdirectory(include) |
Petr Hosek | 5becd8c | 2019-05-01 06:40:36 +0000 | [diff] [blame] | 888 | add_subdirectory(src) |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 889 | |
Eric Fiselier | 453bc18 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 890 | set(LIBCXX_TEST_DEPS "") |
| 891 | |
| 892 | if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
| 893 | list(APPEND LIBCXX_TEST_DEPS cxx_experimental) |
| 894 | endif() |
Eric Fiselier | 453bc18 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 895 | |
| 896 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 897 | list(APPEND LIBCXX_TEST_DEPS cxx_external_threads) |
| 898 | endif() |
Eric Fiselier | 95353d5 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 899 | |
Eric Fiselier | 9e3e137 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 900 | if (LIBCXX_INCLUDE_BENCHMARKS) |
| 901 | add_subdirectory(benchmarks) |
| 902 | endif() |
Eric Fiselier | a1d7f92 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 903 | |
| 904 | # Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or |
| 905 | # LLVM_FOUND is OFF. This allows users to run the tests manually using |
| 906 | # LIT without requiring a full LLVM checkout. |
Duncan P. N. Exon Smith | 4809488 | 2017-05-03 23:33:54 +0000 | [diff] [blame] | 907 | # |
| 908 | # However, since some submission systems strip test/ subdirectories, check for |
| 909 | # it before adding it. |
Zachary Turner | e6c9670 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 910 | |
Duncan P. N. Exon Smith | 4809488 | 2017-05-03 23:33:54 +0000 | [diff] [blame] | 911 | if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test") |
| 912 | add_subdirectory(test) |
| 913 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 914 | if (LIBCXX_INCLUDE_TESTS) |
Eric Fiselier | 95353d5 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 915 | add_subdirectory(lib/abi) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 916 | endif() |
Eric Fiselier | a1d7f92 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 917 | |
Zachary Turner | e6c9670 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 918 | if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit") |
Petr Hosek | 864b575 | 2017-12-01 03:16:50 +0000 | [diff] [blame] | 919 | include(AddLLVM) # for get_llvm_lit_path |
Zachary Turner | e6c9670 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 920 | # Make sure the llvm-lit script is generated into the bin directory, and do |
| 921 | # it after adding all tests, since the generated script will only work |
| 922 | # correctly discovered tests against test locations from the source tree that |
| 923 | # have already been discovered. |
| 924 | add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit |
| 925 | ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) |
| 926 | endif() |
| 927 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 928 | if (LIBCXX_INCLUDE_DOCS) |
| 929 | add_subdirectory(docs) |
| 930 | endif() |