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

Feature request: ability to disable CMake install targets #266

Open
jchv opened this issue Mar 4, 2024 · 0 comments · May be fixed by #267
Open

Feature request: ability to disable CMake install targets #266

jchv opened this issue Mar 4, 2024 · 0 comments · May be fixed by #267

Comments

@jchv
Copy link

jchv commented Mar 4, 2024

When vendoring libspng, it would be very useful to be able to disable the CMake install targets. There are some situations that can't really be worked around otherwise; an example is if you vendor zlib and make libspng link to that. If you do this, then the install target will cause CMake to fail with an error:

 CMake Error: install(EXPORT "SPNGTargets" ...) includes target "spng_static" which requires target "zlib" that is not in any export set.

I've tried quite a few workarounds, but so far no dice. It really seems like you just need a way to disable install targets. The convention that I've seen the most is honoring SKIP_INSTALL_* options, for example, this commit in Freetype.

(P.S.: I am happy to contribute this myself, too, if it is something that would be accepted. Seems trivial enough.)

jchv added a commit to jchw-forks/libspng that referenced this issue Mar 9, 2024
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`, and
  `SKIP_INSTALL_LIBRARIES` variables when setting up `install` 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 randy408#266.
@jchv jchv linked a pull request Mar 9, 2024 that will close this issue
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 a pull request may close this issue.

1 participant