[Openmp-commits] [openmp] [OpenMP] Add `OPENMP_INCLUDE_TESTS` (PR #143390)

Ross Brunton via Openmp-commits openmp-commits at lists.llvm.org
Fri Aug 8 06:18:41 PDT 2025


https://github.com/RossBrunton updated https://github.com/llvm/llvm-project/pull/143390

>From 88f2c31177e5157f8516f62654a4f33b31ffe7bc Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Mon, 9 Jun 2025 16:09:56 +0100
Subject: [PATCH 1/2] [OpenMP] Add `OPENMP_INCLUDE_TESTS`

This is a cmake variable which, if set to `OFF`, will disable building of
tests. It defaults to the value of `LLVM_INCLUDE_TESTS`.
---
 openmp/CMakeLists.txt                 | 10 ++++++++--
 openmp/libompd/CMakeLists.txt         |  8 ++++----
 openmp/runtime/CMakeLists.txt         |  4 +++-
 openmp/tools/archer/CMakeLists.txt    |  4 +++-
 openmp/tools/multiplex/CMakeLists.txt |  4 +++-
 5 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index edd79df7fb767..7f9e625381ea3 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -17,6 +17,8 @@ else()
   set(OPENMP_STANDALONE_BUILD FALSE)
 endif()
 
+option(OPENMP_INCLUDE_TESTS "Generate and build openmp tests." ${LLVM_INCLUDE_TESTS})
+
 # Must go below project(..)
 include(GNUInstallDirs)
 
@@ -104,7 +106,9 @@ include(config-ix)
 include(HandleOpenMPOptions)
 
 # Set up testing infrastructure.
-include(OpenMPTesting)
+if(OPENMP_INCLUDE_TESTS)
+  include(OpenMPTesting)
+endif()
 
 set(OPENMP_TEST_FLAGS "" CACHE STRING
   "Extra compiler flags to send to the test compiler.")
@@ -164,4 +168,6 @@ add_subdirectory(libompd)
 add_subdirectory(docs)
 
 # Now that we have seen all testsuites, create the check-openmp target.
-construct_check_openmp_target()
+if(OPENMP_INCLUDE_TESTS)
+  construct_check_openmp_target()
+endif()
diff --git a/openmp/libompd/CMakeLists.txt b/openmp/libompd/CMakeLists.txt
index e5373318784ce..59b200ec294b5 100644
--- a/openmp/libompd/CMakeLists.txt
+++ b/openmp/libompd/CMakeLists.txt
@@ -18,9 +18,9 @@ if(LIBOMP_OMPD_SUPPORT)
     add_subdirectory(src)
     if(LIBOMP_OMPD_GDB_SUPPORT)
         add_subdirectory(gdb-plugin)
-		# GDB is required to run the tests
-		if (GDB_FOUND)
-	        add_subdirectory(test)
-		endif()
+        # GDB is required to run the tests
+        if (GDB_FOUND AND OPENMP_INCLUDE_TESTS)
+            add_subdirectory(test)
+        endif()
     endif()
 endif()
diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt
index b6c4759ec03f7..d017fec5b5d2f 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -468,7 +468,9 @@ if(${OPENMP_STANDALONE_BUILD})
 endif()
 
 add_subdirectory(src)
-add_subdirectory(test)
+if(OPENMP_INCLUDE_TESTS)
+  add_subdirectory(test)
+endif()
 
 # make these variables available for tools:
 set(LIBOMP_LIBRARY_DIR ${LIBOMP_LIBRARY_DIR} PARENT_SCOPE)
diff --git a/openmp/tools/archer/CMakeLists.txt b/openmp/tools/archer/CMakeLists.txt
index 980eb2b0b675f..ad3795bb96450 100644
--- a/openmp/tools/archer/CMakeLists.txt
+++ b/openmp/tools/archer/CMakeLists.txt
@@ -19,5 +19,7 @@ if(LIBOMP_OMPT_SUPPORT AND LIBOMP_ARCHER_SUPPORT)
     LIBRARY DESTINATION ${OPENMP_INSTALL_LIBDIR}
     ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})
 
-  add_subdirectory(tests)
+  if(OPENMP_INCLUDE_TESTS)
+    add_subdirectory(tests)
+  endif()
 endif()
diff --git a/openmp/tools/multiplex/CMakeLists.txt b/openmp/tools/multiplex/CMakeLists.txt
index afc7fc5aa44ad..f44aa04f4354c 100644
--- a/openmp/tools/multiplex/CMakeLists.txt
+++ b/openmp/tools/multiplex/CMakeLists.txt
@@ -6,5 +6,7 @@ if(LIBOMP_OMPT_SUPPORT)
 
   install(FILES ompt-multiplex.h DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}")
 
-  add_subdirectory(tests)
+  if(OPENMP_INCLUDE_TESTS)
+    add_subdirectory(tests)
+  endif()
 endif()

>From 25da6327d7934b06db83f735ba237baea1011140 Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Fri, 8 Aug 2025 14:17:29 +0100
Subject: [PATCH 2/2] Small cleanup and docs

---
 openmp/CMakeLists.txt | 4 ++--
 openmp/README.rst     | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 7f9e625381ea3..d2efc5e4e7c52 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -13,12 +13,12 @@ list(INSERT CMAKE_MODULE_PATH 0
 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   set(OPENMP_STANDALONE_BUILD TRUE)
   project(openmp C CXX ASM)
+  option(OPENMP_INCLUDE_TESTS "Generate and build openmp tests." ON)
 else()
   set(OPENMP_STANDALONE_BUILD FALSE)
+  option(OPENMP_INCLUDE_TESTS "Generate and build openmp tests." ${LLVM_INCLUDE_TESTS})
 endif()
 
-option(OPENMP_INCLUDE_TESTS "Generate and build openmp tests." ${LLVM_INCLUDE_TESTS})
-
 # Must go below project(..)
 include(GNUInstallDirs)
 
diff --git a/openmp/README.rst b/openmp/README.rst
index 2dfc8630858b8..382bda88a3bb8 100644
--- a/openmp/README.rst
+++ b/openmp/README.rst
@@ -123,6 +123,10 @@ Options for all Libraries
   Compiler to use for testing. Defaults to the compiler that was also used for
   building. Will default to flang if build is in-tree.
 
+**OPENMP_INCLUDE_TESTS** = ``${LLVM_INCLUDE_TESTS}``
+  Enable generation and build of test suite. Defaults to ``LLVM_INCLUDE_TESTS``
+  if built as part of LLVM, otherwise defaults to ``ON``.
+
 **OPENMP_LLVM_TOOLS_DIR** = ``/path/to/built/llvm/tools``
   Additional path to search for LLVM tools needed by tests.
 



More information about the Openmp-commits mailing list