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

build: various install improvements #1117

Closed
wants to merge 2 commits into from

Conversation

Tachi107
Copy link

@Tachi107 Tachi107 commented Sep 2, 2022

With this PR I've made two main improvements:

  • Moved install location of the .cmake files from lib/ to share/
  • (re)added a pkg-config file

Also, please don't squash this PR on merge, otherwise all the information in the commits will be lost. Thanks :)

Here are the commit messages:

  1. As GLM is a header-only library, its cmake config files should be installed to share/ (GNUInstallDirs' DATADIR), as share/ is the canonical directory where architecture-independent files should be stored, while lib/ is for architecture-dependent stuff (see the FHS).

    Apart from being technically correct, installing to share/ can help with cross-compiling, for example in Debian-based environments. If you're interested, I'd suggest reading this thread.

    I've also made a few minor fixes, like moving GNUInstallDirs in the main CMakeLists.txt so that it is accessible project-wide and removed the unneeded include(CPack) directive.

  2. GLM used to ship a pkg-config file since version 0.9.8.0, added in commit Tachi107@0e018a5, but it was removed together with the install target in commit Tachi107@5f352ec. While the install target was re-added in commit Tachi107@631faff, the .pc file has been left behind.

    This patch re-adds it, and, compared to the old one, this pkg-config file also accounts for the cases where GLM is installed in an include directory that is not a subdirectory of the install prefix (i.e. it does the right thing™ when CMAKE_INSTALL_INCLUDEDIR is an absolute path).

    To read why the JoinPaths module is needed, take a look at https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files

As GLM is a header-only library, its cmake config files should be
installed to `share/` (GNUInstallDirs' DATADIR), as `share/` is the
canonical directory where architecture-independent files should be
stored, while `lib/` is for architecture-dependent stuff (see the [FHS]).

Apart from being technically correct, installing to `share/` can help
with cross-compiling, for example in Debian-based environments. If
you're interested, I'd suggest reading this [thread].

I've also made a few minor fixes, like moving GNUInstallDirs in the
main CMakeLists.txt so that it is accessible project-wide and removed
the unneeded include(CPack) directive.

[FHS]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrshareArchitectureindependentData
[thread]: marzer/tomlplusplus#165 (comment)
@Tachi107 Tachi107 force-pushed the cmake-install-improvements branch 6 times, most recently from 74c4c88 to beedffb Compare September 3, 2022 10:57
GLM used to ship a pkg-config file since version 0.9.8.0, added in
commit 0e018a5, but it was removed
together with the install target in commit
5f352ec. While the install target was
re-added in commit 631faff, the .pc
file has been left behind.

This patch re-adds it, and, compared to the old one, this pkg-config
file also accounts for the cases where GLM is installed in an include
directory that is not a subdirectory of the install prefix (i.e. it does
the right thing™ when CMAKE_INSTALL_INCLUDEDIR is an absolute path).

To read why the JoinPaths module is needed, take a look at
<https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files>
@Tachi107 Tachi107 force-pushed the cmake-install-improvements branch from beedffb to 775a8e2 Compare September 3, 2022 23:02
@xiaozhuai
Copy link

Dup of #1186

@Tachi107
Copy link
Author

Hi @xiaozhuai, sorry for my late reply, and thanks for your patch! This is not a duplicate of #1186, since this also re-adds the pkg-config file which many people rely on. This also introduced some improvements related to cross-compilation, which does not seem to be addressed in your patch.

@christophe-lunarg, could you please re-open this pull request, so that I can rebase and update my patch? Thanks :)

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.

3 participants