From 51d4eea7c5241b3b595740626c5925f08a546cd2 Mon Sep 17 00:00:00 2001 From: Jordi Mallach Date: Wed, 14 Jun 2023 15:16:01 +0200 Subject: [PATCH] Allow building against system gtest --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d72091752..3b9b324fc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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()