Allow building against system gtest

This commit is contained in:
Jordi Mallach 2023-06-14 15:16:01 +02:00
parent bd125733f0
commit 51d4eea7c5

View file

@ -1032,10 +1032,16 @@ include_directories("${PROJECT_BINARY_DIR}/Source/Core")
# Unit testing.
#
if(ENABLE_TESTS)
message(STATUS "Using static gtest from Externals")
find_package(GTest)
if (GTEST_FOUND)
message(STATUS "Using the system gtest")
include_directories(${GTEST_INCLUDE_DIRS})
else()
message(STATUS "Using static gtest from Externals")
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
endif()
# Force gtest to link the C runtime dynamically on Windows in order to avoid runtime mismatches.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
else()
message(STATUS "Unit tests are disabled")
endif()