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

pkgconfig: Use better path concatenation #260

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

OPNA2608
Copy link
Contributor

A correction to #258, based on recommendations from jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files.

Unconditionally using CMAKE_INSTALL_FULL_*DIRs in a pkg-config file is slightly wrong, because it is expected that the variables are made up of other variables, all of which can be overridden by the user.

CMake added a cmake_path function which can do the required concatenation without the added function, but it's only available on version 3.20 while the current CMakeLists specifies a minimum version of 3.5.

I've checked that this gives regular ${prefix}/<dir> entries again when the CMAKE_INSTALL_*DIRs are relative, and the CMAKE_INSTALL_*DIRs verbatim when they are absolute.

Unconditionally using `CMAKE_INSTALL_FULL_*DIR`s in a pkg-config file is slightly wrong, because it is expected that the variables are made up of other variables, all of which can be overridden by the user.

CMake added a `cmake_path` function which can do the required concatenation without the added function, but it's only available on version 3.20 while the current CMakeLists specifies a minimum version of 3.5.
bors bot added a commit to canonical/mir that referenced this pull request Jan 20, 2023
2786: Better concatenation for pkg-config values, better use of GNUInstallDirs variables r=RAOF a=OPNA2608

Similar situation as canonical/wlcs#258, canonical/wlcs#260:

- CMake code assumes `CMAKE_INSTALL_<dir>` are relative to `CMAKE_INSTALL_PREFIX` when they may be absolute and completely outside of the `PREFIX`, blindly concatenating these two causes broken pkg-config files in such situations
  - `CMAKE_INSTALL_FULL_<dir>` should only be used in pkg-config files when the dir is not relative to the `${prefix}` so overriding the pkg-config variables has the intended effect
- In various places, suitable GNUInstallDirs variables for specifying header & data file locations are ignored
- As a minor point `FULL` & non-`FULL` variables are used inconsistently in `install` commands

I've
- fixed these concatenations in CMake & pkg-config files according to [jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files](https://github.com/jtojnar/cmake-snips/tree/a9d72829ab0cb42e541c9975e698d6b8282610ed#concatenating-paths-when-building-pkg-config-files)
- added more usage of `CMAKE_INSTALL_INCLUDEDIR` (defaults to `include`) & `CMAKE_INSTALL_DATADIR` (`share`) and
- replaced some `FULL` variables with non-`FULL` variants where the effect should be the same, for consistency

I've cherry-picked these commits onto 2.11.0 and checked the pkg-config files with relative & absolute install paths, resulting files looked okay to me. I've also tried building egmde against it and it builds & launches, where previously it would fail to find Mir's headers if `CMAKE_INSTALL_INCLUDEDIR` was an absolute path.

Co-authored-by: OPNA2608 <[email protected]>
bors bot added a commit to canonical/mir that referenced this pull request Jan 20, 2023
2786: Better concatenation for pkg-config values, better use of GNUInstallDirs variables r=RAOF a=OPNA2608

Similar situation as canonical/wlcs#258, canonical/wlcs#260:

- CMake code assumes `CMAKE_INSTALL_<dir>` are relative to `CMAKE_INSTALL_PREFIX` when they may be absolute and completely outside of the `PREFIX`, blindly concatenating these two causes broken pkg-config files in such situations
  - `CMAKE_INSTALL_FULL_<dir>` should only be used in pkg-config files when the dir is not relative to the `${prefix}` so overriding the pkg-config variables has the intended effect
- In various places, suitable GNUInstallDirs variables for specifying header & data file locations are ignored
- As a minor point `FULL` & non-`FULL` variables are used inconsistently in `install` commands

I've
- fixed these concatenations in CMake & pkg-config files according to [jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files](https://github.com/jtojnar/cmake-snips/tree/a9d72829ab0cb42e541c9975e698d6b8282610ed#concatenating-paths-when-building-pkg-config-files)
- added more usage of `CMAKE_INSTALL_INCLUDEDIR` (defaults to `include`) & `CMAKE_INSTALL_DATADIR` (`share`) and
- replaced some `FULL` variables with non-`FULL` variants where the effect should be the same, for consistency

I've cherry-picked these commits onto 2.11.0 and checked the pkg-config files with relative & absolute install paths, resulting files looked okay to me. I've also tried building egmde against it and it builds & launches, where previously it would fail to find Mir's headers if `CMAKE_INSTALL_INCLUDEDIR` was an absolute path.

Co-authored-by: OPNA2608 <[email protected]>
Copy link
Contributor

@RAOF RAOF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, ok.

bors r+

@bors bors bot merged commit 03237c9 into canonical:main Feb 7, 2023
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