[Openmp-commits] [openmp] [OpenMP] Add libomp unit test infrastructure (PR #168063)
Michael Kruse via Openmp-commits
openmp-commits at lists.llvm.org
Tue Dec 2 14:29:50 PST 2025
================
@@ -174,17 +174,28 @@ if(NOT WIN32)
endif()
# Add the OpenMP library
-libomp_get_ldflags(LIBOMP_CONFIGURED_LDFLAGS)
+# 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})
+set_property(TARGET omp_objects PROPERTY FOLDER "OpenMP/Libraries")
+set_property(TARGET omp_objects PROPERTY POSITION_INDEPENDENT_CODE ON)
+# Export the omp_objects target so unit tests can use it
+set(LIBOMP_OBJECTS_TARGET omp_objects PARENT_SCOPE)
----------------
Meinersbur wrote:
```suggestion
```
CMake targets are always global. If `omp_objects` is not descriptive enough, rename it to `libomp_objects_target`. At least we don't need to worry about the scope of a `LIBOMP_OBJECTS_TARGET` variable.
Elsewhere in LLVM, the convention is to prefix the object library with `obj.`, i.e. `obj.omp`.
https://github.com/llvm/llvm-project/pull/168063
More information about the Openmp-commits
mailing list