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()