Skip to content

[CMAKE] Make vc6 debug compatible with retail #1217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"generator": "NMake Makefiles",
"hidden": false,
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/cmake/vc6toolchain.cmake",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
Expand Down
6 changes: 5 additions & 1 deletion cmake/config-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ if(UNIX)
endif()

if(RTS_BUILD_OPTION_DEBUG)
target_compile_definitions(core_config INTERFACE RTS_DEBUG WWDEBUG DEBUG)
if(NOT IS_VS6_BUILD)
target_compile_definitions(core_config INTERFACE RTS_DEBUG WWDEBUG DEBUG)
else()
target_compile_definitions(core_config INTERFACE RTS_DEBUG WWDEBUG)
endif()
else()
target_compile_definitions(core_config INTERFACE RTS_RELEASE)

Expand Down
63 changes: 63 additions & 0 deletions cmake/vc6toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Setting C++ default compiler flags for VC6

string(JOIN " " VC6_CXX_FLAGS
"/DWIN32" # Define WIN32 macro
"/D_WINDOWS" # Define _WINDOWS macro
"/Zm800" # Cap precompiled header memory allocation to prevent running out of heap space
"/Gd" # __cdecl calling convention for all functions (C/C++ standard behaviour)
"/GR" # Enable RTTI (Run-Time Type Information, needed for things like dynamic_cast)
"/EHs" # Synchronous C++ exception handling (ISO-standard C++ exception handling)
"/EHc" # Assume extern "C" functions never throw (safe for release)
)
string(JOIN " " VC6_CXX_FLAGS_RELEASE
"/O2" # Optimize for speed
"/Ob2" # Inline any suitable function
"/Oy" # Omit frame pointer (smaller/faster code)
"/DNDEBUG"
"/O2" # Optimize for speed
"/nologo" # Suppress copyright message
)
string(JOIN " " VC6_CXX_FLAGS_DEBUG
"/Og /Oi /Gs" # Optimize for speed (for compatibility)
"/Ob2" # Inline any suitable function (for compatibility)
"/Oy-" # Don't omit frame pointer
"/DNDEBUG" # (for compatibility)
)
string(JOIN " " VC6_EXE_LINKER_FLAGS
"/machine:IX86" # Target x86 architecture
"/LARGEADDRESSAWARE"# Allow addresses larger than 2 gigabytes"
)
string(JOIN " " VC6_EXE_LINKER_FLAGS_RELEASE
"/RELEASE" # Set the checksum in the header and mark as release
"/OPT:REF,ICF" # Remove unreferenced code/data, COMDAT folding
"/NOLOGO" # Suppress linker startup banner
)
string(JOIN " " VC6_EXE_LINKER_FLAGS_DEBUG
"/DEBUG" # Generate debug info
"/OPT:NOREF,ICF" # Don't remove unreferenced code/data, COMDAT folding
)
set(CMAKE_CXX_FLAGS "${VC6_CXX_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${VC6_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${VC6_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "${VC6_CXX_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "${VC6_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "${VC6_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE)


set(CMAKE_EXE_LINKER_FLAGS "${VC6_EXE_LINKER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${VC6_EXE_LINKER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${VC6_EXE_LINKER_FLAGS}" CACHE STRING "" FORCE)

set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${VC6_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${VC6_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${VC6_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "" FORCE)

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${VC6_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${VC6_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_MODULE_FLAGS_RELEASE "${VC6_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "" FORCE)

set(CMAKE_STATIC_LINKER_FLAGS "/machine:IX86" CACHE STRING "" FORCE)
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "" CACHE STRING "" FORCE)
set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "" CACHE STRING "" FORCE)


Loading