Skip to content

Commit 88ace5b

Browse files
committed
fix: use static runtime library (/MT) for MSVC to avoid CRT mismatch
Switch to static runtime library for all targets including dependencies. This avoids the complex issue of mixing /MT and /MD between different libraries.
1 parent 973cac9 commit 88ace5b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ set(CMAKE_CXX_STANDARD 17)
99
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1010
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1111

12-
# Windows: Use dynamic runtime library (/MD) for all targets
12+
# Windows: Use STATIC runtime library (/MT) for all targets to avoid CRT mismatch
13+
# This ensures all code links against the same static CRT
1314
if(MSVC)
14-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
15-
# Force Google Test to use shared CRT (must be before FetchContent)
16-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
15+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
16+
# Google Test should also use static CRT
17+
set(gtest_force_shared_crt OFF CACHE BOOL "" FORCE)
1718
endif()
1819

1920
# Find OpenSSL for HTTPS support

0 commit comments

Comments
 (0)