From f7f5430f3e027519ac27dba20988b9fc6e1d7d18 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Thu, 8 Jul 2021 19:25:23 +0200 Subject: [PATCH] [PATCH 1/2] cmake: always set GTEST_LIBRARY if it isn't Previously, the GTEST_LIBRARY would only be set manually set when GMock is not built from source, causing likage failures on systems where Gmock is built from source and system-provided GTest does not set it. cc #205 Gbp-Pq: Name 0001-cmake-always-set-GTEST_LIBRARY-if-it-isn-t.patch --- cmake/FindGtestGmock.cmake | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmake/FindGtestGmock.cmake b/cmake/FindGtestGmock.cmake index a57fed8..359f9ab 100644 --- a/cmake/FindGtestGmock.cmake +++ b/cmake/FindGtestGmock.cmake @@ -39,6 +39,12 @@ if (NOT GTEST_FOUND) find_package_handle_standard_args(GTest GTEST_LIBRARY GTEST_BOTH_LIBRARIES GTEST_INCLUDE_DIRS) endif() +# Upstream GTestConfig.cmake doesn't provide GTEST_LIBRARY but GTEST_LIBRARIES +# CMake 3.20+ uses the upstream gtest config if possible. +if (NOT DEFINED GTEST_LIBRARY) + set(GTEST_LIBRARY ${GTEST_LIBRARIES}) +endif() + find_file(GMOCK_SOURCE NAMES gmock-all.cc DOC "GMock source" @@ -63,11 +69,6 @@ if (EXISTS ${GMOCK_SOURCE}) else() # Assume gmock is no longer source, we'll find out soon enough if that's wrong add_custom_target(GMock) - # Upstream GTestConfig.cmake doesn't provide GTEST_LIBRARY but GTEST_LIBRARIES - # CMake 3.20+ uses the upstream gtest config if possible. - if (NOT DEFINED GTEST_LIBRARY) - set(GTEST_LIBRARY ${GTEST_LIBRARIES}) - endif() string(REPLACE gtest gmock GMOCK_LIBRARY ${GTEST_LIBRARY}) endif() -- 2.30.2