Make generated CMake files valid when install paths are absolute #1365
+14
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.