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
2022-07-29 11:34:32 -04:00
committed by Brad King
parent d566bd962d
commit 1aa95e1a3b

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)