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

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

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

jmklix
Copy link
Member

@jmklix jmklix commented Aug 17, 2023

Issue #, if available:
Original PR: #1365
updated to follow new folder structure updates. Original PR comments below

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.

@jmklix jmklix merged commit 6952c4f into main Aug 22, 2023
4 checks passed
@jmklix jmklix deleted the issue_1365 branch August 22, 2023 17:03
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