Skip to content

Conversation

@double-fault
Copy link
Contributor

CMAKE_BUILD_TYPE should only be set when the project being compiled is top-level. The PROJECT_IS_TOP_LEVEL variable was added in cmake 3.21, hence a more hacky solution for older versions.

Another option would be to simply display a message if CMAKE_BUILD_TYPE is unspecified instead of defaulting it to Release.

The issue with the current behavior is that setting the build type flag propagates to the parent project. In some code of mine I'm using spdlog as a git submodule (add_subdirectory), and I have not specified build type - however spdlog sets it to Release which was causing some asserts in my code being compiled-out silently.

As such I think it makes sense to not set any property which propagates to the parent project, since this is a library after all.

@gabime gabime merged commit dd3ca04 into gabime:v1.x Nov 1, 2025
13 of 14 checks passed
@gabime
Copy link
Owner

gabime commented Nov 1, 2025

Thanks @double-fault

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