CMake improvements when vendoring with FetchContent #267
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 patch makes the following improvements to the CMake configuration:
If the target ZLIB::ZLIB already exists, find_package for zlib is not called: this is advantageous if the project that is vendoring libspng is also vendoring zlib, or has an alternate zlib implementation (like zlib-ng.) Otherwise, ugly hacks are needed to make the find_package a no-op (e.g.: introducing a FindZLIB.cmake module somewhere earlier in the search path that does this check and then calls the root module.)
It will now honor the
SKIP_INSTALL_ALL
,SKIP_INSTALL_HEADERS
, andSKIP_INSTALL_LIBRARIES
variables when setting upinstall
targets. This is useful because zlib also honors this setting, and there's not much sense in installing libspng if it depends on vendored zlib which is not going to have install targets. (It causes an error, too.)This should be fairly safe: when configuring standalone, this shouldn't change any of the existing behavior. For vendoring with
FetchContent
, I reckon this still shouldn't break any of the existing cases. This can help on Windows for a project that aims to compile out-of-the-box using Visual Studio without needing tooling like vcpkg, as zlib isn't present by default in this environment.Fixes #266.
P.S.: Thanks for your work, by the way! libspng is a breath of fresh air.