-
Notifications
You must be signed in to change notification settings - Fork 89
build(presets): Major CMakePresets overhaul, unify vcpkg, modernize VC6 support #1373
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
base: main
Are you sure you want to change the base?
Conversation
776e30f
to
4972671
Compare
I wish you had waited with this until #1366 is merged. This is gonna cause endless merge conflicts... How will you be able to control debuginfo generation with this change? Regarding the CI: It's outputting this error:
|
you control debug info by setting the generator config directly or using the build preset. |
CMakePresets.json
Outdated
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>", | ||
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't really care too much about this, but Embeded is allegedly slightly faster to build even on modern MSVC, which is why I set it to that initially. I doubt it makes a massive difference though and only affects object generation, not the final link pdb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't say anything about which format is most efficient for a multithreaded build and I was already aware of the other differences in the format. As I said it doesn't make much difference for the pdb that is generated, its always a separate pdb (if one is generated) for binaries and shared libraries. It only affects how its stored for objects (and static libraries which are just collections of objects). Also, it should be set for all builds, there is no reason to not be generating debug information for all builds except for VC6 so it can multithread build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, somehow had misread it. but i think program database should be better for pdb size. It definitely is for vc6 but i'm not sure for modern visual studio.
CMakePresets.json
Outdated
"cacheVariables": { | ||
"RTS_BUILD_OPTION_PROFILE": "ON" | ||
"CMAKE_CXX_FLAGS" : "/DWIN32 /D_WINDOWS /EHac /Zm800", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it perhaps worth investigating moving all the special VC6 handling to a toolchain file rather than dealing with it all in presets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only special vc6 stuff is replacing /Zm1000 with /Zm800 and setting jobs to 1 for some build presets. The latter can't be done in a toolchain file for only select build presets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be done in compilers.cmake if we are going to say this stuff is required then so it doesn't matter how it was configured, its always set for VC6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have most stuff set through cmakelists. I assumed others preffered it in presets based on other stuff being set in presets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my take is that "its complicated", flags that are needed for a correct build like these I'd say belong in the CMake so any build gets them. Things like warning overrides and especially converting warnings to errors which I think we should work towards using on the CI need to be passed in from the environment in some way so an end users build doesn't error out because we hard coded it and they tried to build for freebsd or their distro upgraded their compilers.
95af92a
to
75f053e
Compare
3dc74e9
to
737bb31
Compare
# and all link steps go into 'link' (so only one link ever runs since vc6 can't handle multithreaded linking) | ||
set(CMAKE_JOB_POOL_LINK link) | ||
if(NOT IS_VS6_BUILD) | ||
set(CMAKE_CXX_STANDARD 20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being moved here and set globally rather than on just out targets? Does it not work as advertised when done on targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't work correctly for visual studio generators if done by target and eitherway I think this way is safer because you would want all code to use the same standard for api/abi compatibility. Not much of a benefit to setting it per target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why it wouldn't work for the VS generators given they probably recieve some of the heaviest testing for CMake.
I'm thinking more along the lines of if we FetchContent a library that doesn't set this for itself and doesn't build correctly. Granted we will be using vcpkg for most dependencies but its possible we would want to use something not packaged there.
Guess it doesn't matter for now, we can reevaluate that when it comes to it. Setting things per target rather than globally is just generally considered better CMake practice.
ba32576
to
ca87492
Compare
f187400
to
45b7d9b
Compare
ffe436c
to
2a92237
Compare
…C6 support - Deduplicate configure presets for easier maintenance - Make vcpkg the default and speed up dependency installation for all builds - Enable vcpkg integration for VC6 builds - Switch VC6 builds to Ninja Multi-Config: optimization level can now be switched without reconfiguring - Enable ful debug info for VC6 configurations - VC6 environment now requires only the VS6_DIR environment variable to be set - Decouple dev builds from optimization config for more flexible development
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty happy with this now, just a couple remaining points for attention/clarification on.
# Generate debug information for all builds | ||
add_link_options("/debug") | ||
|
||
set(CMAKE_CONFIGURATION_TYPES "Release;Debug") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we are limiting this to just Release/Debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit creation of build subdirectories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really care if it creates RelWithDebInfo folders, especially as it is a different optimisation level to Release? Limiting for the CI is fine if we don't build that type, but this limits all end users of this repo unless I'm misunderstanding it.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") | ||
|
||
set(CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /EHac") | ||
set(CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just reiterating the defaults for C_Flags and can probably be ommitted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things I noticed.
tools: ${{ matrix.tools }} | ||
extras: ${{ matrix.extras }} | ||
secrets: inherit | ||
|
||
# Note build-generalsmd is split into two jobs for vc6 and win32 because replaycheck-generalsmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete this comment?
matrix: | ||
include: | ||
- preset: "vc6+t+e" | ||
- preset: "vc6-releaselog+t+e" # optimized build with logging and crashing enabled should be compatible, so we test that here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not check replays for release and releaselog?
The Release version is the one we'll ship, so I think it doesn't hurt to test it as well.
It might also help track down issues when we know that only one version mismatches or doesn't run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not that good at ci stuff atm. I just fixed stuff on the cmake side and tried my best to adjust the ci accordingly. Perhaps someone else can do the ci update/fix.
buildPreset: | ||
required: true | ||
type: string | ||
tools: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is tools and extras added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug builds are excluded from ci because they are not redistributable
Do I understand correctly that each Job compiles Debug and Release, but only uploads Release binaries? Why don't we upload the debug builds? We don't need to upload the debug c++ runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the resulting vc6 binary depends on zlib.dll. Before it didn't require any additional dependencies. Is there a way to keep it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will developers now be required to install vcpkg to compile with VC6? If so, please put a instructions in the first post of the PR. (Ideally in the build instructions, but they are sadly in another repo).
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase") | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") | ||
|
||
set(CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /EHac") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of #1424 this won't be needed for the games at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! /EHsc is better
If you are using the visual studio 2022 ide then I highly recommend you navigate to tool>options>cmake> and disable unified build and configuration preset menu. This way you won't have to re-configure when switching between build presets with a common configure preset.
For convenient vc6 builds, I recommend setting VS6_DIR to your vc6 directory in your system envvironment variable.
Since it is not a standard environment variable, it should have no affect on other visual studio installations or anything
other than building this project using the vc6 presets.
closes #1235