[Openmp-commits] [openmp] [openmp][cmake] Don't glob for source files (PR #165231)

Michael Kruse via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 27 03:38:06 PDT 2025


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/165231

LLVM's cmake standard explicitly lists all source in the CMakeLists.txt. Remove globbing for source files in OpenMP's CMakeLists.txt.

Also see #71404 and CMake's recomandation at https://cmake.org/cmake/help/latest/command/file.html#glob. Two reasons to not glob for source files is that it breaks bisecting and incremental buildbots. Renaming a file, reverting or checking out an older reversion where a newly added source file disappears again will not trigger a CMake configure step and make the build fail because of an non-existing source file.

>From 59fa4e730becea99c4e0d9371b6598020400430b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 27 Oct 2025 10:45:40 +0100
Subject: [PATCH 1/2] [openmp] Explicit CMake dependencies

---
 openmp/tools/CMakeLists.txt | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/openmp/tools/CMakeLists.txt b/openmp/tools/CMakeLists.txt
index eefbbf3376445..df3d381063ca2 100644
--- a/openmp/tools/CMakeLists.txt
+++ b/openmp/tools/CMakeLists.txt
@@ -1,9 +1,4 @@
-# Discover the tools that use CMake in the subdirectories.
-# Note that explicit cmake invocation is required every time a new tool
-# is added or removed.
-file(GLOB entries *)
-foreach(entry ${entries})
-  if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
-    add_subdirectory(${entry})
-  endif()
-endforeach(entry)
+add_subdirectory(archer)
+add_subdirectory(Modules)
+add_subdirectory(multiplex)
+add_subdirectory(omptest)

>From 53fe3de99967c6d6ee2f4d968906a48c539e0dcd Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 27 Oct 2025 11:25:43 +0100
Subject: [PATCH 2/2] [openmp] Explicit source files

---
 openmp/tools/omptest/test/CMakeLists.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/openmp/tools/omptest/test/CMakeLists.txt b/openmp/tools/omptest/test/CMakeLists.txt
index 427893313cc67..1e07a1044f7d6 100644
--- a/openmp/tools/omptest/test/CMakeLists.txt
+++ b/openmp/tools/omptest/test/CMakeLists.txt
@@ -5,7 +5,13 @@
 ##===----------------------------------------------------------------------===##
 
 # Target: ompTest library unit tests
-file(GLOB UNITTEST_SOURCES "unittests/*.cpp")
+set(UNITTEST_SOURCES
+  unittests/asserter-seq-test.cpp
+  unittests/internal-event-eq-test.cpp
+  unittests/internal-event-tostring-test.cpp
+  unittests/internal-util-test
+  unittests/main-test.cpp
+)
 add_executable(omptest-unittests ${UNITTEST_SOURCES})
 
 # Add local and LLVM-provided GoogleTest include directories.



More information about the Openmp-commits mailing list