Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ if(MINGW)
include(cmake/widl.cmake)
endif()

# Find/Add build dependencies and stubs shared by all projects
if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
# Find/Add build dependencies and stubs shared by all projects.
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
include(cmake/miles.cmake)
include(cmake/bink.cmake)
include(cmake/dx8.cmake)
Expand Down
11 changes: 11 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@
"cacheVariables": {
"RTS_BUILD_OPTION_PROFILE": "ON"
}
},
{
"name": "mingw-w64-x86_64",
"displayName": "MinGW-w64 64-bit (x86_64) Release",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/cmake/toolchains/mingw-w64-x86_64.cmake",
Comment on lines +196 to +200

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Build preset missing 🐞 Bug ≡ Correctness

The new mingw-w64-x86_64 configure preset has no matching build preset, so the repository's
standard cmake --build --preset mingw-w64-x86_64 invocation fails with an unknown preset error.
Every existing non-hidden configure preset has a corresponding build preset, and the generic build
workflow invokes presets this way.
Agent Prompt
## Issue description
The new `mingw-w64-x86_64` configure preset lacks a corresponding build preset, causing `cmake --build --preset mingw-w64-x86_64` to fail.

## Issue Context
Existing named configure presets have matching build presets, and the repository's generic build workflow builds using the same preset name.

## Fix Focus Areas
- CMakePresets.json[195-205]
- CMakePresets.json[287-305]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
Expand Down
45 changes: 44 additions & 1 deletion cmake/dx8.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,47 @@ FetchContent_Declare(
GIT_TAG 7bddff8c01f5fb931c3cb73d4aa8e66d303d97bc
)

FetchContent_MakeAvailable(dx8)
# Populate only: the fetched repo's CMakeLists.txt has no architecture condition,
# so d3d8lib is defined here, where it can diverge by CMAKE_SIZEOF_VOID_P.
FetchContent_GetProperties(dx8)
if(NOT dx8_POPULATED)
FetchContent_Populate(dx8)
endif()

add_library(d3d8lib INTERFACE)

# MinGW-w64 x86_64 ships no libd3d8.a and no libd3dx8, so on x64 this target
# carries headers and defines only and cannot link. See issue #473.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(d3d8lib INTERFACE d3d8 dinput8 dxguid)
Comment on lines +16 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. X64 games cannot link 📎 Requirement gap ≡ Correctness

The new x64 configuration deliberately omits the unavailable DX8 libraries, but both game
executables still link directly against d3d8 and d3dx8. Therefore, the Generals and Zero Hour
x64 targets cannot produce successfully linked executables as required.
Agent Prompt
## Issue description
The x64 game targets compile but cannot link because required DirectX 8 libraries are omitted while the executables retain direct references to them.

## Issue Context
PR Compliance ID 1 requires successful x64 upgrades for both games, not compile-only targets. Provide compatible x64 implementations or replace/remove the unsupported dependencies throughout the game link configuration.

## Fix Focus Areas
- cmake/dx8.cmake[14-22]
- cmake/mingw.cmake[57-68]
- Generals/Code/Main/CMakeLists.txt[10-16]
- GeneralsMD/Code/Main/CMakeLists.txt[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

else()
message(STATUS "DX8: x64 build — headers only, no D3D8 link libraries available")
endif()

# MSVC-specific configuration
if(MSVC)
# Use bundled MSVC-compiled .lib files
target_link_libraries(d3d8lib INTERFACE d3dx8)
target_link_directories(d3d8lib BEFORE INTERFACE ${dx8_SOURCE_DIR})
target_link_options(d3d8lib INTERFACE /NODEFAULTLIB:libci.lib)

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.0.8804")
# Modern MSVC (VS 2013+) has complete DirectX headers in Windows SDK
target_link_libraries(d3d8lib INTERFACE legacy_stdio_definitions)
target_link_options(d3d8lib INTERFACE /SAFESEH:NO)
else()
# VC6 and older MSVC need extra headers - their DirectX SDK is missing newer definitions
target_include_directories(d3d8lib INTERFACE ${dx8_SOURCE_DIR}/extra)
endif()
endif()

# MinGW-specific configuration
if(MINGW)
# i686 ships libd3d8.a and libd3dx8d.a; x86_64 ships neither.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(d3d8lib INTERFACE d3dx8d)
endif()
endif()

target_compile_definitions(d3d8lib INTERFACE -DBUILD_WITH_D3D8)
target_include_directories(d3d8lib INTERFACE ${dx8_SOURCE_DIR})
13 changes: 8 additions & 5 deletions cmake/mingw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ if(MINGW)
set(IS_MINGW32 TRUE)
message(STATUS "MinGW-w64 32-bit (i686) detected")
else()
message(FATAL_ERROR "MinGW-w64 64-bit (x86_64) detected, but this project only supports 32-bit builds. Use the i686-w64-mingw32 toolchain.")
set(IS_MINGW64 TRUE)
message(STATUS "MinGW-w64 64-bit (x86_64) detected — experimental, see issue #473")
endif()

# Windows subsystem
Expand Down Expand Up @@ -53,7 +54,8 @@ if(MINGW)
)
endif()

# Required Windows libraries for DX8 + COM
# Required Windows libraries for DX8 + COM. d3d8 is gated to 32-bit because
# link_libraries() is directory-scoped and would also hit the Miles/Bink stubs.
link_libraries(
uuid # COM GUIDs
ole32 # COM runtime
Expand All @@ -63,7 +65,7 @@ if(MINGW)
comctl32 # Common controls
winmm # Multimedia (timeGetTime, etc.)
vfw32 # Video for Windows (AVIFile functions)
d3d8 # Direct3D 8
$<$<EQUAL:${CMAKE_SIZEOF_VOID_P},4>:d3d8> # Direct3D 8 — 32-bit only
dinput8 # DirectInput 8
dsound # DirectSound
imm32 # Input Method Manager (IME)
Expand All @@ -78,8 +80,9 @@ if(MINGW)
# MinGW-w64 only provides libd3dx8d.a (debug library), not libd3dx8.a
# The min-dx8-sdk (dx8.cmake) handles this correctly via d3d8lib interface target,
# but for compatibility with direct library references in main executables,
# we create an alias so that linking to d3dx8 automatically uses d3dx8d
if(NOT TARGET d3dx8)
# we create an alias so that linking to d3dx8 automatically uses d3dx8d.
# 32-bit only: x86_64 MinGW-w64 ships neither libd3dx8.a nor libd3dx8d.a.
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT TARGET d3dx8)
add_library(d3dx8 INTERFACE IMPORTED GLOBAL)
set_target_properties(d3dx8 PROPERTIES
INTERFACE_LINK_LIBRARIES "d3dx8d"
Expand Down
32 changes: 32 additions & 0 deletions cmake/toolchains/mingw-w64-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# MinGW-w64 64-bit (x86_64) Toolchain File
# Use with: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64-x86_64.cmake

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# Specify the cross compiler
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_AR x86_64-w64-mingw32-ar)
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
set(CMAKE_DLLTOOL x86_64-w64-mingw32-dlltool)

# Target environment
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)

# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Force 64-bit pointer size
set(CMAKE_SIZEOF_VOID_P 8)

# Disable MFC-dependent tools (not compatible with MinGW-w64)
set(RTS_BUILD_CORE_TOOLS OFF CACHE BOOL "Disable MFC-dependent core tools for MinGW" FORCE)
set(RTS_BUILD_GENERALS_TOOLS OFF CACHE BOOL "Disable MFC-dependent Generals tools for MinGW" FORCE)
set(RTS_BUILD_ZEROHOUR_TOOLS OFF CACHE BOOL "Disable MFC-dependent Zero Hour tools for MinGW" FORCE)
Comment on lines +31 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. X64 tools are disabled 📎 Requirement gap ≡ Correctness

The x64 toolchain forcibly disables both RTS_BUILD_GENERALS_TOOLS and RTS_BUILD_ZEROHOUR_TOOLS.
Consequently, two of the four targets required by the compliance rule are not upgraded or built for
x64.
Agent Prompt
## Issue description
The x64 toolchain disables the required Generals Tools and Zero Hour Tools targets.

## Issue Context
PR Compliance ID 1 requires both tool suites to support successful x64 builds. Implement the necessary non-MFC or otherwise supported x64 build path instead of forcibly excluding these targets.

## Fix Focus Areas
- cmake/toolchains/mingw-w64-x86_64.cmake[29-32]
- Generals/Code/Tools/CMakeLists.txt[1-10]
- GeneralsMD/Code/Tools/CMakeLists.txt[1-11]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools