Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

build(cmake): link the CRT statically so the zip runs without a redistributable

Olcay Seygan2ea988413cd5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 368b8ff17..1f546e14d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -890,6 +890,11 @@ found and fixed — EA's own, not port damage.**
with it, since it looks those up in a folder while it is running rather than at load, and an
install short of them starts and then plays nothing at all. All of it is the retail files, and the
old copies are backed up like everything else the installer writes over.
+- The game no longer needs a Visual C++ redistributable installed. The exe asked Windows for two
+ support libraries by name at load, so a machine that had never installed one failed exactly the
+ way a missing `mss32.dll` did: a dialog naming a file, nothing written to any log, nothing to send
+ back to anyone. Both libraries are compiled into the exe and into the graphics translator now. The
+ download is half a megabyte larger and there is nothing left to install alongside it.
- Over a build that is already there it updates rather than installs, and says which number it is
moving you from and to. Running an older package over a newer install stops instead, since the
usual reason for doing that by accident is having two zips in the downloads folder; the word
diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt
index 6d12dde4d..173fa0d2c 100644
--- a/GeneralsMD/Code/CMakeLists.txt
+++ b/GeneralsMD/Code/CMakeLists.txt
@@ -1,4 +1,16 @@
cmake_minimum_required(VERSION 3.20)
+
+# The zip goes to machines that have never installed a Visual Studio redistributable, and
+# generals.exe imported MSVCP140.dll and VCRUNTIME140.dll by name. That fails in the Windows
+# loader before a line of our code runs, so there is no DebugLogFile.txt and no crash file to
+# send back - the same undiagnosable failure the retail Miles and Bink DLLs are packaged to
+# avoid. Link the CRT into the exe and into d3d8.dll instead of depending on a machine having
+# it. CMAKE_POLICY_DEFAULT is what reaches the vendored subdirectories: d3d8to9 declares
+# cmake_minimum_required(3.12), which predates CMP0091, and would otherwise ignore the setting
+# below and keep importing the DLL.
+set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
project(GeneralsMD CXX C)
# Win32 only: the code is full of 32-bit inline __asm, which MSVC x64 rejects outright.