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
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)
24 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
25 add_custom_target(install-unwind-test-suite-prefix
26 DEPENDS unwind-headers
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)
40 add_custom_target(install-cxx-test-suite-prefix
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")
69 serialize_lit_string_param(SERIALIZED_LIT_PARAMS enable_benchmarks "no")
70 set(_libcxx_benchmark_mode "no")
73 if (NOT LIBCXX_ENABLE_EXCEPTIONS)
74 serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
77 if (NOT LIBCXX_ENABLE_RTTI)
78 serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
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}")
86 serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
89 if (LLVM_USE_SANITIZER)
90 serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
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"
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)