Skip to content

Revise config.cmake generation #135

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

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

Conversation

LecrisUT
Copy link

CMake already provides built-in support for making sure the package is relocatable. This PR contains:

  • Use CMakePackageConfigHelpers helpers
  • Changed INSTALL_CMAKE_DIR from share to CMAKE_INSTALL_LIBDIR. share is only supposed to be used for architecture independent packages. Changed it for Windows as well because it is generally a common practice to use GNUInstallDirs compatible paths for Windows as well (see vcpkg), but feel free to alter it if you have different needs there.
  • Made the @PROJECT_NAME@_*_DIRS calculated from PATH_VARS.
    • Note it might break if CMAKE_INSTALL_* vars is not relative to CMAKE_INSTALL_PREFIX, but the previous approach is also prone to breaking
    • PS: please find a way to deprecate these, e.g. move them to a DEPRECATED component and emit a warning if these are used
  • Changed INSTALL_NAME_DIR to use genex to be more relocatable
  • Changed the standard to more modern naming conventions -config.cmake -> Config.cmake, -depends.cmake -> Targets.cmake. Please see about changing EXPORT depends as well

- install(TARGETS) does not need explicitly setting variables
- Genex $<INSTALL_PREFIX> is more reliable than hard-coded CMAKE_INSTALL_PREFIX

Signed-off-by: Cristian Le <git@lecris.dev>
@hobu
Copy link
Contributor

hobu commented Mar 13, 2025

libgeotiff's CMake configuration is very old. I think this activity is good alignment with modern CMake, but we need to be careful to let the packagers who might have been scaffolding around our crufty configuration catch up on the next release.

@LecrisUT
Copy link
Author

I come from Fedora packaging 1 and this is part of the removal of questionable default options in cmake macro. But for sure try to contact the other distro packagers. Generally it should be valid out-of-the-box because GNUInstallDirs accounts for each distribution standards.

Footnotes

  1. https://src.fedoraproject.org/rpms/libgeotiff/pull-request/2

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.

2 participants