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:

https://github.com/google/googletest/blob/23ef29555ef4789f555f1ba8c51b4c52975f0907/googletest/README.md#visual-studio-dynamic-vs-static-runtimes
This commit is contained in:
Léo Lam
2021-04-27 12:54:18 +02:00
parent 51bf2dca21
commit dcf3ca0f89
+2
View File
@@ -844,6 +844,8 @@ include_directories("${PROJECT_BINARY_DIR}/Source/Core")
#
if(ENABLE_TESTS)
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)
else()
message(STATUS "Unit tests are disabled")