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

How to use with CPM? #3309

Closed
1 task
paulocoutinhox opened this issue Feb 19, 2025 · 5 comments
Closed
1 task

How to use with CPM? #3309

paulocoutinhox opened this issue Feb 19, 2025 · 5 comments
Labels
build-problem problems with building this sdk guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Comments

@paulocoutinhox
Copy link

Describe the bug

Hi,

How to use with CPM (cmake package manager)?

Im using this but it include entire SDK and not only S3:

# --- AWS SDK configuration ---
CPMAddPackage(
    NAME aws-sdk-cpp
    GITHUB_REPOSITORY aws/aws-sdk-cpp
    GIT_TAG "1.11.505"
    OPTIONS
        "BUILD_ONLY='core;s3'"
        "DISABLE_ALL_SERVICES ON"
        "ENABLE_TESTING OFF"
        "BUILD_SHARED_LIBS OFF"
        "ENABLE_UNITY_BUILD ON"
        "MINIMIZE_SIZE ON"
        "NO_ENCRYPTION OFF"
        "NO_HTTP_CLIENT OFF"
        "USE_OPENSSL ON"
        "USE_TLS_V1_2 ON"
        "USE_TLS_V1_3 OFF"
        "FORCE_SHARED_CRT OFF"
)

# --- Executable ---
add_executable(FTPServerS3 main.cpp)

# --- Linking libraries ---
target_link_libraries(FTPServerS3 PRIVATE aws-cpp-sdk-core aws-cpp-sdk-s3)

Can anyone help me?

Thanks.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Build only the selected libraries

Current Behavior

Building the role SDK

Reproduction Steps

rm -rf build/
mkdir -p build/
cd build &&
cmake ../ &&
make

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.505

Compiler and Version used

Apple clang version 16.0.0 (clang-1600.0.26.6)

Operating System and version

macos

@paulocoutinhox paulocoutinhox added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 19, 2025
@sbiscigl
Copy link
Contributor

Im using this but it include entire SDK and not only S3:

try replacing:

"BUILD_ONLY='core;s3'"

with
"BUILD_ONLY s3"

when i do that it works as expected, full example

Project structure

├── CMakeLists.txt
├── cmake
│   └── CPM.cmake
└── main.cpp

cpm/CPM.cmake is the latest release from CPM

CMakeLists.txt

cmake_minimum_required(VERSION 3.30)
project(cpm_example)

set(CMAKE_CXX_STANDARD 20)

include(cmake/CPM.cmake)

CPMAddPackage(
    NAME aws-sdk-cpp
    GITHUB_REPOSITORY aws/aws-sdk-cpp
    GIT_SUBMODULES_RECURSE TRUE
    GIT_TAG "1.11.505"
    OPTIONS
        "BUILD_ONLY s3"
)

add_executable(cpm_example main.cpp)

target_link_libraries(cpm_example
        PRIVATE
        aws-cpp-sdk-core
        aws-cpp-sdk-s3)

main.cpp

#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>

using namespace Aws;
using namespace Aws::S3;

auto main() -> int {
    SDKOptions options{};
    InitAPI(options);
    {
        S3Client client{};
        const auto buckets_outcome = client.ListBuckets();
        assert(buckets_outcome.IsSuccess());
        std::cout << "Found buckets:\n";
        for (const auto& bucket : buckets_outcome.GetResult().GetBuckets())
        {
            std::cout << bucket.GetName() << "\n";
        }
    }
    ShutdownAPI(options);
    return 0;
}

@sbiscigl sbiscigl added guidance Question that needs advice or information. build-problem problems with building this sdk response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 19, 2025
@paulocoutinhox
Copy link
Author

paulocoutinhox commented Feb 19, 2025

Nice, it works.

But i think that has some problem, because only a single module can be selected.

If we use:

"BUILD_ONLY core;s3"

It shows:

[cmake] -- Considering core
[cmake] -- Adding core to SDK build

If im using:

"BUILD_ONLY s3;core"

Only the first is considered:

[cmake] -- Considering s3
[cmake] -- Adding s3 to SDK build

How we can add multiple modules?

In docs said that we can use:

s3;dynamodb;cognito-identity

But if i use it, the cmake only consider the first:

"BUILD_ONLY s3;dynamodb;cognito-identity"

[cmake] -- Considering s3
[cmake] -- Adding s3 to SDK build
[cmake] -- Adding core to SDK build

Thanks.

@sbiscigl
Copy link
Contributor

sbiscigl commented Feb 19, 2025

As we get into more CPM related questions, gotta call out this is more of a CPM question than a SDK question, the amount i can help with relation to their build system is gunna be limited and they can answer these questions better than I can.

That said, from browsing their issues i found cpm-cmake/CPM.cmake#291 which lead to cpm-cmake/CPM.cmake#302 which lead me to the syntax CPM uses to support list options with is a quadruple escaped semi colon, so the following should work

cmake_minimum_required(VERSION 3.30)
project(cpm_example)

set(CMAKE_CXX_STANDARD 20)

include(cmake/CPM.cmake)

CPMAddPackage(
    NAME aws-sdk-cpp
    GITHUB_REPOSITORY aws/aws-sdk-cpp
    GIT_SUBMODULES_RECURSE TRUE
    GIT_TAG "1.11.505"
    OPTIONS "BUILD_ONLY s3\\\\;dynamodb")

add_executable(cpm_example main.cpp)

target_link_libraries(cpm_example
        PRIVATE
        aws-cpp-sdk-core
        aws-cpp-sdk-s3)

that will show

-- Adding s3 to SDK build
-- Adding dynamodb to SDK build
-- Adding core to SDK build

@paulocoutinhox
Copy link
Author

Hi @sbiscigl, perfect. It works. Thanks.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-problem problems with building this sdk guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.
Projects
None yet
Development

No branches or pull requests

2 participants