[Openmp-commits] [openmp] Reland: [OpenMP] Add ompTest library to OpenMP (PR #154786)
Michael Halkenhäuser via Openmp-commits
openmp-commits at lists.llvm.org
Tue Sep 16 05:31:34 PDT 2025
================
@@ -0,0 +1,154 @@
+##===----------------------------------------------------------------------===##
+#
+# Build OMPT unit testing library: ompTest
+#
+##===----------------------------------------------------------------------===##
+
+cmake_minimum_required(VERSION 3.20)
+project(omptest LANGUAGES CXX)
+
+option(LIBOMPTEST_BUILD_STANDALONE
+ "Build ompTest 'standalone', i.e. w/o GoogleTest."
+ ${OPENMP_STANDALONE_BUILD})
+option(LIBOMPTEST_BUILD_UNITTESTS
+ "Build ompTest's unit tests, requires GoogleTest." OFF)
+
+# In absence of corresponding OMPT support: exit early
+if(NOT ${LIBOMP_OMPT_SUPPORT})
+ return()
+endif()
+
+include(CMakePackageConfigHelpers)
+
+set(OMPTEST_HEADERS
+ ./include/AssertMacros.h
+ ./include/InternalEvent.h
+ ./include/InternalEventCommon.h
+ ./include/Logging.h
+ ./include/OmptAliases.h
+ ./include/OmptAsserter.h
+ ./include/OmptAssertEvent.h
+ ./include/OmptCallbackHandler.h
+ ./include/OmptTester.h
+ ./include/OmptTesterGlobals.h
+)
+
+add_library(omptest
+ SHARED
+
+ ${OMPTEST_HEADERS}
+ ./src/InternalEvent.cpp
+ ./src/InternalEventOperators.cpp
+ ./src/Logging.cpp
+ ./src/OmptAsserter.cpp
+ ./src/OmptAssertEvent.cpp
+ ./src/OmptCallbackHandler.cpp
+ ./src/OmptTester.cpp
+)
+
+# Target: ompTest library
+# On (implicit) request of GoogleTest, link against the one provided with LLVM.
+if ((NOT LIBOMPTEST_BUILD_STANDALONE) OR LIBOMPTEST_BUILD_UNITTESTS)
+ # Check if standalone build was requested together with unittests
+ if (LIBOMPTEST_BUILD_STANDALONE)
+ # Emit warning: this build actually depends on LLVM's GoogleTest
+ message(WARNING "LIBOMPTEST_BUILD_STANDALONE and LIBOMPTEST_BUILD_UNITTESTS"
+ " requested simultaneously.\n"
+ "Linking against LLVM's GoogleTest library archives.\n"
+ "Disable LIBOMPTEST_BUILD_UNITTESTS to perform an actual"
+ " standalone build.")
+ # Explicitly disable LIBOMPTEST_BUILD_STANDALONE
+ set(LIBOMPTEST_BUILD_STANDALONE OFF)
+ endif()
+
+ # Make sure target llvm_gtest is available
+ if (NOT TARGET llvm_gtest)
+ message(FATAL_ERROR "Required target not found: llvm_gtest")
+ endif()
+
+ # Add llvm_gtest as dependency
+ add_dependencies(omptest llvm_gtest)
+
+ # Link llvm_gtest as whole-archive to expose required symbols
+ set(GTEST_LINK_CMD "-Wl,--whole-archive" llvm_gtest
+ "-Wl,--no-whole-archive" LLVMSupport)
+
+ # Add GoogleTest-based header
+ target_sources(omptest PRIVATE ./include/OmptTesterGoogleTest.h)
+
+ # Add LLVM-provided GoogleTest include directories.
+ target_include_directories(omptest PRIVATE
+ ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include)
----------------
mhalk wrote:
Yes, I think you're right. AFAICT this can be removed.
https://github.com/llvm/llvm-project/pull/154786
More information about the Openmp-commits
mailing list