[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:47:21 PDT 2025


================
@@ -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"
+  )
----------------
mhalk wrote:

Good point, thank you!

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


More information about the Openmp-commits mailing list