aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

Make generated CMake files valid when install paths are absolute

Open thequux opened this issue 5 years ago • 1 comments

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:

  • [x] Did a review by yourself.
  • [ ] Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • [x] Checked if this PR is a breaking (APIs have been changed) change.
  • [ ] Checked if this PR will not introduce cross-platform inconsistent behavior.
  • [x] 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.

  • [x] 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.

thequux avatar Apr 15 '20 08:04 thequux

https://github.com/aws/aws-sdk-cpp/issues/1888

jmklix avatar Apr 22 '22 18:04 jmklix

Closing in favor of updated PR

jmklix avatar Aug 17 '23 16:08 jmklix