[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / libcxx / test / CMakeLists.txt
blobf4e577aed57de3dea2e9464dec8d155ca1a911b7
1 include(HandleLitArguments)
2 add_subdirectory(tools)
4 # Install the library at a fake location so we can run the test suite against it.
5 # This ensures that we run the test suite against a setup that matches what we ship
6 # in production as closely as possible (in terms of file paths, rpaths, etc).
7 set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
8 if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
9   add_custom_target(install-cxxabi-test-suite-prefix
10                         DEPENDS cxxabi-headers
11                                 cxxabi
12                         COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
13                         COMMAND "${CMAKE_COMMAND}"
14                                 -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
15                                 -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
16                                 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
17                         COMMAND "${CMAKE_COMMAND}"
18                                 -DCMAKE_INSTALL_COMPONENT=cxxabi
19                                 -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
20                                 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
21   add_dependencies(cxx-test-depends install-cxxabi-test-suite-prefix)
22 endif()
24 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
25   add_custom_target(install-unwind-test-suite-prefix
26   DEPENDS unwind-headers
27           unwind
28   COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
29   COMMAND "${CMAKE_COMMAND}"
30           -DCMAKE_INSTALL_COMPONENT=unwind-headers
31           -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
32           -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
33   COMMAND "${CMAKE_COMMAND}"
34           -DCMAKE_INSTALL_COMPONENT=unwind
35           -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
36           -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
37   add_dependencies(cxx-test-depends install-unwind-test-suite-prefix)
38 endif()
40 add_custom_target(install-cxx-test-suite-prefix
41                       DEPENDS cxx-headers
42                               cxx
43                               cxx_experimental
44                               cxx-modules
45                       COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
46                       COMMAND "${CMAKE_COMMAND}"
47                               -DCMAKE_INSTALL_COMPONENT=cxx-headers
48                               -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
49                               -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
50                       COMMAND "${CMAKE_COMMAND}"
51                               -DCMAKE_INSTALL_COMPONENT=cxx-modules
52                               -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
53                               -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
54                       COMMAND "${CMAKE_COMMAND}"
55                               -DCMAKE_INSTALL_COMPONENT=cxx
56                               -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
57                               -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
58 add_dependencies(cxx-test-depends install-cxx-test-suite-prefix)
60 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
61 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
63 serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}")
65 if (LIBCXX_INCLUDE_BENCHMARKS)
66   add_subdirectory(benchmarks)
67   set(_libcxx_benchmark_mode "dry-run")
68 else()
69   serialize_lit_string_param(SERIALIZED_LIT_PARAMS enable_benchmarks "no")
70   set(_libcxx_benchmark_mode "no")
71 endif()
73 if (NOT LIBCXX_ENABLE_EXCEPTIONS)
74   serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
75 endif()
77 if (NOT LIBCXX_ENABLE_RTTI)
78   serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
79 endif()
81 serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}")
83 if (CMAKE_CXX_COMPILER_TARGET)
84   serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
85 else()
86   serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
87 endif()
89 if (LLVM_USE_SANITIZER)
90   serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
91 endif()
93 serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
95 include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
97 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
98                 "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
99                 @ONLY)
101 configure_lit_site_cfg(
102   "${LIBCXX_TEST_CONFIG}"
103   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
104   MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
106 add_lit_testsuite(check-cxx
107   "Running libcxx tests"
108   ${CMAKE_CURRENT_BINARY_DIR}
109   PARAMS enable_benchmarks="${_libcxx_benchmark_mode}"
110   DEPENDS cxx-test-depends)