llvm-project/libcxxabi/test/CMakeLists.txt
Louis Dionne 2121b961fd
[libc++abi][libunwind] Run c++abi and unwind tests against a fake install root (#110171)
This is what we started doing in libc++ and it straightens up a lot of
things that only happened to work before, notably the presence of
relative rpaths in dylibs when running from the build tree.

This unlocks the ability to link against a just-built dylib but run
against another version of the dylib (for example the system-provided
one), which is necessary for proper backdeployment testing.

This patch adds a lot of code duplication between the libc++ and
libc++abi testing setups. However, there is already a large amount of
duplication and the only real way to get rid of it is to merge libc++abi
into libc++. In a way, this patch is a step in that direction because it
closes the gap between the two libraries' testing setup.
2024-09-30 11:57:35 -04:00

103 lines
4.5 KiB
CMake

include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
include(HandleLitArguments)
macro(pythonize_bool var)
if (${var})
set(${var} True)
else()
set(${var} False)
endif()
endmacro()
set(LIBCXXABI_TESTING_INSTALL_PREFIX "${LIBCXXABI_BINARY_DIR}/test-suite-install")
add_custom_target(libcxxabi-install-cxx-for-testing
DEPENDS cxx-headers
cxx
cxx_experimental
cxx-modules
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxx-headers
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxx-modules
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxx
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_dependencies(cxxabi-test-depends libcxxabi-install-cxx-for-testing)
add_custom_target(libcxxabi-install-cxxabi-for-testing
DEPENDS cxxabi-headers
cxxabi
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxxabi-headers
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxxabi
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_dependencies(cxxabi-test-depends libcxxabi-install-cxxabi-for-testing)
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
add_custom_target(libcxxabi-install-unwind-for-testing
DEPENDS unwind-headers
unwind
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=unwind-headers
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=unwind
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_dependencies(cxxabi-test-depends libcxxabi-install-unwind-for-testing)
endif()
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}")
if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
endif()
if (LIBCXXABI_ENABLE_ASSERTIONS)
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_assertions True)
endif()
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_experimental False)
if (LLVM_USE_SANITIZER)
serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
endif()
if (CMAKE_CXX_COMPILER_TARGET)
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
else()
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
endif()
serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXXABI_TEST_PARAMS)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
@ONLY)
configure_lit_site_cfg(
"${LIBCXXABI_TEST_CONFIG}"
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
add_lit_testsuite(check-cxxabi "Running libcxxabi tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxxabi-test-depends)