Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give parent projects better control over cmake install #334

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

david-pikas
Copy link

@david-pikas david-pikas commented Oct 11, 2024

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 the EXCLUDE_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:

  • Adds an option, 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).
  • Adds an installation component which is equal to ${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:
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(FILTER CPACK_COMPONENTS_ALL EXCLUDE REGEX "^rapidcheck")

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.

David Pikas added 2 commits October 11, 2024 10:59
Installation may be unwanted if a project that includes rapidcheck uses
cpack to create packages, for instance
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.

1 participant