Fix issue 5042: Don't override VC++ project C runtime library settings when googletest is used through cmake FetchContent or add_subdirectory

This commit is contained in:
zmajeed
2026-08-06 09:52:33 -05:00
parent 4f472747b1
commit c0afb7f69d
+2 -1
View File
@@ -71,7 +71,8 @@ macro(config_compiler_and_linker)
# as static libraries, as we don't have to rely on CRT DLLs being available.
# CMake always defaults to using shared CRT libraries, so we override that
# default here.
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY
AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()