CMake: Force gtest to link CRT dynamically to avoid runtime mismatches

Required to fix unit test builds for Windows+MSVC+CMake.

For more information, see:

23ef29555e/googletest/README.md (visual-studio-dynamic-vs-static-runtimes)
This commit is contained in:
Léo Lam 2021-04-24 23:12:30 +02:00
parent 51bf2dca21
commit dcf3ca0f89
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
1 changed files with 2 additions and 0 deletions

View File

@ -844,6 +844,8 @@ include_directories("${PROJECT_BINARY_DIR}/Source/Core")
# #
if(ENABLE_TESTS) if(ENABLE_TESTS)
message(STATUS "Using static gtest from Externals") message(STATUS "Using static gtest from Externals")
# 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) add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
else() else()
message(STATUS "Unit tests are disabled") message(STATUS "Unit tests are disabled")