Skip to content

CMake warn when non-release build#742

Merged
TysonRayJones merged 4 commits intodevelfrom
warn-non-release-build
May 6, 2026
Merged

CMake warn when non-release build#742
TysonRayJones merged 4 commits intodevelfrom
warn-non-release-build

Conversation

@TysonRayJones
Copy link
Copy Markdown
Member

Warn users about potential performance loss when not explicitly specifying Release, and especially when using a multi-config generator which requires build-type specification (as per the doc) - since this just bit me pretty bad on Windows! 😠

@TysonRayJones TysonRayJones requested a review from otbrown May 5, 2026 01:49
@TysonRayJones
Copy link
Copy Markdown
Member Author

@otbrown Any objections to this idea? (I worry about adding warnings to the build process generally).

This will not affect single-config (i.e. MacOS / Linux) users who leave CMAKE_BUILD_TYPE unspecified, since it defaults to Release as per your 35de0e4. Single-config users will only see the warning when explicitly overriding CMAKE_BUILD_TYPE to a non-release mode (overriding to "" will default to Release).

In contrast, multi-config users (e.g. wretched Windows users) will always see a message at config time, reminding them to subsequently build with --config Release. They will also see the message when rebuilding after making a config change too, since CMake auto reconfigs.

It's my opinion this is all good/fine, but making sure as a CMake noobie!

@otbrown
Copy link
Copy Markdown
Collaborator

otbrown commented May 5, 2026

The spirit is fine! I'm just looking at config generators which should let us do it more neatly and capture both single and multiconfig users (although isn't actually working when tested currently...).

I'll push an alternative version using that if I can get it working, if not, squash and merge!

@otbrown
Copy link
Copy Markdown
Collaborator

otbrown commented May 5, 2026

Okay, after some footering around I have concluded that Generator expressions will not help here. I will update to include RelWithDebInfo, and possibly case insensitivity.

@otbrown
Copy link
Copy Markdown
Collaborator

otbrown commented May 5, 2026

@TysonRayJones ignoring my naive and failed attempt to suppress the stupid EOF diff, which I suspect is a LF/CRLF issue:

I have added something to deal with case insensitivity of CMAKE_BUILD_TYPE and included RelWithDebInfo in the "do not warn" category, as that should generally be equivalent to -O3 -g. Assuming I haven't somehow broken anything else, I'm happy for you to merge!

In theory we ought to do something similar where we check the build type before adding -Ofast, but seeing as that's all about to be removed anyway, I propose we leave it.

Edit: I had broken it 🤦‍♂️ should be fixed now

@TysonRayJones
Copy link
Copy Markdown
Member Author

Good catches! Confirmed everything looks good in manual testing on Windows and Mac 🎉

@TysonRayJones TysonRayJones merged commit 8031274 into devel May 6, 2026
130 checks passed
@TysonRayJones TysonRayJones deleted the warn-non-release-build branch May 6, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants