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

aws-sdk-cpp does not work with cmake's find_package() #70075

Closed
timclemons opened this issue Sep 30, 2019 · 7 comments
Closed

aws-sdk-cpp does not work with cmake's find_package() #70075

timclemons opened this issue Sep 30, 2019 · 7 comments
Labels
0.kind: bug Something is broken

Comments

@timclemons
Copy link

Describe the bug
Attempting to use aws-sdk-cpp in nix-shell for development of a cmake-based project causes the build to fail with the following error:

CMake Error at /nix/store/fb5c1m733w8c4ci685nj4g5asdxwnmc9-aws-sdk-cpp-1.7.90-dev/lib/cmake/AWSSDK/AWSSDKConfig.cmake:97 (message):
  AWS SDK for C++ is missing, please install it first
Call Stack (most recent call first):
  CMakeLists.txt:3 (find_package)

To Reproduce
Steps to reproduce the behavior:

  1. Create a shell.nix file with the following contents:
{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    buildInputs = [
      pkgs.gnumake
      pkgs.cmake
      pkgs.clang
      pkgs.aws-sdk-cpp
    ];
  }
  1. In the same directory create a CMakeLists.txt with the following contents:
cmake_minimum_required(VERSION 3.15)
find_package(AWSSDK)
  1. nix-shell && mkdir build && cd build && cmake ..

Expected behavior
Cmake would complete without error

Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.75, NixOS, 20.03pre194293.2436c27541b (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3`
 - channels(tclemons): `""`
 - channels(root): `"nixos-20.03pre194293.2436c27541b"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
  - aws-sdk-cpp
@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@rehno-lindeque
Copy link
Contributor

rehno-lindeque commented Dec 27, 2021

This is still important to me.

I have this error when trying to package https://github.com/aws/amazon-s3-plugin-for-pytorch which relies on aws-sdk-cpp:

CMake Error at /nix/store/kaaffkrfxgb9n53bbb9vagdhpxjlyzgj-aws-sdk-cpp-1.9.121-dev/lib/cmake/AWSSDK/AWSSDKConfig.cmake:86 (message):
  AWS SDK for C++ is missing, please install it first
Call Stack (most recent call first):
  CMakeLists.txt:9 (find_package)

generated by

{ buildPythonPackage
, fetchFromGitHub
, lib
, cmake
, aws-sdk-cpp
}:

let
  custom-aws-sdk-cpp = (aws-sdk-cpp.override {
    apis = ["s3" "transfer"];
    customMemoryManagement = false;
  });
in
buildPythonPackage rec {
  pname = "amazon-s3-plugin-for-pytorch";
  version = "0.0.1";
  src = fetchFromGitHub {
    owner = "aws";
    repo = pname;
    rev = "38284c8a5e92be3bbf47b08e8c90d94be0cb79e7";
    sha256 = "0lww4y3mq854za95hi4y441as4r3h3q0nyrpgj4j6kjk58gijbx9";
  };

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    custom-aws-sdk-cpp
  ];

  checkInputs = [
  ];

  propagatedBuildInputs = [
  ];

  meta = with lib; {
    description = "S3-plugin is a high performance PyTorch dataset library to efficiently access datasets stored in S3 buckets.";
    homepage = "https://github.com/aws/amazon-s3-plugin-for-pytorch";
    license = licenses.asl20;
    maintainers = with maintainers; [];
  };
}

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 27, 2021
@rehno-lindeque
Copy link
Contributor

(As far as I can tell #85254 by @thequux doesn't seem to have resolved the issue)

@rehno-lindeque
Copy link
Contributor

rehno-lindeque commented Jan 22, 2022

This is a workaround I found that fixes the issue:

let
  aws-sdk-cpp-s3-transfer = (aws-sdk-cpp.override {
    apis = ["s3" "transfer"];
  }).overrideAttrs (oldAttrs: {
  
    # Fixes cmake issue in dependent packages (see https://github.com/NixOS/nixpkgs/issues/70075)
    postPatch = oldAttrs.postPatch + ''
      substituteInPlace cmake/AWSSDKConfig.cmake \
        --replace "\''${AWSSDK_DEFAULT_ROOT_DIR}/\''${AWSSDK_INSTALL_INCLUDEDIR}" "\''${AWSSDK_INSTALL_INCLUDEDIR}"
    '';

  });
in
  mkDerivation { ... }

Hence, it should be possible to trace back to the root problem from here:

https://github.com/aws/aws-sdk-cpp/blob/74a1396f93bdcd5e3c3bed25fa73ac472961e55e/cmake/AWSSDKConfig.cmake#L79-L96

if (AWSSDK_ROOT_DIR)
    find_file(AWSSDK_CORE_HEADER_FILE Aws.h
            "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
            "${AWSSDK_DEFAULT_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
            )
else()
    find_file(AWSSDK_CORE_HEADER_FILE Aws.h
        "${AWSSDK_DEFAULT_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "/usr/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "/usr/local/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Progra~1/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files/aws-cpp-sdk-all/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files (x86)/aws-cpp-sdk-all/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
    )
endif()

I'm not clear as to why/how these variables end up different when using find_package(AWSSDK)

@rehno-lindeque
Copy link
Contributor

rehno-lindeque commented Jan 22, 2022

Seems like ff3f5bb#diff-bb198faaa0e40668ef72c8354e3e431dfd37426d45229c6f3c6fa3174652d570 removes the code in cmake-dirs.patch that deals with this.

Partially rolling back this change appears as though it might solve the problem.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 31, 2022
@Artturin
Copy link
Member

Artturin commented Nov 13, 2023

@jmklix does your aws/aws-sdk-cpp#2630 make the patch unnecessary?

After comparing yes it does

#267232

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 13, 2023
@Artturin
Copy link
Member

This was fixed by f7557ec

Added a test to #267232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants