build(cmake): Force include CppMacros.h globally for VC6#2252
build(cmake): Force include CppMacros.h globally for VC6#2252xezon merged 1 commit intoTheSuperHackers:mainfrom
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| CMakeLists.txt | Added forced include of CppMacros.h for VC6 builds to provide C++11 polyfills like nullptr |
Sequence Diagram
sequenceDiagram
participant CMake
participant Compiler as MSVC VC6
participant Sources as Source Files
participant CppMacros as CppMacros.h
CMake->>CMake: Check IS_VS6_BUILD
alt IS_VS6_BUILD is TRUE
CMake->>CMake: Add Dependencies/Utility to include paths
CMake->>Compiler: Set /FIUtility/CppMacros.h flag
loop For each source file
Compiler->>CppMacros: Force include at start of compilation
CppMacros->>Compiler: Define nullptr as 0
CppMacros->>Compiler: Define other C++11 polyfills
Compiler->>Sources: Compile with polyfills available
end
else IS_VS6_BUILD is FALSE
Compiler->>Sources: Compile normally (C++11 support)
end
CMakeLists.txt
Outdated
|
|
||
| # To be removed when abandoning VC6 | ||
| if (IS_VS6_BUILD) | ||
| include_directories(${CMAKE_SOURCE_DIR}/Dependencies/Utility) |
There was a problem hiding this comment.
Can we omit ${CMAKE_SOURCE_DIR} or is that strictly required?
There was a problem hiding this comment.
true, it's not needed, it's a remnant from when I was experimenting 😅
Also after giving it a second look today, I didn't like the generator expression I had: it had a check for if it's a MSVC compiler ($<CXX_COMPILER_ID:MSVC>:) while it's enclosed in a if (IS_VS6_BUILD) and cmake generators are ugly imo. I rewrote it to a more readable line now.
Many source files in Generals and GeneralsMD use modern C++ features like 'nullptr' (polyfilled in CppMacros.h) without explicitly including the header. This caused build failures on VC6 (Fixes TheSuperHackers#2165). This change: 1. Adds 'Dependencies/Utility' to the global include path (guarded by IS_VS6_BUILD). 2. Uses the MSVC '/FI' flag to force include 'Utility/CppMacros.h' when compiling with VC6. This ensures compatibility macros like 'nullptr' (defined as 0) are always available.
xezon
left a comment
There was a problem hiding this comment.
Looks ok to me. Curious why the compiled header does not work with Docker VC6. It works on native Windows.
Many source files in Generals and GeneralsMD use modern C++ features like 'nullptr' (polyfilled in CppMacros.h) without explicitly including the header. This caused build failures on VC6 (Fixes #2165).
This change: