From 6acb47c8dcf092816ea9155eacac4507766d57c3 Mon Sep 17 00:00:00 2001 From: Benson Muite Date: Mon, 27 Feb 2023 20:08:29 +0300 Subject: [PATCH] Ensure find and link gmock for tests --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ef94820..395e8f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,9 +161,10 @@ option(PARLAY_TEST "Build unit tests" OFF) if (PARLAY_TEST) find_package(GTest) - if(NOT GTest_FOUND) + find_library(GMock NAME gmock gmock_main) + if(NOT GTest_FOUND OR GMock-NOTFOUND) if(FETCH_CONTENT_FULLY_DISCONNECTED) - message(FATAL_ERROR "GoogleTest not found, enable downloads or install it") + message(FATAL_ERROR "GoogleTest/GoogleMock not found, enable downloads or install them") else() # Set CMake options for GoogleTest set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) @@ -175,6 +176,7 @@ if (PARLAY_TEST) FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG main + FIND_PACKAGE_ARGS NAMES GTest ) FetchContent_GetProperties(googletest) if(NOT googletest_POPULATED) @@ -190,12 +192,14 @@ if (PARLAY_TEST) # Include test targets message(STATUS "testing: Enabled") include(CTest) + link_libraries(gmock gmock_main gtest gtest_main) add_subdirectory(test) else() message(STATUS "testing: Disabled (enable with -DPARLAY_TEST=On)") endif() + # ------------------------------------------------------------------- # Benchmarks