-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Installing Catch2 when using FetchContent #2164
Comments
Another solution might be for Catch to always install its targets, even when used as a sub-project, and leave it up to dependents to opt out of Catch's install targets using |
What you need to do is to not consume Catch2 via |
I agree that using There are some useful benefits to using the |
In theory I agree with you, but that would be a breaking change, while adding an option will give you the possibility without breaking existing builds |
@saxbophone already gave you a more than valid answer. I would also add that FetchContent is not an hack but a very valid solution to a big problem. Even without using that, though, there are many situations where the usage of the add_subdirectory can be useful. For example I load Catch in my core project as a git subtree and I want the plugin projects depending from that Core to be able to use Catch without having to rely on an external installation but using the one I ship with the core package |
FetchContent + I too use Catch2 via If any of your dependencies becomes public then you should strictly consume it via |
I understand your point @dimztimz but I'd rather have the choice of bundling my dependency if, in my use case, the advantages are greater than the disadvantages. This may be particularly useful for header only libraries like Catch. |
Yeah, I think allowing for flexibility is really useful for end-users. @dimztimz is not wrong that bundling or "vendoring" dependencies is not ideal, but it would be unfortunate to not allow dependents to use the various different methods that CMake provides for retrieving dependencies —these are after all, documented methods that CMake provides for dependency resolution. For my example use-case, it makes it easier for doing cross-platform builds on continuous integration, as I don't need to add separate code for installing third party dependencies on macOS, Windows and Linux. |
I've been using the following. What you actually need are the cmake modules, so you can do
Then use
as you would normally. |
In my case, it does not work with catch v3.6.0 and this msgpack implementation in C++17, which is also included via
Also, I do not need to There is an example how to integrate
I get
And CMake says
|
Due to the behaviors documented in #1373 Catch doesn't install anything when used as a subproject but this doesn't allow it to be installed when used through the FetchContent macro, that requires the package to be added with the add_subdirectory.
Could be useful to add an option, maybe even mark as advanced if necessary, to force the installation if the user wants to, even when used as subproject
The text was updated successfully, but these errors were encountered: