Merge pull request #11950 from jmallach/gtest

Allow building against system gtest
This commit is contained in:
Admiral H. Curtiss 2023-06-16 16:08:44 +02:00 committed by GitHub
commit afa8a47be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

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