• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}"  PARENT_SCOPE)
2
3# Get sources
4# FIXME: Don't use glob here
5file(GLOB LIBCXX_SOURCES ../src/*.cpp)
6if(WIN32)
7  file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
8  list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
9elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
10  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
11  list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
12endif()
13
14# Add all the headers to the project for IDEs.
15if (LIBCXX_CONFIGURE_IDE)
16  file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
17  if(WIN32)
18    file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h)
19    list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS})
20  endif()
21  # Force them all into the headers dir on MSVC, otherwise they end up at
22  # project scope because they don't have extensions.
23  if (MSVC_IDE)
24    source_group("Header Files" FILES ${LIBCXX_HEADERS})
25  endif()
26endif()
27
28if(NOT LIBCXX_INSTALL_LIBRARY)
29  set(exclude_from_all EXCLUDE_FROM_ALL)
30endif()
31
32# If LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
33add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH
34                  "${CMAKE_LIBRARY_PATH_FLAG}${LIBCXX_CXX_ABI_LIBRARY_PATH}")
35
36
37if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
38  find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
39endif()
40add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
41
42if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
43               LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"))
44  set(LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON)
45endif()
46
47if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
48  add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
49  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
50  add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
51elseif (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
52  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
53else ()
54 add_interface_library("${LIBCXX_CXX_ABI_LIBRARY}")
55endif()
56
57if (APPLE AND LLVM_USE_SANITIZER)
58  if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
59      ("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
60      ("${LLVM_USE_SANITIZER}" STREQUAL "Undefined;Address"))
61    set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
62  elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
63    set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
64  elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread")
65    set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib")
66  else()
67    message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X")
68  endif()
69  if (LIBFILE)
70    find_compiler_rt_dir(LIBDIR)
71    if (NOT IS_DIRECTORY "${LIBDIR}")
72      message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER")
73    endif()
74    set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}")
75    set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE)
76    message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}")
77    add_library_flags("${LIBCXX_SANITIZER_LIBRARY}")
78    add_link_flags("-Wl,-rpath,${LIBDIR}")
79  endif()
80endif()
81
82# Generate private library list.
83add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
84add_library_flags_if(LIBCXX_HAS_C_LIB c)
85add_library_flags_if(LIBCXX_HAS_M_LIB m)
86add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
87if (LIBCXX_USE_COMPILER_RT)
88  find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
89  add_library_flags_if(LIBCXX_BUILTINS_LIBRARY "${LIBCXX_BUILTINS_LIBRARY}")
90else()
91  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
92endif()
93add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
94add_library_flags_if(MINGW "${MINGW_LIBRARIES}")
95
96# Add the unwinder library.
97if (LIBCXXABI_USE_LLVM_UNWINDER)
98  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
99    add_interface_library(unwind_shared)
100  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
101    add_interface_library(unwind_static)
102  else()
103    add_interface_library(unwind)
104  endif()
105endif()
106
107# Setup flags.
108if (NOT WIN32)
109  add_flags_if_supported(-fPIC)
110endif()
111
112add_link_flags_if_supported(-nodefaultlibs)
113
114if (LIBCXX_TARGETING_MSVC)
115  if (LIBCXX_DEBUG_BUILD)
116    set(LIB_SUFFIX "d")
117  else()
118    set(LIB_SUFFIX "")
119  endif()
120  add_compile_flags(/Zl)
121  add_link_flags(/nodefaultlib)
122
123  add_library_flags(ucrt${LIB_SUFFIX}) # Universal C runtime
124  add_library_flags(vcruntime${LIB_SUFFIX}) # C++ runtime
125  add_library_flags(msvcrt${LIB_SUFFIX}) # C runtime startup files
126  add_library_flags(msvcprt${LIB_SUFFIX}) # C++ standard library. Required for exception_ptr internals.
127  # Required for standards-complaint wide character formatting functions
128  # (e.g. `printfw`/`scanfw`)
129  add_library_flags(iso_stdio_wide_specifiers)
130endif()
131
132if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
133  if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
134    set(LIBCXX_LIBCPPABI_VERSION "2") # Default value
135    execute_process(
136      COMMAND xcrun --show-sdk-version
137      OUTPUT_VARIABLE sdk_ver
138      RESULT_VARIABLE res
139      OUTPUT_STRIP_TRAILING_WHITESPACE)
140    if (res EQUAL 0)
141      message(STATUS "Found SDK version ${sdk_ver}")
142      string(REPLACE "10." "" sdk_ver "${sdk_ver}")
143      if (sdk_ver LESS 9)
144        set(LIBCXX_LIBCPPABI_VERSION "")
145      else()
146        set(LIBCXX_LIBCPPABI_VERSION "2")
147      endif()
148    endif()
149  endif()
150
151  if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
152    message(FATAL_ERROR "Mac OSX 10.6 is not supported anymore as a deployment "
153                        "target. If you need support for this, please contact "
154                        "the libc++ maintainers.")
155  else()
156    if ("armv7" IN_LIST CMAKE_OSX_ARCHITECTURES)
157      set(RE_EXPORT_LIST "${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
158    else()
159      set(RE_EXPORT_LIST "${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
160    endif()
161    add_link_flags(
162      "-compatibility_version 1"
163      "-install_name /usr/lib/libc++.1.dylib"
164      "-Wl,-unexported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp\""
165      "-Wl,-reexported_symbols_list,\"${RE_EXPORT_LIST}\""
166      "-Wl,-force_symbols_not_weak_list,\"${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp\""
167      "-Wl,-force_symbols_weak_list,\"${CMAKE_CURRENT_SOURCE_DIR}/weak.exp\"")
168
169    if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
170      add_link_flags("-Wl,-reexported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/libc++abi-new-delete.exp\"")
171    endif()
172  endif()
173endif()
174
175split_list(LIBCXX_COMPILE_FLAGS)
176split_list(LIBCXX_LINK_FLAGS)
177
178macro(cxx_object_library name)
179  cmake_parse_arguments(ARGS "" "" "DEFINES;FLAGS" ${ARGN})
180
181  # Add an object library that contains the compiled source files.
182  add_library(${name} OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
183  if(LIBCXX_CXX_ABI_HEADER_TARGET)
184    add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
185  endif()
186  if(WIN32 AND NOT MINGW)
187    target_compile_definitions(${name}
188                               PRIVATE
189                                 # Ignore the -MSC_VER mismatch, as we may build
190                                 # with a different compatibility version.
191                                 _ALLOW_MSC_VER_MISMATCH
192                                 # Don't check the msvcprt iterator debug levels
193                                 # as we will define the iterator types; libc++
194                                 # uses a different macro to identify the debug
195                                 # level.
196                                 _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
197                                 # We are building the c++ runtime, don't pull in
198                                 # msvcprt.
199                                 _CRTBLD
200                                 # Don't warn on the use of "deprecated"
201                                 # "insecure" functions which are standards
202                                 # specified.
203                                 _CRT_SECURE_NO_WARNINGS
204                                 # Use the ISO conforming behaviour for conversion
205                                 # in printf, scanf.
206                                 _CRT_STDIO_ISO_WIDE_SPECIFIERS)
207  endif()
208
209  if(ARGS_DEFINES)
210    target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
211  endif()
212
213  set_target_properties(${name}
214    PROPERTIES
215      COMPILE_FLAGS ${LIBCXX_COMPILE_FLAGS}
216  )
217
218  if(ARGS_FLAGS)
219    target_compile_options(${name} PRIVATE ${ARGS_FLAGS})
220  endif()
221endmacro()
222
223if(LIBCXX_HERMETIC_STATIC_LIBRARY)
224  append_flags_if_supported(CXX_STATIC_OBJECTS_FLAGS -fvisibility=hidden)
225  append_flags_if_supported(CXX_STATIC_OBJECTS_FLAGS -fvisibility-global-new-delete-hidden)
226  cxx_object_library(cxx_static_objects
227    DEFINES _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
228    FLAGS ${CXX_STATIC_OBJECTS_FLAGS})
229  cxx_object_library(cxx_shared_objects)
230  set(cxx_static_sources $<TARGET_OBJECTS:cxx_static_objects>)
231  set(cxx_shared_sources $<TARGET_OBJECTS:cxx_shared_objects>)
232else()
233  cxx_object_library(cxx_objects)
234  set(cxx_static_sources $<TARGET_OBJECTS:cxx_objects>)
235  set(cxx_shared_sources $<TARGET_OBJECTS:cxx_objects>)
236endif()
237
238# Build the shared library.
239if (LIBCXX_ENABLE_SHARED)
240  add_library(cxx_shared SHARED ${cxx_shared_sources})
241  if(COMMAND llvm_setup_rpath)
242    llvm_setup_rpath(cxx_shared)
243  endif()
244  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
245  set_target_properties(cxx_shared
246    PROPERTIES
247      LINK_FLAGS    "${LIBCXX_LINK_FLAGS}"
248      OUTPUT_NAME   "c++"
249      VERSION       "${LIBCXX_ABI_VERSION}.0"
250      SOVERSION     "${LIBCXX_ABI_VERSION}"
251  )
252  list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared")
253  if (LIBCXX_INSTALL_SHARED_LIBRARY)
254    list(APPEND LIBCXX_INSTALL_TARGETS "cxx_shared")
255  endif()
256  if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
257    # Since we most likely do not have a mt.exe replacement, disable the
258    # manifest bundling.  This allows a normal cmake invocation to pass which
259    # will attempt to use the manifest tool to generate the bundled manifest
260    set_target_properties(cxx_shared PROPERTIES
261                          APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO")
262  endif()
263endif()
264
265# Build the static library.
266if (LIBCXX_ENABLE_STATIC)
267  add_library(cxx_static STATIC ${cxx_static_sources})
268  target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
269  set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
270  set_target_properties(cxx_static
271    PROPERTIES
272      LINK_FLAGS    "${LIBCXX_LINK_FLAGS}"
273      OUTPUT_NAME   "c++"
274  )
275  list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
276  if (LIBCXX_INSTALL_STATIC_LIBRARY)
277    list(APPEND LIBCXX_INSTALL_TARGETS "cxx_static")
278  endif()
279  # Attempt to merge the libc++.a archive and the ABI library archive into one.
280  if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
281    set(MERGE_ARCHIVES_SEARCH_PATHS "")
282    if (LIBCXX_CXX_ABI_LIBRARY_PATH)
283      set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
284    endif()
285    if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
286        (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
287      set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:cxxabi_static>")
288    else()
289      set(MERGE_ARCHIVES_ABI_TARGET
290          "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
291    endif()
292    add_custom_command(TARGET cxx_static POST_BUILD
293    COMMAND
294      ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py
295    ARGS
296      -o $<TARGET_LINKER_FILE:cxx_static>
297      --ar "${CMAKE_AR}"
298      "$<TARGET_LINKER_FILE:cxx_static>"
299      "${MERGE_ARCHIVES_ABI_TARGET}"
300      "${MERGE_ARCHIVES_SEARCH_PATHS}"
301    WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
302    )
303  endif()
304endif()
305
306# Add a meta-target for both libraries.
307add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
308
309if (LIBCXX_ENABLE_FILESYSTEM)
310  set(LIBCXX_FILESYSTEM_SOURCES
311      ../src/filesystem/operations.cpp
312      ../src/filesystem/directory_iterator.cpp)
313
314  # Filesystem uses __int128_t, which requires a definition of __muloi4 when
315  # compiled with UBSAN. This definition is not provided by libgcc_s, but is
316  # provided by compiler-rt. So we need to disable it to avoid having multiple
317  # definitions. See filesystem/int128_builtins.cpp.
318  if (NOT LIBCXX_USE_COMPILER_RT)
319    list(APPEND LIBCXX_FILESYSTEM_SOURCES ../src/filesystem/int128_builtins.cpp)
320  endif()
321
322  add_library(cxx_filesystem STATIC ${LIBCXX_FILESYSTEM_SOURCES})
323  if (LIBCXX_ENABLE_SHARED)
324    target_link_libraries(cxx_filesystem cxx_shared)
325  else()
326    target_link_libraries(cxx_filesystem cxx_static)
327  endif()
328
329  set(filesystem_flags "${LIBCXX_COMPILE_FLAGS}")
330  check_flag_supported(-std=c++14)
331  if (NOT MSVC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG)
332    string(REPLACE "-std=c++11" "-std=c++14" filesystem_flags "${LIBCXX_COMPILE_FLAGS}")
333  endif()
334  set_target_properties(cxx_filesystem
335    PROPERTIES
336      COMPILE_FLAGS "${filesystem_flags}"
337      OUTPUT_NAME   "c++fs"
338  )
339endif()
340
341
342if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
343  file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
344  add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
345  if (LIBCXX_ENABLE_SHARED)
346    target_link_libraries(cxx_experimental cxx_shared)
347  else()
348    target_link_libraries(cxx_experimental cxx_static)
349  endif()
350
351  set(experimental_flags "${LIBCXX_COMPILE_FLAGS}")
352  check_flag_supported(-std=c++14)
353  if (NOT MSVC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG)
354    string(REPLACE "-std=c++11" "-std=c++14" experimental_flags "${LIBCXX_COMPILE_FLAGS}")
355  endif()
356  set_target_properties(cxx_experimental
357    PROPERTIES
358      COMPILE_FLAGS "${experimental_flags}"
359      OUTPUT_NAME   "c++experimental"
360  )
361endif()
362
363if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
364  file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES ../test/support/external_threads.cpp)
365
366  if (LIBCXX_ENABLE_SHARED)
367    add_library(cxx_external_threads SHARED ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
368  else()
369    add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES})
370  endif()
371
372  set_target_properties(cxx_external_threads
373    PROPERTIES
374      LINK_FLAGS    "${LIBCXX_LINK_FLAGS}"
375      COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
376      OUTPUT_NAME   "c++external_threads"
377  )
378endif()
379
380# Generate a linker script inplace of a libc++.so symlink. Rerun this command
381# after cxx builds.
382if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
383  # Get the name of the ABI library and handle the case where CXXABI_LIBNAME
384  # is a target name and not a library. Ex cxxabi_shared.
385  set(LIBCXX_INTERFACE_LIBRARY_NAMES)
386  foreach(lib ${LIBCXX_INTERFACE_LIBRARIES})
387    # FIXME: Handle cxxabi_static and unwind_static.
388    if (TARGET ${lib} OR
389        (${lib} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI) OR
390        (${lib} MATCHES "unwind(_static|_shared)?" AND HAVE_LIBUNWIND))
391      list(APPEND LIBCXX_INTERFACE_LIBRARY_NAMES "$<TARGET_PROPERTY:${lib},OUTPUT_NAME>")
392    else()
393      list(APPEND LIBCXX_INTERFACE_LIBRARY_NAMES "${lib}")
394    endif()
395  endforeach()
396  #split_list(LIBCXX_INTERFACE_LIBRARY_NAMES)
397  # Generate a linker script inplace of a libc++.so symlink. Rerun this command
398  # after cxx builds.
399  add_custom_command(TARGET cxx_shared POST_BUILD
400    COMMAND
401      ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/gen_link_script.py
402    ARGS
403      "$<TARGET_LINKER_FILE:cxx_shared>"
404      ${LIBCXX_INTERFACE_LIBRARY_NAMES}
405    WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
406  )
407endif()
408
409if (LIBCXX_INSTALL_LIBRARY)
410  if (LIBCXX_INSTALL_FILESYSTEM_LIBRARY)
411    set(filesystem_lib cxx_filesystem)
412  endif()
413  if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
414    set(experimental_lib cxx_experimental)
415  endif()
416  install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib}
417    LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
418    ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
419    )
420  # NOTE: This install command must go after the cxx install command otherwise
421  # it will not be executed after the library symlinks are installed.
422  if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
423    # Replace the libc++ filename with $<TARGET_LINKER_FILE:cxx>
424    # after we required CMake 3.0.
425    install(FILES "${LIBCXX_LIBRARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}"
426      DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX}
427      COMPONENT libcxx)
428  endif()
429endif()
430
431if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
432                                       LIBCXX_INSTALL_HEADERS))
433    if(LIBCXX_INSTALL_LIBRARY)
434      set(lib_install_target cxx)
435    endif()
436    if (LIBCXX_INSTALL_FILESYSTEM_LIBRARY)
437      set(filesystem_lib_install_target cxx_filesystem)
438    endif()
439    if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
440      set(experimental_lib_install_target cxx_experimental)
441    endif()
442    if(LIBCXX_INSTALL_HEADERS)
443      set(header_install_target install-cxx-headers)
444    endif()
445    add_custom_target(install-cxx
446                      DEPENDS ${lib_install_target}
447                              ${experimental_lib_install_target}
448                              ${filesystem_lib_install_target}
449                              ${header_install_target}
450                      COMMAND "${CMAKE_COMMAND}"
451                      -DCMAKE_INSTALL_COMPONENT=cxx
452                      -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
453    add_custom_target(install-cxx-stripped
454                      DEPENDS ${lib_install_target}
455                              ${experimental_lib_install_target}
456                              ${filesystem_lib_install_target}
457                              ${header_install_target}
458                      COMMAND "${CMAKE_COMMAND}"
459                      -DCMAKE_INSTALL_COMPONENT=cxx
460                      -DCMAKE_INSTALL_DO_STRIP=1
461                      -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
462    add_custom_target(install-libcxx DEPENDS install-cxx)
463endif()
464