Modernize the CMake build files #102
Merged
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.
What does this change do?
FetchContentreadyThis is achieved by conditionally executing code that is only useful
for a consumer of the project, such as examples.
Because this is a header-only library, its install rules should be
categorized in a dev component (think foo-dev packages in apt). By
assigning all install rules to a component, the project no longer
clobbers the global component when vendored (see the previous point).
This is achieved by adding SYSTEM to the include directories
conditionally and only providing targets that are actually needed.
This is achieved by setting the ARCH_INDEPENDENT argument when
generating the version config file, which is available since CMake
3.14. This feature is intended to be used for header-only libraries.
The install rules are written in a way that allows package maintainers
to trivially package the project.
Additionally, if you ever wish to completely move the build tooling of this library to CMake, only minimal changes are necessary from this point on:
With a developer mode you may add testing, docs, benchmarks, whatever else your heart desires, without disturbing regular consumers who couldn't care less about those things.
With presets you can add warning flags, extra configurations for coverage, sanitizers, etc without hardcoding things into the CML files. Generally, you want to avoid putting anything in the CML files that aren't build or usage requirements. Warning flags are neither of those :)
A helpful template in the contributing guidelines with a developer mode preset can be helpful for those not yet familiar with this type of workflow and its benefits.
All of the above can be seen in action in the example repositories listed in cmake-init's readme. There is also an example for vcpkg integration that can help you to get rid of git submodules.
I have read on Reddit that you are putting off learning CMake, I hope the above link can help you to kick-start that endeavour. If you have questions, feel free to open a discussion in that repository or shoot me an email at [email protected]
Is it related to an exisiting bug report or feature request?
No.
Pre-merge checklist
origin/master(if necessary)