[Openmp-commits] [openmp] [OpenMP] Add libomp unit test infrastructure (PR #168063)
Robert Imschweiler via Openmp-commits
openmp-commits at lists.llvm.org
Wed Dec 17 08:26:12 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}"
----------------
ro-i wrote:
I just used
https://github.com/llvm/llvm-project/blob/a3b79893da47275dc374b0139645c7ebe7c2e2d2/openmp/runtime/src/CMakeLists.txt#L233-L237
https://github.com/llvm/llvm-project/pull/168063
More information about the Openmp-commits
mailing list