[libcxx-commits] [libcxx] [libcxxabi] [libc++] Simplify how we install test-suite dependencies (PR #171504)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 9 12:56:04 PST 2025


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/171504

Based on comments in #171474, it was brought to my attention that we can modernize and simplify how we perform the test suite installation in libc++ and libc++abi.

>From e265029b4d56fc6b6ea5579c476ff009ec05f59e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 15:52:55 -0500
Subject: [PATCH] [libc++] Simplify how we install test-suite dependencies

Based on comments in #171474, it was brought to my attention that
we can modernize and simplify how we perform the test suite installation
in libc++ and libc++abi.
---
 libcxx/test/CMakeLists.txt    | 57 ++++++---------------------------
 libcxxabi/test/CMakeLists.txt | 59 +++++++----------------------------
 2 files changed, 22 insertions(+), 94 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index f4e577aed57de..57474f92a4bfd 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -5,57 +5,20 @@ add_subdirectory(tools)
 # 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")
+set(libcxx_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules)
 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)
+  list(APPEND libcxx_test_suite_install_targets cxxabi-headers cxxabi)
 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)
+  list(APPEND libcxx_test_suite_install_targets unwind-headers unwind)
 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)
+foreach(target IN LISTS libcxx_test_suite_install_targets)
+  add_custom_target(libcxx-test-suite-install-${target} DEPENDS "${target}"
+                    COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
+                                               --prefix "${LIBCXX_TESTING_INSTALL_PREFIX}"
+                                               --component "${target}")
+  add_dependencies(cxx-test-depends libcxx-test-suite-install-${target})
+endforeach()
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index 9eabfb08240b6..021bd7cc959e2 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -8,56 +8,21 @@ macro(pythonize_bool var)
   endif()
 endmacro()
 
+# Install the library and its dependencies 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(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)
-
+set(libcxxabi_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
 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)
+  list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()
+foreach(target IN LISTS libcxxabi_test_suite_install_targets)
+  add_custom_target(libcxxabi-test-suite-install-${target} DEPENDS "${target}"
+                    COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
+                                               --prefix "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
+                                               --component "${target}")
+  add_dependencies(cxxabi-test-depends libcxxabi-test-suite-install-${target})
+endforeach()
 
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 



More information about the libcxx-commits mailing list