diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d504ab..d461d06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,14 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# Statically link the VC runtime everywhere (/MT, /MTd in Debug). The injected coop_hook.dll must load +# into games on machines without the matching VC++ redist; SafetyHook + Zydis are linked into it, so a +# per-target /MT would clash with their default /MD. Setting it project-wide keeps every target -- the +# DLL, the host, dev tools, tests, and the vendored deps -- on one static CRT (and ships the whole tool +# redist-free). CMP0091 (NEW since our 3.21 minimum) makes this abstraction select the actual flag. +cmake_policy(SET CMP0091 NEW) +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + # Emit compile_commands.json so clangd resolves includes/flags. Ignored by the # Visual Studio generator, so configure the Ninja build (build-clangd/) for this; # .clangd points clangd at that compilation database. diff --git a/README.md b/README.md index 43db7d2..0277326 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,6 @@ From an in-depth review pass. Each item is fixed test-first (a failing test, the as its own commit; "verify" items are confirmed real before any change, and dropped if not. Features: -- **Static CRT (`/MT`) for `coop_hook.dll`** (x64 + x86) so it loads in games without the VC++ redist. - **Stale Vulkan-layer registration cleanup** — remove a leftover `HKCU` implicit-layer entry from a crashed prior run on host startup. diff --git a/hook/CMakeLists.txt b/hook/CMakeLists.txt index 051f110..199e4a6 100644 --- a/hook/CMakeLists.txt +++ b/hook/CMakeLists.txt @@ -43,6 +43,6 @@ else() set_target_properties(coop_hook PROPERTIES OUTPUT_NAME "coop_hook") endif() -# TODO(dist): statically link the VC runtime (/MT) so the DLL loads in games on -# machines without the matching VC redist. Deferred until SafetyHook + Zydis are -# also forced to a static CRT to avoid a /MT-vs-/MD mismatch. +# The VC runtime is statically linked (/MT) project-wide (see CMAKE_MSVC_RUNTIME_LIBRARY in the top +# CMakeLists), so this DLL -- and the SafetyHook/Zydis it links -- carry no VC++ redist dependency and +# load into games on any machine.