[Openmp-commits] [openmp] [OpenMP][ompTest] Guard installation of all components (PR #155433)

Michael Halkenhäuser via Openmp-commits openmp-commits at lists.llvm.org
Tue Aug 26 08:16:34 PDT 2025


https://github.com/mhalk created https://github.com/llvm/llvm-project/pull/155433

Make installation of ompTest optional via:
-DLIBOMPTEST_INSTALL_COMPONENTS=ON (default: OFF)

>From 5d81bc8b6ad3953a678b8c199b480a16c77f982c Mon Sep 17 00:00:00 2001
From: Michael Halkenhaeuser <MichaelGerald.Halkenhauser at amd.com>
Date: Tue, 26 Aug 2025 10:08:22 -0500
Subject: [PATCH] [OpenMP][ompTest] Guard installation of all components

Make installation of ompTest optional via:
-DLIBOMPTEST_INSTALL_COMPONENTS=ON (default: OFF)
---
 openmp/tools/omptest/CMakeLists.txt | 65 ++++++++++++++++-------------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/openmp/tools/omptest/CMakeLists.txt b/openmp/tools/omptest/CMakeLists.txt
index 10c0cd98ccbc2..56b4443c497d7 100644
--- a/openmp/tools/omptest/CMakeLists.txt
+++ b/openmp/tools/omptest/CMakeLists.txt
@@ -12,6 +12,8 @@ option(LIBOMPTEST_BUILD_STANDALONE
        ${OPENMP_STANDALONE_BUILD})
 option(LIBOMPTEST_BUILD_UNITTESTS
        "Build ompTest's unit tests, requires GoogleTest." OFF)
+option(LIBOMPTEST_INSTALL_COMPONENTS
+       "Install ompTest library, headers and package files." OFF)
 
 # Exit early if OMPT support or LLVM-tests were disabled by the user.
 if((NOT ${LIBOMP_OMPT_SUPPORT}) OR (NOT ${LLVM_INCLUDE_TESTS}))
@@ -112,36 +114,39 @@ target_include_directories(omptest PUBLIC
 
 target_compile_features(omptest PRIVATE cxx_std_17)
 
-# Create and install package configuration files.
-configure_package_config_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/omptest-config.cmake.in
-  ${CMAKE_CURRENT_BINARY_DIR}/cmake/omptest-config.cmake
-  INSTALL_DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest"
-)
-
-install(FILES ${omptest_BINARY_DIR}/cmake/omptest-config.cmake
-        DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest")
-
-# Install libomptest header files: Copy header-files from include dir
-install(DIRECTORY ./include/
-        DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest"
-        FILES_MATCHING PATTERN "*.h")
-
-# Install library and export targets.
-# Note: find_package(omptest) may require setting of PATH_SUFFIXES
-#       Example: "lib/cmake/openmp/omptest", this is due to the install location
-install(TARGETS omptest
-        EXPORT OPENMPomptest
-        LIBRARY COMPONENT omptest
-        DESTINATION "${OPENMP_INSTALL_LIBDIR}"
-        INCLUDES DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest")
-
-# Allow to link omptest by using: target_link_libraries( ... omptest::omptest)
-# Additionally, it automatically propagates the include directory.
-install(EXPORT OPENMPomptest
-        DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest"
-        NAMESPACE omptest::
-        FILE omptest-targets.cmake)
+# Perform installation only if requested by the user.
+if(LIBOMPTEST_INSTALL_COMPONENTS)
+  # Create and install package configuration files.
+  configure_package_config_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/omptest-config.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/cmake/omptest-config.cmake
+    INSTALL_DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest"
+  )
+
+  install(FILES ${omptest_BINARY_DIR}/cmake/omptest-config.cmake
+          DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest")
+
+  # Install libomptest header files: Copy header-files from include dir
+  install(DIRECTORY ./include/
+          DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest"
+          FILES_MATCHING PATTERN "*.h")
+
+  # Install library and export targets.
+  # Note: find_package(omptest) may require setting of PATH_SUFFIXES
+  #       Example: "lib/cmake/openmp/omptest", this is due to the install location
+  install(TARGETS omptest
+          EXPORT OPENMPomptest
+          LIBRARY COMPONENT omptest
+          DESTINATION "${OPENMP_INSTALL_LIBDIR}"
+          INCLUDES DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest")
+
+  # Allow to link omptest by using: target_link_libraries( ... omptest::omptest)
+  # Additionally, it automatically propagates the include directory.
+  install(EXPORT OPENMPomptest
+          DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest"
+          NAMESPACE omptest::
+          FILE omptest-targets.cmake)
+endif()
 
 # Discover unit tests (added to check-openmp)
 if(LIBOMPTEST_BUILD_UNITTESTS)



More information about the Openmp-commits mailing list