Introduce custom preprocessor flag for debugging #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces the
CELERITY_DETAIL_ENABLE_DEBUG
flag, which is set for debug builds of the Celerity runtime, regardless of a user target's build type. This is more reliable than usingNDEBUG
, as headers and implementation files are always guaranteed to receive the flag, both during library compilation and when linking to it. Also it means having less of those confusing double-negative!defined(NDEBUG)
checks.Unfortunately the implementation turned out to be quite annoying (of course...), as CMake doesn't really expose a mechanism for querying the build configuration of a library target that is being linked (which could then be used e.g. in generator expressions). The workaround for now is to inspect the
IMPORTED_CONFIGURATIONS
of theCelerity::celerity_runtime
library, and use that to conditionally set the flag. For this to work however we require that only a single build configuration is imported in the first place, as otherwise it becomes more difficult to tell which configuration ends up being linked (albeit not impossible).While thus far we effectively already only really supported one installed build configuration (as we'd otherwise have to set the
CMAKE_<CONFIG>_POSTFIX
variables), instead of adding support for multiple configurations, I've decided to enforce single config installs with an error for now. While I do see merit in having that feature, I can also see it causing a lot of unnecessary headaches during development, when rebuilding one configuration of the runtime, while some executable still links to the other one... So maybe we could look into e.g. only enabling this for versioned releases.This should fix #19.