Skip to content

Make generated CMake files valid when install paths are absolute #1365

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

Closed
wants to merge 2 commits into from

Conversation

thequux
Copy link

@thequux thequux commented Apr 15, 2020

Issue #, if available:
NixOS/nixpkgs#70075, #1188

Similar alternative patch: #1315

The difference between this patch and #1315 is that the change to the logic in this patch is much simpler, and it also fixes the pkgconfig files.

Description of changes:

Problem

If the install directories are given as absolute paths, the generated
CMake files break completely; in particular, on NixOS, they will try
to read headers from

/nix/store/somelonghash-aws-version-dev//nix/store/somelonghash-aws-sdk-cpp-version-dev/include

and find the library binaries in

/nix/store/somelonghash-aws-version-dev//nix/store/somelonghash-aws-sdk-cpp-version/lib

The part before the // is what is discovered as AWSSDK_ROOT_DIR.

Fix

If CMAKE_INSTALL_LIBDIR and friends are absolute, then they should not
have AWSSDK_ROOT_DIR prepended to them.

Unfortunately, this is tricky to do in a small patch, but on the
assumption that if one of these variables is absolute, then so are the
rest, I have picked AWSSDK_INSTALL_LIBDIR as the representative sample.

If this variable is unset, then AWSSDK_ROOT_DIR is forced to be "" so
that in can still be prepended to the install paths and get a valid
path as a result.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Tests are not applicable because this is purely a change to the build system.

I strongly suspect that this will not introduce cross-platform inconsistent behaviour, as I don't know enough about cmake's path handling on Windows to be sure. However, I am completely sure that this will behave the same across all the various Unix-like platforms.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Problem
-------

If the install directories are given as absolute paths, the generated
CMake files break completely; in particular, on NixOS, they will try
to read headers from

/nix/store/somelonghash-aws-version-dev//nix/store/somelonghash-aws-sdk-cpp-version-dev/include

and find the library binaries in

/nix/store/somelonghash-aws-version-dev//nix/store/somelonghash-aws-sdk-cpp-version/lib

The part before the `//` is what is discovered as AWSSDK_ROOT_DIR.

Fix
---

If CMAKE_INSTALL_LIBDIR and friends are absolute, then they should not
have AWSSDK_ROOT_DIR prepended to them.

Unfortunately, this is tricky to do in a small patch, but on the
assumption that if one of these variables is absolute, then so are the
rest, I have picked AWSSDK_INSTALL_LIBDIR as the representative sample.

If this variable is unset, then AWSSDK_ROOT_DIR is forced to be "" so
that in can still be prepended to the install paths and get a valid
path as a result.
@KaibaLopez KaibaLopez added the pr/needs-review This PR needs a review from a Member. label Apr 16, 2020
@jmklix
Copy link
Member

jmklix commented Apr 22, 2022

#1888

@jmklix jmklix added needs-review This issue or pull request needs review from a core team member. and removed pr/needs-review This PR needs a review from a Member. labels Jan 27, 2023
@jmklix
Copy link
Member

jmklix commented Aug 17, 2023

Closing in favor of updated PR

@jmklix jmklix closed this Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review This issue or pull request needs review from a core team member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants