Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 1 | include(HandleLitArguments) |
Nikolas Klauser | 841399a | 2022-08-13 20:33:12 | [diff] [blame] | 2 | add_subdirectory(tools) |
| 3 | |
Louis Dionne | 0e8208e | 2024-08-28 13:23:00 | [diff] [blame] | 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() |
| 23 | |
| 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() |
| 39 | |
| 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) |
| 59 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 | [diff] [blame] | 60 | set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 61 | set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n") |
| 62 | |
Louis Dionne | 633ea41 | 2024-05-29 01:29:47 | [diff] [blame] | 63 | serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}") |
| 64 | |
Louis Dionne | e236a52 | 2024-11-07 14:07:50 | [diff] [blame] | 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() |
| 72 | |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 73 | if (NOT LIBCXX_ENABLE_EXCEPTIONS) |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 74 | serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False) |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 75 | endif() |
| 76 | |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 77 | if (NOT LIBCXX_ENABLE_RTTI) |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 78 | serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False) |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 79 | endif() |
| 80 | |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 81 | serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}") |
varconst | d1367ca | 2023-07-12 17:12:51 | [diff] [blame] | 82 | |
Louis Dionne | 3ee0cec | 2021-10-12 19:59:08 | [diff] [blame] | 83 | if (CMAKE_CXX_COMPILER_TARGET) |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 84 | serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}") |
Louis Dionne | 3ee0cec | 2021-10-12 19:59:08 | [diff] [blame] | 85 | else() |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 86 | serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}") |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 87 | endif() |
| 88 | |
| 89 | if (LLVM_USE_SANITIZER) |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 90 | serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}") |
Louis Dionne | 58a2304 | 2021-06-01 21:16:11 | [diff] [blame] | 91 | endif() |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 | [diff] [blame] | 92 | |
Alexander Richardson | e5994229 | 2023-10-04 22:11:37 | [diff] [blame] | 93 | serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS) |
Louis Dionne | 0c3401c | 2021-07-14 15:36:22 | [diff] [blame] | 94 | |
Louis Dionne | 0307dd0 | 2024-07-25 18:45:53 | [diff] [blame] | 95 | include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite |
Petr Hosek | 363c631 | 2017-12-01 03:16:50 | [diff] [blame] | 96 | |
Louis Dionne | 0307dd0 | 2024-07-25 18:45:53 | [diff] [blame] | 97 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in" |
| 98 | "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg" |
| 99 | @ONLY) |
Louis Dionne | 19a3e24 | 2021-09-30 17:23:39 | [diff] [blame] | 100 | |
Louis Dionne | 0307dd0 | 2024-07-25 18:45:53 | [diff] [blame] | 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") |
Petr Hosek | 363c631 | 2017-12-01 03:16:50 | [diff] [blame] | 105 | |
Louis Dionne | 0307dd0 | 2024-07-25 18:45:53 | [diff] [blame] | 106 | add_lit_testsuite(check-cxx |
| 107 | "Running libcxx tests" |
| 108 | ${CMAKE_CURRENT_BINARY_DIR} |
Louis Dionne | e236a52 | 2024-11-07 14:07:50 | [diff] [blame] | 109 | PARAMS enable_benchmarks="${_libcxx_benchmark_mode}" |
Louis Dionne | 0307dd0 | 2024-07-25 18:45:53 | [diff] [blame] | 110 | DEPENDS cxx-test-depends) |