Skip to content

Commit

Permalink
Ensure find and link gmock for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkmgit authored Feb 27, 2023
1 parent 648ff8d commit 6acb47c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 6acb47c

Please # to comment.