[Openmp-commits] [openmp] [OpenMP] Add libomp unit test infrastructure (PR #168063)

Michael Kruse via Openmp-commits openmp-commits at lists.llvm.org
Wed Dec 17 06:09:00 PST 2025


================
@@ -0,0 +1,63 @@
+add_custom_target(OpenMPUnitTests)
+set_target_properties(OpenMPUnitTests PROPERTIES FOLDER "OpenMP/Tests")
+
+if(WIN32 OR STUBS_LIBRARY)
+  message(WARNING "OpenMP unittests disabled due to stub library or Windows")
+  return()
+endif()
+
+# Build a testing version of libomp that exports all symbols for unit tests.
+# This library uses the same compiled objects as libomp, but with all symbols
+# exported to allow testing internal functions.
+
+libomp_get_ldflags(LIBOMP_TEST_LDFLAGS FOR_UNITTESTS)
+libomp_get_libflags(LIBOMP_TEST_LIBFLAGS)
+
+# Create the testing library from the same objects as libomp.
+add_library(omp_testing SHARED $<TARGET_OBJECTS:obj.omp>)
+set_property(TARGET omp_testing PROPERTY FOLDER "OpenMP/Libraries")
+target_link_libraries(omp_testing PUBLIC default_gtest)
+target_link_libraries(omp_testing PUBLIC ${LIBOMP_TEST_LIBFLAGS} ${LIBOMP_DL_LIBS})
+set_target_properties(omp_testing PROPERTIES
+  PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"
----------------
Meinersbur wrote:

```suggestion
  PREFIX "" 
  SUFFIX "" 
  OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"
```

Why override SUFFIX/PREFIX? Would
```
  PREFIX ""
  SUFFIX "${LIBOMP_LIBRARY_SUFFIX}"
```
get the same result?

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


More information about the Openmp-commits mailing list