From 9c6485a37c331243b12e642bdd8debc90c9bb4fd Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 24 Jun 2025 13:38:13 +0200 Subject: [PATCH] Make CppInterOp work with new gtest target names. Starting from CMake v3.23, one can use GTest::gtest and similar in CMake. Since the root-project wants to move to these targets, Interop should work with both the new or the old target names in order not to start building its own gtest. --- interpreter/CppInterOp/unittests/CMakeLists.txt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/interpreter/CppInterOp/unittests/CMakeLists.txt b/interpreter/CppInterOp/unittests/CMakeLists.txt index 0ea65be871ba1..f13b85f68f497 100644 --- a/interpreter/CppInterOp/unittests/CMakeLists.txt +++ b/interpreter/CppInterOp/unittests/CMakeLists.txt @@ -3,16 +3,23 @@ set(CTEST_BUILD_NAME enable_testing() # LLVM builds (not installed llvm) provides gtest. -if (NOT TARGET gtest) +if (NOT TARGET GTest::gtest AND NOT TARGET gtest) include(GoogleTest) endif() if(EMSCRIPTEN) - set(gtest_libs gtest gmock) + if (TARGET GTest::gtest) + # Target names in CMake >= v3.23 + set(gtest_libs GTest::gtest GTest::gmock) + else() + set(gtest_libs gtest gmock) + endif() else() - set(gtest_libs gtest gtest_main) - if (TARGET gmock) - list(APPEND gtest_libs gmock gmock_main) + if (TARGET GTest::gtest) + # Target names in CMake >= v3.23 + set(gtest_libs GTest::gtest GTest::gmock GTest::gtest_main) + else() + set(gtest_libs gtest gtest_main gmock) endif() set(link_pthreads_lib pthread) endif()