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.
This commit is contained in:
Robert Maynard authored and Brad King committed 2022-07-29 14:05:55 -04:00
1 parent d566bd962d
commit 1aa95e1a3b
1 file changed
+1 -1
+1 -1
View File
@@ -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)