[Openmp-commits] [openmp] [OpenMP][omptest] Fix target dependency on runtimes GTest (PR #237200)
Jan Patrick Lehr via Openmp-commits
openmp-commits at lists.llvm.org
Fri Oct 30 05:31:10 PDT 2026
https://github.com/jplehr created https://github.com/llvm/llvm-project/pull/237200
Linking default_gtest PUBLIC puts it into omptest's link interface, so
install(EXPORT) fails with "requires target runtimes_gtest that is not in any
export set".
Only GTest's include directories and compile definitions are needed, and only
while building, so attach those behind BUILD_INTERFACE. Embedding the GTest
objects is unchanged.
---
<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
>From 169e8b0d1612beff144a390d873dad35718f86ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Halkenh=C3=A4user?=
<MichaelGerald.Halkenhauser at amd.com>
Date: Thu, 29 Oct 2026 16:49:22 -0500
Subject: [PATCH] [OpenMP][omptest] Fix target dependency on runtimes GTest
Linking default_gtest PUBLIC puts it into omptest's link interface, so
install(EXPORT) fails with "requires target runtimes_gtest that is not in any
export set".
Only GTest's include directories and compile definitions are needed, and only
while building, so attach those behind BUILD_INTERFACE. Embedding the GTest
objects is unchanged.
---
openmp/tools/omptest/CMakeLists.txt | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/openmp/tools/omptest/CMakeLists.txt b/openmp/tools/omptest/CMakeLists.txt
index f26e1947b4e24e..13dd5cc2ebbe81 100644
--- a/openmp/tools/omptest/CMakeLists.txt
+++ b/openmp/tools/omptest/CMakeLists.txt
@@ -82,10 +82,16 @@ if ((NOT LIBOMPTEST_BUILD_STANDALONE) OR LIBOMPTEST_BUILD_UNITTESTS)
$<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 PUBLIC default_gtest)
+ # Take GTest's include directories and compile definitions, and make them
+ # available to dependent targets such as the unit tests. BUILD_INTERFACE
+ # keeps default_gtest out of the link interface, which install(EXPORT)
+ # would otherwise require to be in an export set.
+ target_include_directories(omptest PUBLIC
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:default_gtest,INCLUDE_DIRECTORIES>>
+ )
+ target_compile_definitions(omptest PUBLIC
+ $<BUILD_INTERFACE:$<TARGET_PROPERTY:default_gtest,COMPILE_DEFINITIONS>>
+ )
# Link against Threads, which may be required for GTest.
# But keep it out of the link interface to avoid transitive dependencies.
More information about the Openmp-commits
mailing list