From dcf3ca0f8995324471fc3359ee17d7ea89afd8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 24 Apr 2021 23:12:30 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06137c57e0..727d32ccef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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")