[Openmp-commits] [openmp] [OpenMP] Add libomp unit test infrastructure (PR #168063)
Robert Imschweiler via Openmp-commits
openmp-commits at lists.llvm.org
Sat Nov 15 05:26:19 PST 2025
================
@@ -174,17 +174,26 @@ if(NOT WIN32)
endif()
# Add the OpenMP library
+
+# First, create an OBJECT library with all the runtime sources.
+# This allows both the main library and unit tests to link against the same compiled objects.
+add_library(omp_objects OBJECT ${LIBOMP_SOURCE_FILES})
----------------
ro-i wrote:
I think so, yes. Because the object files have to be linked statically to build libomp, otherwise libomp would be linked against some random object files in a build folder, which would be very bad.
My general goal was to use the same object stuff that is used to build libomp for building the unittests. (So that failures are relevant and do not depend on different compile options/definitions or whatever.) And, as far as I understand, this change makes this possible.
Alternatives included pulling selected files from libomp (e.g., kmp_str.cpp) into the unittest building, but due to dependency hell, this would basically result in most of libomp and would be very bad style imho.
If someone knows a better way to do this, I would be more than happy! My experience with CMake is still limited :)
https://github.com/llvm/llvm-project/pull/168063
More information about the Openmp-commits
mailing list