[CMake] Remove assumptions about LIBDIR and INCLUDEDIR being co-located in AWSSDK
- Vorherrschende Sprache
- C++
- Sterne
- 2.2k
- Forks
- 1.2k
- Ø Merge
- 4 T. 11 Std.
- Gemergte PRs (30 T.)
- 13
Beschreibung
### Describe the bug
It's possible that the installation LIBDIR to be in a different directory from INCLUDEDIR.
Currently, the [AWSSDK logic](https://github.com/aws/aws-sdk-cpp/blob/6709bb6de9010b165b8bf44b708ba51e26fd5869/cmake/AWSSDKConfig.cmake#L103) assumes that it can traverse up then over to the lib directory.
### Expected Behavior
Since a package manager installed aws-sdk-cpp, aws-sdk-cpp should re-use the `install(TARGETS` information to conclude where to find a package (or at least prefer this method) with `find_package()`. This should also work with `export(TARGETS` as well.
### Current Behavior
At least for nix, the current behavior is that the `find_package(AWSSDK COMPONENTS [components]) ... AWSSDK_LINK_LIBRARIES` workflow is largely useless.
### Reproduction Steps
This would probably not be worthwhile.
### Possible Solution
- Use `find_package(aws-sdk-core)` + `get_target_property(AWS_CORE_HEADER_DIR aws-sdk-core INCLUDE_DIRECTORIES)`
- Takes into account different installation locations (e.g. /usr/local/ vs /usr/ vs build dir)
### Additional Information/Context
Nixpkgs for aws-sdk-cpp installs build dependencies separately from runtime
```
$ nix-build -A aws-sdk-cpp.all
/nix/store/8acky9zc3kldyz0m6728ff4vf24sg3rb-aws-sdk-cpp-1.9.238
/nix/store/34qdbh5bn2wdsm76m9gxqvyfxix65p0j-aws-sdk-cpp-1.9.238-dev
$ ls /nix/store/34qdbh5bn2wdsm76m9gxqvyfxix65p0j-aws-sdk-cpp-1.9.238-dev/include/aws/core/Aws.h
/nix/store/34qdbh5bn2wdsm76m9gxqvyfxix65p0j-aws-sdk-cpp-1.9.238-dev/include/aws/core/Aws.h
$ ls /nix/store/8acky9zc3kldyz0m6728ff4vf24sg3rb-aws-sdk-cpp-1.9.238/lib/libaws-cpp-sdk-core.so
/nix/store/8acky9zc3kldyz0m6728ff4vf24sg3rb-aws-sdk-cpp-1.9.238/lib/libaws-cpp-sdk-core.so
```
[Traversing from the `-dev` output](https://github.com/aws/aws-sdk-cpp/blob/6709bb6de9010b165b8bf44b708ba51e26fd5869/cmake/AWSSDKConfig.cmake#L113) will set AWS_SDK_ROOT_DIR to something which will not contain the respective library, which breaks the AWSSDK logic.
In practice, this isn't too much of an issue as `find_package()` will find the corresponding `-targets.cmake`, which will correctly reflect the passed `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR` values for the build. But it does mean that the QoL features of AWSSDK are largely unusable on packaging tools which don't assume FHS (or similar unification of dependencies).
### AWS CPP SDK version used
1.9.238
### Compiler and Version used
gcc 11
### Operating System and version
NixOS 22.11pre393074.614a842b74b (unstable)
Beitragsleitfaden
Rechercherichtung
Lies cmake/AWSSDKConfig.cmake ungefähr in den Zeilen 103 und 113 und untersuche anschließend, wie install(TARGETS) und export(TARGETS) Paketmetadaten erzeugen. Verfolge den find_package(AWSSDK COMPONENTS ...)‑Workflow, wenn Bibliotheks- und Include-Verzeichnisse getrennt sind, und verwende dabei die Nix-Pfade aus dem Issue als Szenario. Als erledigt gilt die Aufgabe, wenn AWSSDK_LINK_LIBRARIES und verwandte QoL-Funktionen funktionieren, ohne gemeinsam angeordnete Verzeichnisse vorauszusetzen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cmake, cpp
- Bereich
- build-system
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100