2023-10-04 15:11:37 -07:00
|
|
|
include(HandleLitArguments)
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 22:33:12 +02:00
|
|
|
add_subdirectory(tools)
|
|
|
|
|
2024-08-28 09:23:00 -04:00
|
|
|
# Install the library at a fake location so we can run the test suite against it.
|
|
|
|
# This ensures that we run the test suite against a setup that matches what we ship
|
|
|
|
# in production as closely as possible (in terms of file paths, rpaths, etc).
|
|
|
|
set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
|
|
|
|
if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
|
|
|
|
add_custom_target(install-cxxabi-test-suite-prefix
|
|
|
|
DEPENDS cxxabi-headers
|
|
|
|
cxxabi
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxxabi-headers
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxxabi
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
add_dependencies(cxx-test-depends install-cxxabi-test-suite-prefix)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
|
|
|
|
add_custom_target(install-unwind-test-suite-prefix
|
|
|
|
DEPENDS unwind-headers
|
|
|
|
unwind
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=unwind-headers
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=unwind
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
add_dependencies(cxx-test-depends install-unwind-test-suite-prefix)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(install-cxx-test-suite-prefix
|
|
|
|
DEPENDS cxx-headers
|
|
|
|
cxx
|
|
|
|
cxx_experimental
|
|
|
|
cxx-modules
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxx-headers
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxx-modules
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=cxx
|
|
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
|
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
add_dependencies(cxx-test-depends install-cxx-test-suite-prefix)
|
|
|
|
|
2015-07-30 22:30:34 +00:00
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
2021-06-01 17:16:11 -04:00
|
|
|
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
|
|
|
|
|
2024-05-28 18:29:47 -07:00
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}")
|
|
|
|
|
2024-11-07 09:07:50 -05:00
|
|
|
if (LIBCXX_INCLUDE_BENCHMARKS)
|
|
|
|
add_subdirectory(benchmarks)
|
|
|
|
set(_libcxx_benchmark_mode "dry-run")
|
|
|
|
else()
|
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS enable_benchmarks "no")
|
|
|
|
set(_libcxx_benchmark_mode "no")
|
|
|
|
endif()
|
|
|
|
|
2021-06-01 17:16:11 -04:00
|
|
|
if (NOT LIBCXX_ENABLE_EXCEPTIONS)
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
|
2021-06-01 17:16:11 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
|
2021-06-01 17:16:11 -04:00
|
|
|
endif()
|
|
|
|
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}")
|
2023-07-12 10:12:51 -07:00
|
|
|
|
2021-10-12 15:59:08 -04:00
|
|
|
if (CMAKE_CXX_COMPILER_TARGET)
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
|
2021-10-12 15:59:08 -04:00
|
|
|
else()
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
2021-06-01 17:16:11 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LLVM_USE_SANITIZER)
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
|
2021-06-01 17:16:11 -04:00
|
|
|
endif()
|
2015-07-30 22:30:34 +00:00
|
|
|
|
2023-10-04 15:11:37 -07:00
|
|
|
serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
|
[runtimes] Serialize all Lit params instead of passing them to add_lit_testsuite
add_lit_testsuite() takes Lit parameters passed to it and adds them
to the parameters used globally when running all test suites. That
means that a target like `check-all`, which ends up calling Lit on
the whole monorepo, will see the test parameters for all the individual
project's test suites.
So, for example, it would see `--param std=c++03` (from libc++abi), and
`--param std=c++03` (from libc++), and `--param whatever` (from another
project being tested at the same time). While always unclean, that works
when the parameters all agree. However, if the parameters share the same
name but have different values, only one of those two values will be used
and it will be incredibly confusing to understand why one of the test
suites is being run with the incorrect parameter value.
For that reason, this commit moves away from using add_lit_testsuite()'s
PARAM functionality, and serializes the parameter values for the runtimes
in the generated config.py file instead, which is local to the specific
test suite.
Differential Revision: https://reviews.llvm.org/D105991
2021-07-14 11:36:22 -04:00
|
|
|
|
2024-07-25 13:45:53 -05:00
|
|
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
|
2017-12-01 03:16:50 +00:00
|
|
|
|
2024-07-25 13:45:53 -05:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
|
|
|
@ONLY)
|
2021-09-30 13:23:39 -04:00
|
|
|
|
2024-07-25 13:45:53 -05:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
"${LIBCXX_TEST_CONFIG}"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
2017-12-01 03:16:50 +00:00
|
|
|
|
2024-07-25 13:45:53 -05:00
|
|
|
add_lit_testsuite(check-cxx
|
|
|
|
"Running libcxx tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
2024-11-07 09:07:50 -05:00
|
|
|
PARAMS enable_benchmarks="${_libcxx_benchmark_mode}"
|
2024-07-25 13:45:53 -05:00
|
|
|
DEPENDS cxx-test-depends)
|