Skip to content

Commit f3ade2a

Browse files
hageboeckvgvassilev
authored andcommitted
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.
1 parent 3ead778 commit f3ade2a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

unittests/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ set(CTEST_BUILD_NAME
33
enable_testing()
44

55
# LLVM builds (not installed llvm) provides gtest.
6-
if (NOT TARGET gtest)
6+
if (NOT TARGET GTest::gtest AND NOT TARGET gtest)
77
include(GoogleTest)
88
endif()
99

1010
if(EMSCRIPTEN)
11-
set(gtest_libs gtest gmock)
11+
if (TARGET GTest::gtest)
12+
# Target names in CMake >= v3.23
13+
set(gtest_libs GTest::gtest GTest::gmock)
14+
else()
15+
set(gtest_libs gtest gmock)
16+
endif()
1217
else()
13-
set(gtest_libs gtest gtest_main)
14-
if (TARGET gmock)
15-
list(APPEND gtest_libs gmock gmock_main)
18+
if (TARGET GTest::gtest)
19+
# Target names in CMake >= v3.23
20+
set(gtest_libs GTest::gtest GTest::gmock GTest::gtest_main)
21+
else()
22+
set(gtest_libs gtest gtest_main gmock)
1623
endif()
1724
set(link_pthreads_lib pthread)
1825
endif()

0 commit comments

Comments
 (0)