From 1aa95e1a3b0f29ca35554b1bb003f714c315e047 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 29 Jul 2022 11:34:32 -0400 Subject: FindGTest: Create the gmock targets only when GTest has been found When we introduced the `GTest::gmock` and `GTest::gmock_main` targets in commit 50bf457a0d (FindGTest: Add target for gmock library, 2021-10-17, v3.23.0-rc1~321^2) we failed to handle the case where GTest isn't found. Don't construct gmock targets that depend on non-existent gtest targets when gtest failed to be found. --- Modules/FindGTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 60bb401..92334e4 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -314,7 +314,7 @@ if(GTest_FOUND) __gtest_define_backwards_compatible_library_targets() endif() -if(GMock_FOUND) +if(GMock_FOUND AND GTest_FOUND) if(NOT TARGET GTest::gmock) __gtest_determine_library_type(GMOCK_LIBRARY) add_library(GTest::gmock ${GMOCK_LIBRARY_TYPE} IMPORTED) -- cgit v0.12