Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | # See www/CMake.html for instructions on how to build libcxx with CMake. |
Eric Fiselier | 74abe0b | 2017-05-04 06:28:34 +0000 | [diff] [blame] | 2 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 3 | #=============================================================================== |
| 4 | # Setup Project |
| 5 | #=============================================================================== |
Chris Bieneman | cad86ff | 2016-05-31 20:21:52 +0000 | [diff] [blame] | 6 | cmake_minimum_required(VERSION 3.4.3) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 7 | |
Eric Fiselier | e9d4b23 | 2015-01-26 21:56:45 +0000 | [diff] [blame] | 8 | if(POLICY CMP0042) |
| 9 | cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default |
| 10 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 11 | if(POLICY CMP0022) |
| 12 | cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang |
| 13 | endif() |
| 14 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 15 | # Add path for custom modules |
| 16 | set(CMAKE_MODULE_PATH |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 17 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 18 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
Eric Fiselier | ce5695f | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 19 | ${CMAKE_MODULE_PATH} |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 20 | ) |
| 21 | |
Eric Fiselier | 5e000c6 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 22 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
Saleem Abdulrasool | 7adfa03 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 23 | project(libcxx CXX C) |
| 24 | |
| 25 | set(PACKAGE_NAME libcxx) |
Hans Wennborg | 12ab658 | 2017-07-19 13:57:10 +0000 | [diff] [blame] | 26 | set(PACKAGE_VERSION 6.0.0svn) |
Saleem Abdulrasool | 7adfa03 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 27 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 28 | set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") |
Eric Fiselier | 5e000c6 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 29 | |
| 30 | # Find the LLVM sources and simulate LLVM CMake options. |
| 31 | include(HandleOutOfTreeLLVM) |
Eugene Zelenko | 96f1017 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 32 | endif() |
Saleem Abdulrasool | 7adfa03 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 33 | |
Petr Hosek | 3508e7a | 2017-01-16 00:33:07 +0000 | [diff] [blame] | 34 | if (LIBCXX_STANDALONE_BUILD) |
| 35 | include(FindPythonInterp) |
| 36 | if( NOT PYTHONINTERP_FOUND ) |
| 37 | message(WARNING "Failed to find python interpreter. " |
| 38 | "The libc++ test suite will be disabled.") |
| 39 | set(LLVM_INCLUDE_TESTS OFF) |
| 40 | endif() |
| 41 | endif() |
| 42 | |
Saleem Abdulrasool | 7adfa03 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 43 | # Require out of source build. |
| 44 | include(MacroEnsureOutOfSourceBuild) |
| 45 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( |
| 46 | "${PROJECT_NAME} requires an out of source build. Please create a separate |
| 47 | build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." |
| 48 | ) |
| 49 | |
Eric Fiselier | fdd3c91 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 50 | if (MSVC) |
| 51 | set(LIBCXX_TARGETING_MSVC ON) |
| 52 | else() |
| 53 | set(LIBCXX_TARGETING_MSVC OFF) |
| 54 | endif() |
| 55 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 56 | #=============================================================================== |
| 57 | # Setup CMake Options |
| 58 | #=============================================================================== |
Eric Fiselier | 01609af | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 59 | include(CMakeDependentOption) |
Eric Fiselier | c51e0d2 | 2017-03-11 03:24:18 +0000 | [diff] [blame] | 60 | include(HandleCompilerRT) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 61 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 62 | # Basic options --------------------------------------------------------------- |
Eric Fiselier | b89eba0 | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 63 | option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 64 | option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 65 | option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 66 | option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) |
Eric Fiselier | 5bf8bed | 2017-04-20 04:24:29 +0000 | [diff] [blame] | 67 | set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) |
| 68 | if (WIN32) |
| 69 | set(ENABLE_FILESYSTEM_DEFAULT OFF) |
| 70 | endif() |
| 71 | option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a" |
| 72 | ${ENABLE_FILESYSTEM_DEFAULT}) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 73 | option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) |
Eric Fiselier | 2d2f0c0 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 74 | |
Eric Fiselier | 2d2f0c0 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 75 | # Benchmark options ----------------------------------------------------------- |
Eric Fiselier | 0a799bd | 2016-08-29 19:50:49 +0000 | [diff] [blame] | 76 | option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON) |
Eric Fiselier | 2d2f0c0 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 77 | set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING |
| 78 | "Build the benchmarks against the specified native STL. |
| 79 | The value must be one of libc++/libstdc++") |
| 80 | set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING |
| 81 | "Use alternate GCC toolchain when building the native benchmarks") |
| 82 | |
| 83 | if (LIBCXX_BENCHMARK_NATIVE_STDLIB) |
| 84 | if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" |
| 85 | OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) |
| 86 | message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " |
| 87 | "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") |
| 88 | endif() |
| 89 | endif() |
| 90 | |
Eric Fiselier | b9f425a | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 91 | option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 92 | set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING |
| 93 | "Define suffix of library directory name (32/64)") |
| 94 | option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 95 | option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 96 | option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) |
Eric Fiselier | 01609af | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 97 | cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY |
| 98 | "Install libc++experimental.a" ON |
| 99 | "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) |
Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 100 | set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.") |
| 101 | option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) |
Saleem Abdulrasool | e146f75 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 102 | option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 103 | |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 104 | if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC) |
| 105 | message(FATAL_ERROR "libc++ must be built as either a shared or static library.") |
| 106 | endif() |
| 107 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 108 | # ABI Library options --------------------------------------------------------- |
Eric Fiselier | cfc5515 | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 109 | set(LIBCXX_CXX_ABI "default" CACHE STRING |
| 110 | "Specify C++ ABI library to use.") |
Eric Fiselier | bde2871 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 111 | set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 112 | set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) |
| 113 | |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 114 | # Setup the default options if LIBCXX_CXX_ABI is not specified. |
Eric Fiselier | cfc5515 | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 115 | if (LIBCXX_CXX_ABI STREQUAL "default") |
Petr Hosek | d842fed | 2016-11-09 03:22:28 +0000 | [diff] [blame] | 116 | find_path( |
| 117 | LIBCXX_LIBCXXABI_INCLUDES_INTERNAL |
| 118 | cxxabi.h |
| 119 | PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include |
| 120 | ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include |
Reid Kleckner | bfe423e | 2017-06-20 20:34:13 +0000 | [diff] [blame] | 121 | ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include |
Petr Hosek | d842fed | 2016-11-09 03:22:28 +0000 | [diff] [blame] | 122 | NO_DEFAULT_PATH |
| 123 | ) |
Shoaib Meenai | 3d1d1ea | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 124 | if (LIBCXX_TARGETING_MSVC) |
| 125 | # FIXME: Figure out how to configure the ABI library on Windows. |
| 126 | set(LIBCXX_CXX_ABI_LIBNAME "vcruntime") |
| 127 | elseif ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND |
| 128 | IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 129 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
Petr Hosek | d842fed | 2016-11-09 03:22:28 +0000 | [diff] [blame] | 130 | set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 131 | set(LIBCXX_CXX_ABI_INTREE 1) |
Shoaib Meenai | 3d1d1ea | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 132 | elseif (APPLE) |
| 133 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
| 134 | set(LIBCXX_CXX_ABI_SYSTEM 1) |
Eugene Zelenko | 96f1017 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 135 | else() |
Shoaib Meenai | 3d1d1ea | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 136 | set(LIBCXX_CXX_ABI_LIBNAME "default") |
Eugene Zelenko | 96f1017 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 137 | endif() |
| 138 | else() |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 139 | set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") |
Eugene Zelenko | 96f1017 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 140 | endif() |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 141 | |
Eric Fiselier | bb856cc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 142 | # Use a static copy of the ABI library when linking libc++. This option |
| 143 | # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 144 | option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) |
| 145 | |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 146 | # Generate and install a linker script inplace of libc++.so. The linker script |
Eric Fiselier | bb856cc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 147 | # will link libc++ to the correct ABI library. This option is on by default |
Shoaib Meenai | e577401 | 2017-03-25 03:22:35 +0000 | [diff] [blame] | 148 | # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' |
Eric Fiselier | 5d5b59b | 2015-10-22 20:50:07 +0000 | [diff] [blame] | 149 | # is on. This option is also disabled when the ABI library is not specified |
| 150 | # or is specified to be "none". |
Eric Fiselier | bb856cc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 151 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) |
Eric Fiselier | 1d3716a | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 152 | if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY |
Eric Fiselier | 1cf5a81 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 153 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" |
Eric Fiselier | cfc5515 | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 154 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" |
Asiri Rathnayake | 10a6829 | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 155 | AND PYTHONINTERP_FOUND |
| 156 | AND LIBCXX_ENABLE_SHARED) |
Eric Fiselier | bb856cc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 157 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) |
| 158 | endif() |
| 159 | |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 160 | option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT |
Eric Fiselier | bb856cc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 161 | "Use and install a linker script for the given ABI library" |
Eric Fiselier | 1d3716a | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 162 | ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 163 | |
Eric Fiselier | dc69aac | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 164 | set(ENABLE_NEW_DELETE_DEFAULT ON) |
| 165 | if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) |
Eric Fiselier | 0cbd39f | 2017-03-02 21:55:03 +0000 | [diff] [blame] | 166 | # FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link |
Shoaib Meenai | f23e281 | 2017-03-25 03:29:51 +0000 | [diff] [blame] | 167 | # programs due to undefined references to new/delete in libc++abi so to work |
Eric Fiselier | 0cbd39f | 2017-03-02 21:55:03 +0000 | [diff] [blame] | 168 | # around this libc++abi currently defaults LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS |
| 169 | # to ON. Once the GCC bug has been worked around this option should be changed |
| 170 | # back to OFF. |
| 171 | set(ENABLE_NEW_DELETE_DEFAULT ON) |
Eric Fiselier | dc69aac | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 172 | endif() |
| 173 | |
| 174 | option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS |
| 175 | "Build libc++ with definitions for operator new/delete. This option can |
| 176 | be used to disable the definitions when libc++abi is expected to provide |
| 177 | them" ${ENABLE_NEW_DELETE_DEFAULT}) |
| 178 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 179 | # Build libc++abi with libunwind. We need this option to determine whether to |
| 180 | # link with libunwind or libgcc_s while running the test cases. |
| 181 | option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) |
Petr Hosek | f4699a5 | 2017-02-09 02:19:43 +0000 | [diff] [blame] | 182 | option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 183 | |
| 184 | # Target options -------------------------------------------------------------- |
| 185 | option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) |
| 186 | set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") |
| 187 | set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") |
| 188 | |
| 189 | # Feature options ------------------------------------------------------------- |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 190 | option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) |
| 191 | option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) |
Ed Schouten | b33ae5b | 2015-03-12 15:44:39 +0000 | [diff] [blame] | 192 | option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) |
Ed Schouten | abd06b4 | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 193 | option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) |
| 194 | option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) |
Eric Fiselier | 7330ed3 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 195 | option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) |
Ed Schouten | 323ade3 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 196 | option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) |
Eric Fiselier | 7330ed3 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 197 | option(LIBCXX_ENABLE_MONOTONIC_CLOCK |
| 198 | "Build libc++ with support for a monotonic clock. |
Jonathan Roelofs | 5e91fa1 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 199 | This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) |
Vasileios Kalintiris | 579b42b | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 200 | option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) |
Ben Craig | 5163e46 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 201 | option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 202 | option(LIBCXX_HAS_EXTERNAL_THREAD_API |
| 203 | "Build libc++ with an externalized threading API. |
| 204 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) |
Eric Fiselier | 66134e8 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 205 | option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY |
| 206 | "Build libc++ with an externalized threading library. |
| 207 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 208 | |
| 209 | # Misc options ---------------------------------------------------------------- |
Eric Fiselier | cb23a49 | 2015-10-10 03:34:52 +0000 | [diff] [blame] | 210 | # FIXME: Turn -pedantic back ON. It is currently off because it warns |
| 211 | # about #include_next which is used everywhere. |
| 212 | option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 213 | option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
Saleem Abdulrasool | ab008f7 | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 214 | option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 215 | |
Eric Fiselier | bf9653d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 216 | option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) |
| 217 | set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 218 | "The Profile-rt library used to build with code coverage") |
| 219 | |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 220 | # Don't allow a user to accidentally overwrite the system libc++ installation on Darwin. |
| 221 | # If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++ |
| 222 | # will not be generated and a warning will be issued. |
| 223 | option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF) |
| 224 | mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default. |
| 225 | |
| 226 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL) |
| 227 | if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") |
| 228 | message(WARNING "Disabling libc++ install rules because installation would " |
| 229 | "overwrite the systems installation. Configure with " |
| 230 | "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.") |
| 231 | mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option. |
| 232 | set(LIBCXX_INSTALL_HEADERS OFF) |
| 233 | set(LIBCXX_INSTALL_LIBRARY OFF) |
| 234 | endif() |
| 235 | endif() |
| 236 | |
Eric Fiselier | 85df7a8 | 2015-12-16 23:41:05 +0000 | [diff] [blame] | 237 | set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) |
| 238 | if (XCODE OR MSVC_IDE) |
| 239 | set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) |
| 240 | endif() |
| 241 | option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" |
| 242 | ${LIBCXX_CONFIGURE_IDE_DEFAULT}) |
| 243 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 244 | #=============================================================================== |
| 245 | # Check option configurations |
| 246 | #=============================================================================== |
| 247 | |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 248 | if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
| 249 | message(FATAL_ERROR |
| 250 | "LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF") |
| 251 | endif() |
| 252 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 253 | # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when |
| 254 | # LIBCXX_ENABLE_THREADS is on. |
| 255 | if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) |
| 256 | message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" |
| 257 | " when LIBCXX_ENABLE_THREADS is also set to OFF.") |
Eric Fiselier | 25a1516 | 2014-08-18 05:03:46 +0000 | [diff] [blame] | 258 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 259 | |
Asiri Rathnayake | e262e7b | 2017-01-03 12:59:50 +0000 | [diff] [blame] | 260 | if(NOT LIBCXX_ENABLE_THREADS) |
| 261 | if(LIBCXX_HAS_PTHREAD_API) |
| 262 | message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" |
| 263 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 264 | endif() |
| 265 | if(LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 266 | message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" |
| 267 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 268 | endif() |
Eric Fiselier | 66134e8 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 269 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 270 | message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " |
| 271 | "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 272 | endif() |
| 273 | |
| 274 | endif() |
| 275 | |
Asiri Rathnayake | da39f1b | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 276 | if (LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 277 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 278 | message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " |
| 279 | "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " |
| 280 | "the same time") |
| 281 | endif() |
| 282 | if (LIBCXX_HAS_PTHREAD_API) |
| 283 | message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" |
| 284 | "and LIBCXX_HAS_PTHREAD_API cannot be both" |
| 285 | "set to ON at the same time.") |
| 286 | endif() |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 287 | endif() |
| 288 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 289 | # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE |
| 290 | # is ON. |
| 291 | if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) |
| 292 | message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") |
| 293 | endif() |
| 294 | |
| 295 | # Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) |
| 296 | # and check that we can build with 32 bits if requested. |
| 297 | if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) |
| 298 | if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM |
| 299 | message(STATUS "Building 32 bits executables and libraries.") |
| 300 | endif() |
| 301 | elseif(LIBCXX_BUILD_32_BITS) |
| 302 | message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") |
| 303 | endif() |
| 304 | |
| 305 | # Check that this option is not enabled on Apple and emit a usage warning. |
Eric Fiselier | c0b166e | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 306 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
| 307 | if (APPLE) |
| 308 | message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") |
| 309 | else() |
| 310 | message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") |
| 311 | endif() |
Eric Fiselier | 60479ea | 2016-11-18 19:53:45 +0000 | [diff] [blame] | 312 | if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND) |
| 313 | message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.") |
| 314 | endif() |
Eric Fiselier | c0b166e | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 315 | endif() |
| 316 | |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 317 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 318 | if (APPLE) |
| 319 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") |
| 320 | endif() |
| 321 | if (NOT PYTHONINTERP_FOUND) |
| 322 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.") |
| 323 | endif() |
Asiri Rathnayake | 10a6829 | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 324 | if (NOT LIBCXX_ENABLE_SHARED) |
| 325 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") |
| 326 | endif() |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 327 | endif() |
| 328 | |
| 329 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 330 | message(FATAL_ERROR "Conflicting options given. |
| 331 | LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with |
| 332 | LIBCXX_ENABLE_ABI_LINKER_SCRIPT") |
| 333 | endif() |
| 334 | |
Vasileios Kalintiris | 579b42b | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 335 | if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) |
| 336 | message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off" |
| 337 | "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") |
| 338 | endif() |
| 339 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 340 | #=============================================================================== |
| 341 | # Configure System |
| 342 | #=============================================================================== |
| 343 | |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 344 | set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) |
| 345 | set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 346 | set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
Eric Fiselier | bde2871 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 347 | set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") |
Jonas Hahnfeld | f77a7df | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 348 | if (LLVM_LIBRARY_OUTPUT_INTDIR) |
| 349 | set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) |
| 350 | else() |
| 351 | set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) |
| 352 | endif() |
Eric Fiselier | bde2871 | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 353 | file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 354 | |
Petr Hosek | 347be61 | 2017-07-11 02:39:50 +0000 | [diff] [blame] | 355 | set(LIBCXX_INSTALL_PREFIX "" CACHE STRING |
| 356 | "Define libc++ destination prefix.") |
| 357 | |
| 358 | if (NOT LIBCXX_INSTALL_PREFIX MATCHES "^$|.*/") |
| 359 | message(FATAL_ERROR "LIBCXX_INSTALL_PREFIX has to end with \"/\".") |
| 360 | endif() |
| 361 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 362 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
| 363 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Shoaib Meenai | b975b45 | 2017-04-13 16:27:38 +0000 | [diff] [blame] | 364 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 365 | |
Eric Fiselier | 8e2855c | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 366 | # Declare libc++ configuration variables. |
| 367 | # They are intended for use as follows: |
| 368 | # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. |
| 369 | # LIBCXX_COMPILE_FLAGS: Compile only flags. |
| 370 | # LIBCXX_LINK_FLAGS: Linker only flags. |
Eric Fiselier | 3bf8a9c | 2016-10-09 21:34:03 +0000 | [diff] [blame] | 371 | # LIBCXX_LIBRARIES: libraries libc++ is linked to. |
| 372 | # LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++ |
Eric Fiselier | 742d878 | 2016-10-10 14:45:06 +0000 | [diff] [blame] | 373 | # These libraries are exposed in the linker script. |
Eric Fiselier | 8e2855c | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 374 | set(LIBCXX_COMPILE_FLAGS "") |
| 375 | set(LIBCXX_LINK_FLAGS "") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 376 | set(LIBCXX_LIBRARIES "") |
Eric Fiselier | 3bf8a9c | 2016-10-09 21:34:03 +0000 | [diff] [blame] | 377 | set(LIBCXX_INTERFACE_LIBRARIES "") |
Eric Fiselier | 8e2855c | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 378 | |
Eric Fiselier | a27cbf8 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 379 | # Include macros for adding and removing libc++ flags. |
| 380 | include(HandleLibcxxFlags) |
| 381 | |
| 382 | # Target flags ================================================================ |
| 383 | # These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that |
| 384 | # 'config-ix' use them during feature checks. It also adds them to both |
| 385 | # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' |
| 386 | add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") |
Petr Hosek | cebb3e9 | 2017-04-16 02:25:55 +0000 | [diff] [blame] | 387 | add_target_flags_if(LIBCXX_TARGET_TRIPLE "--target=${LIBCXX_TARGET_TRIPLE}") |
Eric Fiselier | a27cbf8 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 388 | add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}") |
Petr Hosek | cebb3e9 | 2017-04-16 02:25:55 +0000 | [diff] [blame] | 389 | add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") |
Eric Fiselier | 6e467a8 | 2016-11-13 22:27:00 +0000 | [diff] [blame] | 390 | if (LIBCXX_TARGET_TRIPLE) |
| 391 | set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") |
| 392 | endif() |
Eric Fiselier | a27cbf8 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 393 | |
Eric Fiselier | 9a1468f | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 394 | # Configure compiler. |
| 395 | include(config-ix) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 396 | |
Saleem Abdulrasool | e146f75 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 397 | if (LIBCXX_USE_COMPILER_RT) |
| 398 | list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt") |
| 399 | endif() |
| 400 | |
Eric Fiselier | bf9653d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 401 | # Configure coverage options. |
| 402 | if (LIBCXX_GENERATE_COVERAGE) |
| 403 | include(CodeCoverage) |
| 404 | set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) |
| 405 | endif() |
Eric Fiselier | 9a1468f | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 406 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 407 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
Eric Fiselier | 157fd34 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 408 | if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") |
| 409 | set(LIBCXX_DEBUG_BUILD ON) |
| 410 | else() |
| 411 | set(LIBCXX_DEBUG_BUILD OFF) |
| 412 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 413 | |
Eric Fiselier | 9a1468f | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 414 | #=============================================================================== |
| 415 | # Setup Compiler Flags |
| 416 | #=============================================================================== |
| 417 | |
JF Bastien | c7c4c77 | 2016-03-05 14:22:02 +0000 | [diff] [blame] | 418 | include(HandleLibCXXABI) # Setup the ABI library flags |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 419 | |
Michal Gorny | b79ca0a | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 420 | if (NOT LIBCXX_STANDALONE_BUILD) |
| 421 | # Remove flags that may have snuck in. |
| 422 | remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG |
Eric Fiselier | 8e39559 | 2017-01-17 23:27:56 +0000 | [diff] [blame] | 423 | -lc++abi) |
Michal Gorny | b79ca0a | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 424 | endif() |
| 425 | remove_flags(-stdlib=libc++ -stdlib=libstdc++) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 426 | |
Eric Fiselier | fdd3c91 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 427 | # FIXME: Remove all debug flags and flags that change which Windows |
| 428 | # default libraries are linked. Currently we only support linking the |
| 429 | # non-debug DLLs |
Eric Fiselier | 157fd34 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 430 | remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") |
Eric Fiselier | fdd3c91 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 431 | |
Shoaib Meenai | 68fdad6 | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 432 | # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. |
Eric Fiselier | 7b081f6 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 433 | # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors |
Shoaib Meenai | 68fdad6 | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 434 | # so they don't get transformed into -Wno and -errors respectively. |
Eric Fiselier | 7b081f6 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 435 | remove_flags(-Wno-pedantic -pedantic-errors -pedantic) |
Eric Fiselier | 499d878 | 2015-10-13 23:56:33 +0000 | [diff] [blame] | 436 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 437 | # Required flags ============================================================== |
Eric Fiselier | c9e74dd | 2016-08-14 22:51:54 +0000 | [diff] [blame] | 438 | set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect") |
Petr Hosek | 44197a1 | 2016-10-23 21:48:27 +0000 | [diff] [blame] | 439 | if (LIBCXX_HAS_MUSL_LIBC) |
| 440 | # musl's pthread implementations uses volatile types in their structs which is |
| 441 | # not a constexpr in C++11 but is in C++14, so we use C++14 with musl. |
| 442 | set(LIBCXX_STANDARD_VER c++14 CACHE INTERNAL "internal option to change build dialect") |
| 443 | endif() |
Eric Fiselier | c9e74dd | 2016-08-14 22:51:54 +0000 | [diff] [blame] | 444 | add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER}) |
| 445 | mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME) |
Saleem Abdulrasool | 1ca3c45 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 446 | if(NOT ${SUPPORTS_DIALECT_NAME}) |
| 447 | if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") |
| 448 | message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") |
| 449 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 450 | endif() |
| 451 | |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 452 | # On all systems the system c++ standard library headers need to be excluded. |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 453 | # MSVC only has -X, which disables all default includes; including the crt. |
| 454 | # Thus, we do nothing and hope we don't accidentally include any of the C++ |
| 455 | # headers |
| 456 | add_compile_flags_if_supported(-nostdinc++) |
Eric Fiselier | d74dee9 | 2015-07-29 21:07:28 +0000 | [diff] [blame] | 457 | |
Eric Fiselier | 8330b1e | 2016-10-25 19:43:44 +0000 | [diff] [blame] | 458 | # Hide all inline function definitions which have not explicitly been marked |
| 459 | # visible. This prevents new definitions for inline functions from appearing in |
| 460 | # the dylib when get ODR used by another function. |
| 461 | add_compile_flags_if_supported(-fvisibility-inlines-hidden) |
| 462 | |
Eric Fiselier | 737c3bf | 2017-05-25 04:36:24 +0000 | [diff] [blame] | 463 | if (LIBCXX_CONFIGURE_IDE) |
| 464 | # This simply allows IDE to process <experimental/coroutine> |
| 465 | add_compile_flags_if_supported(-fcoroutines-ts) |
| 466 | endif() |
| 467 | |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 468 | # Let the library headers know they are currently being used to build the |
| 469 | # library. |
Eric Fiselier | 6dbed46 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 470 | add_definitions(-D_LIBCPP_BUILDING_LIBRARY) |
| 471 | |
Eric Fiselier | dc69aac | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 472 | if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) |
| 473 | add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) |
| 474 | endif() |
| 475 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 476 | # Warning flags =============================================================== |
Eric Fiselier | 692177d | 2015-07-18 20:40:46 +0000 | [diff] [blame] | 477 | add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 478 | add_compile_flags_if_supported( |
Eric Fiselier | 3ec6b84 | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 479 | -Wall -Wextra -W -Wwrite-strings |
| 480 | -Wno-unused-parameter -Wno-long-long |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 481 | -Werror=return-type) |
Eric Fiselier | 3ec6b84 | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 482 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 483 | add_compile_flags_if_supported( |
| 484 | -Wno-user-defined-literals |
| 485 | -Wno-covered-switch-default) |
| 486 | elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") |
| 487 | add_compile_flags_if_supported( |
Eric Fiselier | 3ec6b84 | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 488 | -Wno-literal-suffix |
Eric Fiselier | f3b3a65 | 2017-04-03 20:53:15 +0000 | [diff] [blame] | 489 | -Wno-c++14-compat |
| 490 | -Wno-noexcept-type) |
Eric Fiselier | 3ec6b84 | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 491 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 492 | if (LIBCXX_ENABLE_WERROR) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 493 | add_compile_flags_if_supported(-Werror) |
| 494 | add_compile_flags_if_supported(-WX) |
Eric Fiselier | 26d2390 | 2015-07-31 01:25:01 +0000 | [diff] [blame] | 495 | else() |
| 496 | # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is |
| 497 | # added elsewhere. |
| 498 | add_compile_flags_if_supported(-Wno-error) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 499 | endif() |
| 500 | if (LIBCXX_ENABLE_PEDANTIC) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 501 | add_compile_flags_if_supported(-pedantic) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 502 | endif() |
Saleem Abdulrasool | ab008f7 | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 503 | if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 504 | add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 505 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 506 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 507 | # Exception flags ============================================================= |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 508 | if (LIBCXX_ENABLE_EXCEPTIONS) |
| 509 | # Catches C++ exceptions only and tells the compiler to assume that extern C |
| 510 | # functions never throw a C++ exception. |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 511 | add_compile_flags_if_supported(-EHsc) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 512 | else() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 513 | add_definitions(-D_LIBCPP_NO_EXCEPTIONS) |
| 514 | add_compile_flags_if_supported(-EHs- -EHa-) |
| 515 | add_compile_flags_if_supported(-fno-exceptions) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 516 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 517 | |
| 518 | # RTTI flags ================================================================== |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 519 | if (NOT LIBCXX_ENABLE_RTTI) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 520 | add_definitions(-D_LIBCPP_NO_RTTI) |
| 521 | add_compile_flags_if_supported(-GR-) |
| 522 | add_compile_flags_if_supported(-fno-rtti) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 523 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 524 | |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 525 | # Threading flags ============================================================= |
Asiri Rathnayake | da39f1b | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 526 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 527 | # Need to allow unresolved symbols if this is to work with shared library builds |
| 528 | if (APPLE) |
| 529 | add_link_flags("-undefined dynamic_lookup") |
| 530 | else() |
| 531 | # Relax this restriction from HandleLLVMOptions |
| 532 | string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") |
| 533 | endif() |
| 534 | endif() |
| 535 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 536 | # Assertion flags ============================================================= |
| 537 | define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) |
| 538 | define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) |
Eric Fiselier | b89eba0 | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 539 | define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) |
Eric Fiselier | 157fd34 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 540 | define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) |
| 541 | if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 542 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
Eric Fiselier | fdd3c91 | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 543 | define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) |
Howard Hinnant | 4a0e74f | 2013-02-25 15:50:36 +0000 | [diff] [blame] | 544 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 545 | |
Eric Fiselier | 29026ad | 2016-10-14 12:56:52 +0000 | [diff] [blame] | 546 | # Modules flags =============================================================== |
| 547 | # FIXME The libc++ sources are fundamentally non-modular. They need special |
| 548 | # versions of the headers in order to provide C++03 and legacy ABI definitions. |
| 549 | # NOTE: The public headers can be used with modules in all other contexts. |
| 550 | if (LLVM_ENABLE_MODULES) |
| 551 | # Ignore that the rest of the modules flags are now unused. |
| 552 | add_compile_flags_if_supported(-Wno-unused-command-line-argument) |
| 553 | add_compile_flags(-fno-modules) |
| 554 | endif() |
| 555 | |
Jonathan Roelofs | 5e91fa1 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 556 | # Sanitizer flags ============================================================= |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 557 | |
Chris Bieneman | 8c22696 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 558 | # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 559 | # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. |
Chris Bieneman | 8c22696 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 560 | if (LIBCXX_STANDALONE_BUILD) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 561 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 562 | "Define the sanitizer used to build the library and tests") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 563 | # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. |
| 564 | # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. |
| 565 | if (LLVM_USE_SANITIZER AND NOT MSVC) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 566 | add_flags_if_supported("-fno-omit-frame-pointer") |
| 567 | add_flags_if_supported("-gline-tables-only") |
| 568 | |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 569 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND |
| 570 | NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 571 | add_flags_if_supported("-gline-tables-only") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 572 | endif() |
| 573 | if (LLVM_USE_SANITIZER STREQUAL "Address") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 574 | add_flags("-fsanitize=address") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 575 | elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 576 | add_flags(-fsanitize=memory) |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 577 | if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 578 | add_flags("-fsanitize-memory-track-origins") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 579 | endif() |
| 580 | elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 581 | add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 582 | elseif (LLVM_USE_SANITIZER STREQUAL "Thread") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 583 | add_flags(-fsanitize=thread) |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 584 | else() |
| 585 | message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") |
| 586 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 587 | elseif(LLVM_USE_SANITIZER AND MSVC) |
| 588 | message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") |
Eric Fiselier | 5514d36 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 589 | endif() |
| 590 | endif() |
Eric Fiselier | 73ffc78 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 591 | |
| 592 | # Configuration file flags ===================================================== |
Evgeniy Stepanov | 4f01aa8 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 593 | if (NOT LIBCXX_ABI_VERSION EQUAL "1") |
| 594 | config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) |
| 595 | endif() |
| 596 | config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) |
| 597 | |
Eric Fiselier | 73ffc78 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 598 | config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) |
| 599 | config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) |
| 600 | config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) |
| 601 | config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) |
| 602 | config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) |
| 603 | config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) |
| 604 | |
Ben Craig | 5163e46 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 605 | config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 606 | config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) |
Eric Fiselier | 66134e8 | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 607 | config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) |
Vasileios Kalintiris | 579b42b | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 608 | config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) |
| 609 | |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 610 | # By default libc++ on Windows expects to use a shared library, which requires |
| 611 | # the headers to use DLL import/export semantics. However when building a |
| 612 | # static library only we modify the headers to disable DLL import/export. |
| 613 | if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) |
| 614 | message(STATUS "Generating custom __config for non-DLL Windows build") |
Shoaib Meenai | c6d8e8a | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 615 | config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Eric Fiselier | 74c9857 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 616 | endif() |
| 617 | |
Shoaib Meenai | 0a2af12 | 2017-09-14 18:23:43 +0000 | [diff] [blame] | 618 | set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site") |
Eric Fiselier | 73ffc78 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 619 | if (LIBCXX_NEEDS_SITE_CONFIG) |
Saleem Abdulrasool | 1ca3c45 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 620 | configure_file("include/__config_site.in" |
Shoaib Meenai | 0a2af12 | 2017-09-14 18:23:43 +0000 | [diff] [blame] | 621 | "${site_config_path}" |
Saleem Abdulrasool | 1ca3c45 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 622 | @ONLY) |
| 623 | |
Eric Fiselier | a662279 | 2015-10-14 00:22:05 +0000 | [diff] [blame] | 624 | # Provide the config definitions by included the generated __config_site |
| 625 | # file at compile time. |
Saleem Abdulrasool | 1ca3c45 | 2017-01-01 20:20:40 +0000 | [diff] [blame] | 626 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") |
| 627 | add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"") |
| 628 | else() |
| 629 | add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") |
| 630 | endif() |
Shoaib Meenai | 0a2af12 | 2017-09-14 18:23:43 +0000 | [diff] [blame] | 631 | else() |
| 632 | if (EXISTS "${site_config_path}") |
| 633 | message(STATUS "Removing stale site configuration ${site_config_path}") |
| 634 | file(REMOVE "${site_config_path}") |
| 635 | endif() |
Eric Fiselier | 73ffc78 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 636 | endif() |
| 637 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 638 | #=============================================================================== |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 639 | # Setup Source Code And Tests |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 640 | #=============================================================================== |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 641 | include_directories(include) |
Howard Hinnant | c4962b3 | 2013-11-15 17:18:57 +0000 | [diff] [blame] | 642 | add_subdirectory(include) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 643 | add_subdirectory(lib) |
Eric Fiselier | b9f425a | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 644 | |
Eric Fiselier | 5e000c6 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 645 | |
Eric Fiselier | d9b9ef7 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 646 | if (LIBCXX_INCLUDE_BENCHMARKS) |
| 647 | add_subdirectory(benchmarks) |
| 648 | endif() |
Eric Fiselier | c57fb58 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 649 | |
| 650 | # Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or |
| 651 | # LLVM_FOUND is OFF. This allows users to run the tests manually using |
| 652 | # LIT without requiring a full LLVM checkout. |
Duncan P. N. Exon Smith | 59a094f | 2017-05-03 23:33:54 +0000 | [diff] [blame] | 653 | # |
| 654 | # However, since some submission systems strip test/ subdirectories, check for |
| 655 | # it before adding it. |
Zachary Turner | 7a87049 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 656 | |
Duncan P. N. Exon Smith | 59a094f | 2017-05-03 23:33:54 +0000 | [diff] [blame] | 657 | if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test") |
| 658 | add_subdirectory(test) |
| 659 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 660 | if (LIBCXX_INCLUDE_TESTS) |
Eric Fiselier | 5e000c6 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 661 | add_subdirectory(lib/abi) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 662 | endif() |
Eric Fiselier | c57fb58 | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 663 | |
Zachary Turner | 7a87049 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 664 | if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit") |
| 665 | # Make sure the llvm-lit script is generated into the bin directory, and do |
| 666 | # it after adding all tests, since the generated script will only work |
| 667 | # correctly discovered tests against test locations from the source tree that |
| 668 | # have already been discovered. |
| 669 | add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit |
| 670 | ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) |
| 671 | endif() |
| 672 | |
Eric Fiselier | b9f425a | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 673 | if (LIBCXX_INCLUDE_DOCS) |
| 674 | add_subdirectory(docs) |
| 675 | endif() |