[Openmp-commits] [openmp] [OpenMP][omptest] Improve CMake and address review comments (PR #159416)
Michael Halkenhäuser via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jan 19 11:08:29 PST 2026
================
@@ -65,34 +73,39 @@ if ((NOT LIBOMPTEST_BUILD_STANDALONE) OR LIBOMPTEST_BUILD_UNITTESTS)
set(LIBOMPTEST_BUILD_STANDALONE OFF)
endif()
- # Add dependency llvm_gtest; emits error if unavailable.
- 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)
+ message(STATUS "omptest build mode: GTest-based")
- # Add LLVM-provided GoogleTest include directories.
- target_include_directories(omptest PRIVATE
- ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include)
-
- # TODO: Re-visit ABI breaking checks, disable for now.
- target_compile_definitions(omptest PUBLIC
- -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING)
-
- # Link against gtest and gtest_main
- target_link_libraries(omptest PRIVATE ${GTEST_LINK_CMD})
+ # Add GoogleTest-based header and embed GTest symbols into the shared lib.
+ # Merging of GTest is desired, such that omptest is self-contained and
+ # independent of external GTest installations.
+ target_sources(omptest PRIVATE
+ $<TARGET_OBJECTS:default_gtest>
+ )
+
+ # Link against the default GTest which at this point primarily pulls in the
+ # include directories and compile definitions. It is important to make these
+ # available to dependant targets, e.g. for unit tests.
+ target_link_libraries(omptest INTERFACE default_gtest)
----------------
mhalk wrote:
Buildbot issue was that for `omptest` the GTest headers were pulled from the system (e.g. `gtest/gtest.h`) instead of the LLVM-tree (as intended).
This already worked for the unit tests (this target used the LLVM-tree).
The fix is minimal: changing `INTERFACE` to `PUBLIC` is sufficient, so both targets use the LLVM-tree.
https://github.com/llvm/llvm-project/pull/159416
More information about the Openmp-commits
mailing list