• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# See www/CMake.html for instructions on how to build libcxx with CMake.
2
3#===============================================================================
4# Setup Project
5#===============================================================================
6cmake_minimum_required(VERSION 3.4.3)
7
8if(POLICY CMP0042)
9  cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
10endif()
11if(POLICY CMP0022)
12  cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
13endif()
14if(POLICY CMP0068)
15  cmake_policy(SET CMP0068 NEW)
16  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
17endif()
18
19# Add path for custom modules
20set(CMAKE_MODULE_PATH
21  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
22  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
23  ${CMAKE_MODULE_PATH}
24  )
25
26if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
27  project(libcxx CXX C)
28
29  set(PACKAGE_NAME libcxx)
30  set(PACKAGE_VERSION 8.0.0svn)
31  set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
32  set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
33
34  # Find the LLVM sources and simulate LLVM CMake options.
35  include(HandleOutOfTreeLLVM)
36endif()
37
38if (LIBCXX_STANDALONE_BUILD)
39  include(FindPythonInterp)
40  if( NOT PYTHONINTERP_FOUND )
41    message(WARNING "Failed to find python interpreter. "
42                    "The libc++ test suite will be disabled.")
43    set(LLVM_INCLUDE_TESTS OFF)
44  endif()
45endif()
46
47# Require out of source build.
48include(MacroEnsureOutOfSourceBuild)
49MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
50 "${PROJECT_NAME} requires an out of source build. Please create a separate
51 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
52 )
53if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
54  message(STATUS "Configuring for clang-cl")
55  set(LIBCXX_TARGETING_CLANG_CL ON)
56endif()
57
58if (MSVC)
59  set(LIBCXX_TARGETING_MSVC ON)
60  message(STATUS "Configuring for MSVC")
61else()
62  set(LIBCXX_TARGETING_MSVC OFF)
63endif()
64
65#===============================================================================
66# Setup CMake Options
67#===============================================================================
68include(CMakeDependentOption)
69include(HandleCompilerRT)
70
71# Basic options ---------------------------------------------------------------
72option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF)
73option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
74option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
75option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
76set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
77if (WIN32)
78  set(ENABLE_FILESYSTEM_DEFAULT OFF)
79endif()
80option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++fs.a"
81    ${ENABLE_FILESYSTEM_DEFAULT})
82option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
83
84# Benchmark options -----------------------------------------------------------
85option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON)
86
87set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01)
88set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING
89    "Arguments to pass when running the benchmarks using check-cxx-benchmarks")
90
91set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING
92        "Build the benchmarks against the specified native STL.
93         The value must be one of libc++/libstdc++")
94set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING
95    "Use alternate GCC toolchain when building the native benchmarks")
96
97if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
98  if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++"
99        OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++"))
100    message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: "
101            "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'")
102  endif()
103endif()
104
105option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
106set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
107    "Define suffix of library directory name (32/64)")
108option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
109option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
110cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY
111  "Install the static libc++ library." ON
112  "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF)
113cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY
114  "Install the shared libc++ library." ON
115  "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF)
116option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
117cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
118        "Install libc++experimental.a" ON
119        "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
120cmake_dependent_option(LIBCXX_INSTALL_FILESYSTEM_LIBRARY
121        "Install libc++fs.a" ON
122        "LIBCXX_ENABLE_FILESYSTEM;LIBCXX_INSTALL_LIBRARY" OFF)
123
124set(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.")
125set(LIBCXX_ABI_NAMESPACE "" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
126option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
127option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
128option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
129option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF)
130set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
131option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
132
133if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
134  message(FATAL_ERROR "libc++ must be built as either a shared or static library.")
135endif()
136
137# ABI Library options ---------------------------------------------------------
138set(LIBCXX_CXX_ABI "default" CACHE STRING
139    "Specify C++ ABI library to use.")
140set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
141set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
142
143# Setup the default options if LIBCXX_CXX_ABI is not specified.
144if (LIBCXX_CXX_ABI STREQUAL "default")
145  find_path(
146    LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
147    cxxabi.h
148    PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include
149          ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
150          ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
151    NO_DEFAULT_PATH
152    NO_CMAKE_FIND_ROOT_PATH
153  )
154  if (LIBCXX_TARGETING_MSVC)
155    # FIXME: Figure out how to configure the ABI library on Windows.
156    set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
157  elseif ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND
158          IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
159    set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
160    set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
161    set(LIBCXX_CXX_ABI_INTREE 1)
162  elseif (APPLE)
163    set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
164    set(LIBCXX_CXX_ABI_SYSTEM 1)
165  elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
166    set(LIBCXX_CXX_ABI_LIBNAME "libcxxrt")
167    set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1")
168  else()
169    set(LIBCXX_CXX_ABI_LIBNAME "default")
170  endif()
171else()
172  set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
173endif()
174
175# Use a static copy of the ABI library when linking libc++. This option
176# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
177option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
178
179cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY
180  "Statically link the ABI library to static library" ON
181  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
182
183cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
184  "Statically link the ABI library to shared library" ON
185  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF)
186
187# Generate and install a linker script inplace of libc++.so. The linker script
188# will link libc++ to the correct ABI library. This option is on by default
189# on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
190# is on. This option is also disabled when the ABI library is not specified
191# or is specified to be "none".
192set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
193if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
194      AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
195      AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
196      AND PYTHONINTERP_FOUND
197      AND LIBCXX_ENABLE_SHARED)
198    set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
199endif()
200
201option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
202      "Use and install a linker script for the given ABI library"
203      ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
204
205set(ENABLE_NEW_DELETE_DEFAULT ON)
206if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
207# FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link
208# programs due to undefined references to new/delete in libc++abi so to work
209# around this libc++abi currently defaults LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
210# to ON. Once the GCC bug has been worked around this option should be changed
211# back to OFF.
212  set(ENABLE_NEW_DELETE_DEFAULT ON)
213endif()
214
215option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
216    "Build libc++ with definitions for operator new/delete. This option can
217    be used to disable the definitions when libc++abi is expected to provide
218    them" ${ENABLE_NEW_DELETE_DEFAULT})
219
220# Build libc++abi with libunwind. We need this option to determine whether to
221# link with libunwind or libgcc_s while running the test cases.
222option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
223option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
224
225# Target options --------------------------------------------------------------
226option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
227set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
228set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
229
230# Feature options -------------------------------------------------------------
231option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
232option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
233option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
234option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
235option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
236option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
237option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
238option(LIBCXX_ENABLE_MONOTONIC_CLOCK
239  "Build libc++ with support for a monotonic clock.
240   This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
241option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
242option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
243option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
244option(LIBCXX_HAS_EXTERNAL_THREAD_API
245  "Build libc++ with an externalized threading API.
246   This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
247option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
248    "Build libc++ with an externalized threading library.
249     This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
250
251# Misc options ----------------------------------------------------------------
252# FIXME: Turn -pedantic back ON. It is currently off because it warns
253# about #include_next which is used everywhere.
254option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
255option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
256option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF)
257
258option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
259set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
260    "The Profile-rt library used to build with code coverage")
261
262# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
263# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
264# will not be generated and a warning will be issued.
265option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
266mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
267
268if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
269  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
270    message(WARNING "Disabling libc++ install rules because installation would "
271                    "overwrite the systems installation. Configure with "
272                    "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
273    mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
274    set(LIBCXX_INSTALL_HEADERS OFF)
275    set(LIBCXX_INSTALL_LIBRARY OFF)
276  endif()
277endif()
278
279set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF)
280if (XCODE OR MSVC_IDE)
281  set(LIBCXX_CONFIGURE_IDE_DEFAULT ON)
282endif()
283option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE"
284      ${LIBCXX_CONFIGURE_IDE_DEFAULT})
285
286option(LIBCXX_HERMETIC_STATIC_LIBRARY
287  "Do not export any symbols from the static library." OFF)
288
289#===============================================================================
290# Check option configurations
291#===============================================================================
292
293if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
294  message(FATAL_ERROR
295    "LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF")
296endif()
297
298# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
299# LIBCXX_ENABLE_THREADS is on.
300if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
301  message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
302                      " when LIBCXX_ENABLE_THREADS is also set to OFF.")
303endif()
304
305if(NOT LIBCXX_ENABLE_THREADS)
306  if(LIBCXX_HAS_PTHREAD_API)
307    message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
308                        " when LIBCXX_ENABLE_THREADS is also set to ON.")
309  endif()
310  if(LIBCXX_HAS_EXTERNAL_THREAD_API)
311    message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
312                        " when LIBCXX_ENABLE_THREADS is also set to ON.")
313  endif()
314  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
315    message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set "
316                        "to ON when LIBCXX_ENABLE_THREADS is also set to ON.")
317  endif()
318  if (LIBCXX_HAS_WIN32_THREAD_API)
319    message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON"
320                        " when LIBCXX_ENABLE_THREADS is also set to ON.")
321  endif()
322
323endif()
324
325if (LIBCXX_HAS_EXTERNAL_THREAD_API)
326  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
327    message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and "
328                        "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at "
329                        "the same time")
330  endif()
331  if (LIBCXX_HAS_PTHREAD_API)
332    message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
333                        "and LIBCXX_HAS_PTHREAD_API cannot be both"
334                        "set to ON at the same time.")
335  endif()
336  if (LIBCXX_HAS_WIN32_THREAD_API)
337    message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
338                        "and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
339                        "set to ON at the same time.")
340  endif()
341endif()
342
343if (LIBCXX_HAS_PTHREAD_API)
344  if (LIBCXX_HAS_WIN32_THREAD_API)
345    message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API"
346                        "and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
347                        "set to ON at the same time.")
348  endif()
349endif()
350
351# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
352# is ON.
353if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
354  message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
355endif()
356
357# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS)
358# and check that we can build with 32 bits if requested.
359if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
360  if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
361    message(STATUS "Building 32 bits executables and libraries.")
362  endif()
363elseif(LIBCXX_BUILD_32_BITS)
364  message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
365endif()
366
367# Check that this option is not enabled on Apple and emit a usage warning.
368if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
369  if (APPLE)
370    message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
371  else()
372    message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
373  endif()
374  if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND)
375    message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.")
376  endif()
377endif()
378
379if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
380    if (APPLE)
381      message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
382    endif()
383    if (NOT PYTHONINTERP_FOUND)
384      message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.")
385    endif()
386    if (NOT LIBCXX_ENABLE_SHARED)
387      message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.")
388    endif()
389endif()
390
391if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
392    message(FATAL_ERROR "Conflicting options given.
393        LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
394        LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
395endif()
396
397if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
398  message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off"
399                      "when building for Musl with LIBCXX_HAS_MUSL_LIBC.")
400endif()
401
402if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT)
403  message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.")
404endif ()
405
406#===============================================================================
407# Configure System
408#===============================================================================
409
410set(LIBCXX_COMPILER    ${CMAKE_CXX_COMPILER})
411set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
412set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
413set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
414
415string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
416       ${PACKAGE_VERSION})
417
418if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
419  set(DEFAULT_INSTALL_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
420  set(DEFAULT_INSTALL_HEADER_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/)
421  set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXX_LIBDIR_SUFFIX})
422  set(LIBCXX_HEADER_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
423elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
424  set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
425  set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
426else()
427  set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
428endif()
429
430file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
431
432set(LIBCXX_INSTALL_PREFIX ${DEFAULT_INSTALL_PREFIX} CACHE STRING
433    "Define libc++ destination prefix.")
434
435set(LIBCXX_INSTALL_HEADER_PREFIX ${DEFAULT_INSTALL_HEADER_PREFIX} CACHE STRING
436    "Define libc++ header destination prefix.")
437
438set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
439set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
440set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
441
442# Declare libc++ configuration variables.
443# They are intended for use as follows:
444# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
445# LIBCXX_COMPILE_FLAGS: Compile only flags.
446# LIBCXX_LINK_FLAGS: Linker only flags.
447# LIBCXX_LIBRARIES: libraries libc++ is linked to.
448# LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++
449#                             These libraries are exposed in the linker script.
450set(LIBCXX_COMPILE_FLAGS "")
451set(LIBCXX_LINK_FLAGS "")
452set(LIBCXX_LIBRARIES "")
453set(LIBCXX_INTERFACE_LIBRARIES "")
454
455# Include macros for adding and removing libc++ flags.
456include(HandleLibcxxFlags)
457
458# Target flags ================================================================
459# These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that
460# 'config-ix' use them during feature checks. It also adds them to both
461# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
462add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
463add_target_flags_if(LIBCXX_TARGET_TRIPLE "--target=${LIBCXX_TARGET_TRIPLE}")
464add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
465add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
466if (LIBCXX_TARGET_TRIPLE)
467  set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}")
468endif()
469
470# Configure compiler.
471include(config-ix)
472
473if (LIBCXX_USE_COMPILER_RT)
474  list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt")
475endif()
476
477# Configure coverage options.
478if (LIBCXX_GENERATE_COVERAGE)
479  include(CodeCoverage)
480  set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
481endif()
482
483string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
484if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
485  set(LIBCXX_DEBUG_BUILD ON)
486else()
487  set(LIBCXX_DEBUG_BUILD OFF)
488endif()
489
490#===============================================================================
491# Setup Compiler Flags
492#===============================================================================
493
494include(HandleLibCXXABI) # Setup the ABI library flags
495
496if (NOT LIBCXX_STANDALONE_BUILD)
497  # Remove flags that may have snuck in.
498  remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
499               -lc++abi)
500endif()
501remove_flags(-stdlib=libc++ -stdlib=libstdc++)
502
503# FIXME: Remove all debug flags and flags that change which Windows
504# default libraries are linked. Currently we only support linking the
505# non-debug DLLs
506remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md")
507
508# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
509# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
510# so they don't get transformed into -Wno and -errors respectively.
511remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
512
513# Required flags ==============================================================
514set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
515if (LIBCXX_HAS_MUSL_LIBC OR LIBCXX_TARGETING_CLANG_CL)
516  # musl's pthread implementations uses volatile types in their structs which is
517  # not a constexpr in C++11 but is in C++14, so we use C++14 with musl.
518  set(LIBCXX_STANDARD_VER c++14 CACHE INTERNAL "internal option to change build dialect")
519endif()
520add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})
521add_compile_flags_if_supported("/std:${LIBCXX_STANDARD_VER}")
522mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME)
523mangle_name("LIBCXX_SUPPORTS_STD_COLON_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME_MSVC)
524if(NOT ${SUPPORTS_DIALECT_NAME} AND NOT ${SUPPORTS_DIALECT_NAME_MSVC})
525  if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
526    message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}")
527  endif()
528endif()
529
530# On all systems the system c++ standard library headers need to be excluded.
531# MSVC only has -X, which disables all default includes; including the crt.
532# Thus, we do nothing and hope we don't accidentally include any of the C++
533# headers
534add_compile_flags_if_supported(-nostdinc++)
535
536# Hide all inline function definitions which have not explicitly been marked
537# visible. This prevents new definitions for inline functions from appearing in
538# the dylib when get ODR used by another function.
539add_compile_flags_if_supported(-fvisibility-inlines-hidden)
540
541if (LIBCXX_CONFIGURE_IDE)
542  # This simply allows IDE to process <experimental/coroutine>
543  add_compile_flags_if_supported(-fcoroutines-ts)
544endif()
545
546# Let the library headers know they are currently being used to build the
547# library.
548add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
549
550if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
551  add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
552endif()
553
554# Warning flags ===============================================================
555add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
556add_compile_flags_if_supported(
557    -Wall -Wextra -W -Wwrite-strings
558    -Wno-unused-parameter -Wno-long-long
559    -Werror=return-type -Wextra-semi)
560if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
561    add_compile_flags_if_supported(
562        -Wno-user-defined-literals
563        -Wno-covered-switch-default)
564    if (LIBCXX_TARGETING_CLANG_CL)
565      add_compile_flags_if_supported(
566        -Wno-c++98-compat
567        -Wno-c++98-compat-pedantic
568        -Wno-c++11-compat
569        -Wno-undef
570        -Wno-reserved-id-macro
571        -Wno-gnu-include-next
572        -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings
573        -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences.
574        -Wno-deprecated-dynamic-exception-spec # For auto_ptr
575        -Wno-sign-conversion
576        -Wno-old-style-cast
577        -Wno-deprecated # FIXME: Remove this and fix all occurrences.
578        -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang?
579        -Wno-double-promotion # FIXME: remove me
580      )
581    endif()
582elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
583    add_compile_flags_if_supported(
584        -Wno-literal-suffix
585        -Wno-c++14-compat
586        -Wno-noexcept-type)
587endif()
588if (LIBCXX_ENABLE_WERROR)
589  add_compile_flags_if_supported(-Werror)
590  add_compile_flags_if_supported(-WX)
591else()
592  # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
593  # added elsewhere.
594  add_compile_flags_if_supported(-Wno-error)
595endif()
596if (LIBCXX_ENABLE_PEDANTIC)
597  add_compile_flags_if_supported(-pedantic)
598endif()
599if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
600  add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
601endif()
602
603# Exception flags =============================================================
604if (LIBCXX_ENABLE_EXCEPTIONS)
605  # Catches C++ exceptions only and tells the compiler to assume that extern C
606  # functions never throw a C++ exception.
607  add_compile_flags_if_supported(-EHsc)
608else()
609  add_definitions(-D_LIBCPP_NO_EXCEPTIONS)
610  add_compile_flags_if_supported(-EHs- -EHa-)
611  add_compile_flags_if_supported(-fno-exceptions)
612endif()
613
614# RTTI flags ==================================================================
615if (NOT LIBCXX_ENABLE_RTTI)
616  add_definitions(-D_LIBCPP_NO_RTTI)
617  add_compile_flags_if_supported(-GR-)
618  add_compile_flags_if_supported(-fno-rtti)
619endif()
620
621# Threading flags =============================================================
622if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED)
623  # Need to allow unresolved symbols if this is to work with shared library builds
624  if (APPLE)
625    add_link_flags("-undefined dynamic_lookup")
626  else()
627    # Relax this restriction from HandleLLVMOptions
628    string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
629  endif()
630endif()
631
632# Assertion flags =============================================================
633define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
634define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
635define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0)
636define_if(LIBCXX_DEBUG_BUILD -D_DEBUG)
637if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD)
638  # MSVC doesn't like _DEBUG on release builds. See PR 4379.
639  define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG)
640endif()
641
642# Modules flags ===============================================================
643# FIXME The libc++ sources are fundamentally non-modular. They need special
644# versions of the headers in order to provide C++03 and legacy ABI definitions.
645# NOTE: The public headers can be used with modules in all other contexts.
646if (LLVM_ENABLE_MODULES)
647  # Ignore that the rest of the modules flags are now unused.
648  add_compile_flags_if_supported(-Wno-unused-command-line-argument)
649  add_compile_flags(-fno-modules)
650endif()
651
652# Sanitizer flags =============================================================
653
654function(get_sanitizer_flags OUT_VAR  USE_SANITIZER)
655  set(SANITIZER_FLAGS)
656  set(USE_SANITIZER "${USE_SANITIZER}")
657  # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
658  # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
659  if (USE_SANITIZER AND NOT MSVC)
660    append_flags_if_supported(SANITIZER_FLAGS "-fno-omit-frame-pointer")
661    append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only")
662
663    if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
664            NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
665      append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only")
666    endif()
667    if (USE_SANITIZER STREQUAL "Address")
668      append_flags(SANITIZER_FLAGS "-fsanitize=address")
669    elseif (USE_SANITIZER MATCHES "Memory(WithOrigins)?")
670      append_flags(SANITIZER_FLAGS -fsanitize=memory)
671      if (USE_SANITIZER STREQUAL "MemoryWithOrigins")
672        append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins")
673      endif()
674    elseif (USE_SANITIZER STREQUAL "Undefined")
675      append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
676    elseif (USE_SANITIZER STREQUAL "Thread")
677      append_flags(SANITIZER_FLAGS -fsanitize=thread)
678    else()
679      message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${USE_SANITIZER}")
680    endif()
681  elseif(USE_SANITIZER AND MSVC)
682    message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
683  endif()
684  set(${OUT_VAR} "${SANITIZER_FLAGS}" PARENT_SCOPE)
685endfunction()
686
687# Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do
688# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
689if (LIBCXX_STANDALONE_BUILD)
690  set(LLVM_USE_SANITIZER "" CACHE STRING
691      "Define the sanitizer used to build the library and tests")
692endif()
693get_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}")
694if (LIBCXX_STANDALONE_BUILD AND SANITIZER_FLAGS)
695  add_flags(${SANITIZER_FLAGS})
696endif()
697
698# Configuration file flags =====================================================
699if (NOT LIBCXX_ABI_VERSION EQUAL 1)
700  config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
701endif()
702if (NOT LIBCXX_ABI_NAMESPACE STREQUAL "")
703  if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*")
704    message(WARNING "LIBCXX_ABI_NAMESPACE must be a reserved identifier.")
705  endif()
706  if (LIBCXX_ABI_NAMESPACE MATCHES "__[0-9]+$")
707    message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE '${LIBCXX_ABI_NAMESPACE}' is reserved for use by libc++.")
708  endif()
709  config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE)
710endif()
711config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
712config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
713config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
714config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT)
715
716config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
717config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
718config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT)
719config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
720config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
721config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
722
723config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
724config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
725config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32)
726config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
727config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
728config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
729
730if (LIBCXX_ABI_DEFINES)
731  set(abi_defines)
732  foreach (abi_define ${LIBCXX_ABI_DEFINES})
733    if (NOT abi_define MATCHES "^_LIBCPP_ABI_")
734      message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES")
735    endif()
736    list(APPEND abi_defines "#define ${abi_define}")
737  endforeach()
738  string(REPLACE ";" "\n" abi_defines "${abi_defines}")
739  config_define(${abi_defines} _LIBCPP_ABI_DEFINES)
740endif()
741
742# By default libc++ on Windows expects to use a shared library, which requires
743# the headers to use DLL import/export semantics. However when building a
744# static library only we modify the headers to disable DLL import/export.
745if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
746  message(STATUS "Generating custom __config for non-DLL Windows build")
747  config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
748endif()
749
750set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site")
751if (LIBCXX_NEEDS_SITE_CONFIG)
752  configure_file("include/__config_site.in"
753                 "${site_config_path}"
754                 @ONLY)
755
756  # Provide the config definitions by included the generated __config_site
757  # file at compile time.
758  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
759    add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"")
760  else()
761    add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
762  endif()
763else()
764  if (EXISTS "${site_config_path}")
765    message(STATUS "Removing stale site configuration ${site_config_path}")
766    file(REMOVE "${site_config_path}")
767  endif()
768endif()
769
770#===============================================================================
771# Setup Source Code And Tests
772#===============================================================================
773include_directories(include)
774add_subdirectory(include)
775add_subdirectory(lib)
776
777set(LIBCXX_TEST_DEPS "")
778
779if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
780  list(APPEND LIBCXX_TEST_DEPS cxx_experimental)
781endif()
782if (LIBCXX_ENABLE_FILESYSTEM)
783  list(APPEND LIBCXX_TEST_DEPS cxx_filesystem)
784endif()
785
786if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
787  list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
788endif()
789
790if (LIBCXX_INCLUDE_BENCHMARKS)
791  add_subdirectory(benchmarks)
792endif()
793
794# Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or
795# LLVM_FOUND is OFF. This allows users to run the tests manually using
796# LIT without requiring a full LLVM checkout.
797#
798# However, since some submission systems strip test/ subdirectories, check for
799# it before adding it.
800
801if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
802  add_subdirectory(test)
803endif()
804if (LIBCXX_INCLUDE_TESTS)
805  add_subdirectory(lib/abi)
806endif()
807
808if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
809  include(AddLLVM) # for get_llvm_lit_path
810  # Make sure the llvm-lit script is generated into the bin directory, and do
811  # it after adding all tests, since the generated script will only work
812  # correctly discovered tests against test locations from the source tree that
813  # have already been discovered.
814  add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
815                   ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
816endif()
817
818if (LIBCXX_INCLUDE_DOCS)
819  add_subdirectory(docs)
820endif()
821