Give parent projects better control over cmake install #334
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.
Rationale
Right now rapidcheck uses cmake install functionality to install some files. This isn't always desirable, for example if someone includes rapidcheck in their project with cmakes
add_subdirectory
, this will cause rapidcheck to be installed alongside their files. Projects including rapidcheck might not want to install rapidcheck since testing is often only relevant for people working on that project, and not their consumers. Additionally, this also includes rapidcheck in packages generated with cpack.Currently this can be worked around by re-defining
install
before including rapidcheck to a no-op and then setting it to the default value, however this is rather hacky and will break if the parent project doesn't use the standard install.One can also use theEXCLUDE_FROM_ALL
keyword argument when including rapidcheck, but this will also change when rapidcheck is built and not just installed. Furthermore, this fix doesn't adress the cpack case.Edit: Actually I was wrong about EXCLUDE_FROM_ALL, it does seem to prevent it from being included in cpack case. This means that this change isn't as valuable as I first thought but I'll still leave this pull request up.
Solution
This pull request does two things, broken up in separate commits:
RC_ENABLE_INSTALL
. If set to on (default value), everything will be installed just as before. Setting this to off will disable all install commands (including in extras).${PROJECT_NAME}
to all install commands (so extras will have components like e.g. rapidcheck_gtest while the main gtest module will have rapidcheck). This allows users to leave install on for rapidcheck for local development but filter it from cpack with the following cmake code:The changes are inspired by google test: it has the
INSTALL_GTEST
cache variable which works in the same way and also sets COMPONENT to${PROJECT_NAME}
on its installs.