Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/modern-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Modern Build Matrix

on:
push:
branches: [main, mainline]
paths:
- 'cmake/**'
- 'CMakeLists.txt'
- 'src/aws-cpp-sdk-core/**'
pull_request:
paths:
- 'cmake/**'
- 'CMakeLists.txt'
- 'src/aws-cpp-sdk-core/**'

concurrency:
group: modern-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
build_type: [Release, Debug]
shared: ['ON', 'OFF']
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-${{ matrix.build_type }}-shared=${{ matrix.shared }}
steps:
- uses: actions/checkout@v4

- name: Configure
run: >
cmake -B build
-DLEGACY_BUILD=OFF
-DAWS_SDK_BUILD_ONLY="s3;sts"
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
-DAWS_SDK_ENABLE_TESTING=ON

- name: Build
run: cmake --build build --config ${{ matrix.build_type }}

- name: Test
run: ctest --test-dir build -C ${{ matrix.build_type }} --output-on-failure

- name: Install
run: cmake --install build --config ${{ matrix.build_type }} --prefix ${{ github.workspace }}/install

- name: Verify find_package
shell: bash
run: |
mkdir verify_pkg && cd verify_pkg
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.14)
project(verify)
find_package(aws-cpp-sdk-s3 REQUIRED)
add_executable(verify main.cpp)
target_link_libraries(verify PRIVATE aws-cpp-sdk-s3)
EOF
cat > main.cpp <<'EOF'
#include <aws/s3/S3Client.h>
int main() { return 0; }
EOF
cmake -B build \
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install" \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build --config ${{ matrix.build_type }}

source-package-offline:
runs-on: ubuntu-22.04
name: source-package-offline
steps:
- uses: actions/checkout@v4

- name: Configure
run: cmake -DLEGACY_BUILD=OFF -DAWS_SDK_BUILD_ONLY="s3" -DCMAKE_BUILD_TYPE=Release -B build

- name: Build source package
run: cmake --build build --target package_source

- name: Unpack source archive
run: |
mkdir /tmp/offline-build
tar -xzf build/*.tar.gz -C /tmp/offline-build --strip-components=1

- name: Pre-fetch CRT sources
run: git clone --depth 1 https://github.com/awslabs/aws-crt-cpp.git /tmp/crt-src

- name: Configure offline
run: >
cmake -B /tmp/offline-build/build
-S /tmp/offline-build
-DLEGACY_BUILD=OFF
-DAWS_SDK_BUILD_ONLY="s3"
-DCMAKE_BUILD_TYPE=Release
-DFETCHCONTENT_SOURCE_DIR_AWS-CRT-CPP=/tmp/crt-src
-DFETCHCONTENT_FULLY_DISCONNECTED=ON

- name: Build offline
run: cmake --build /tmp/offline-build/build --config Release
158 changes: 87 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0.
#

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

option(LEGACY_BUILD "If enabled, the SDK will use 1.11.0 version of CMake files to build" ON)
if (LEGACY_BUILD)
Expand Down Expand Up @@ -361,87 +361,103 @@ if (LEGACY_BUILD)
ADD_CUSTOM_TARGET(uninstall-awssdk "${CMAKE_COMMAND}" -P "${AWS_NATIVE_SDK_ROOT}/cmake/make_uninstall.cmake")
endif ()
else () # End of Legacy Build
# -- Preamble --
message(STATUS "Building with new CMake scripts.")
string(CONCAT DESCRIPTION_STRING "The AWS SDK for C++ provides a modern C++ (standard version C++11 or later) "
"interface for Amazon Web Services (AWS).")
# ==========================================================================
# Modern (non-legacy) build path
# ==========================================================================
message(STATUS "Building with modern CMake scripts (LEGACY_BUILD=OFF).")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

find_package(Git QUIET) # Adding development helper tools as git_hash built when available.

# -- Project version --
find_package(Git QUIET)
include(project_version)
obtain_project_version(SDK_PROJECT_VERSION aws-cpp-sdk_GIT_HASH)

project("aws-cpp-sdk"
LANGUAGES CXX
VERSION ${SDK_PROJECT_VERSION}
DESCRIPTION ${DESCRIPTION_STRING}
HOMEPAGE_URL "https://docs.aws.amazon.com/sdk-for-cpp"
)
include(CTest)

# -- Project wide setup --
# Setting C++ minimum requirements
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Setting flags for telling compiler this is a non-legacy build
add_definitions(-DNON_LEGACY_BUILD)
LANGUAGES CXX C
VERSION ${SDK_PROJECT_VERSION}
DESCRIPTION "The AWS SDK for C++ provides a modern C++ interface for Amazon Web Services."
HOMEPAGE_URL "https://docs.aws.amazon.com/sdk-for-cpp"
)

# -- Load modern modules --
include(aws_sdk_options)

# Validate BUILD_ONLY is set before fetching dependencies (fail fast)
if(NOT AWS_SDK_BUILD_ONLY)
message(FATAL_ERROR
"AWS_SDK_BUILD_ONLY is required in the modern build.\n"
"Specify services to build: -DAWS_SDK_BUILD_ONLY=\"s3;dynamodb\"\n"
"To build all services: -DAWS_SDK_BUILD_ONLY=\"all\"")
endif()

# Setting build to hide symbols in targets by default
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
include(aws_sdk_platform)
include(aws_sdk_compiler)
include(fetch_dependencies)

# Preventing writes to package registry by default
# -- Global project settings --
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY YES)

# Validating config type and setting default if needed
get_property(is_multi_conf_build GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT is_multi_conf_build)
set(allowed_build_types Debug Release RelWithDebInfo MinSizeRel)
# cmake-gui helper
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowed_build_types}")
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
elseif (NOT CMAKE_BUILD_TYPE IN_LIST allowed_build_types)
# Validate build type for single-config generators
get_property(_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _is_multi_config)
set(_allowed_types Debug Release RelWithDebInfo MinSizeRel)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${_allowed_types}")
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Defaulting CMAKE_BUILD_TYPE to RelWithDebInfo.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type" FORCE)
elseif(NOT CMAKE_BUILD_TYPE IN_LIST _allowed_types)
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif ()
endif ()
endif()
endif()

# Options definition
option(BUILD_TESTING "If enabled, the SDK will include tests in the build" OFF)

# Next to be included
# # -- Dependencies --
# include(dependencies)

# Configuring the encryption tools used

# # -- main build targets --
# add_subdirectory(src)
# add_subdirectory(generated)

# -- Tests and packaging if running this as top project --
# if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# # Testing Dependencies
# if (BUILD_TESTING)
# add_subdirectory(tests)
# endif ()
# add_subdirectory(packaging)
# endif ()

# Adding integration tests build and run
# Adding end-points tests build and run
# Add support for static analysis
# Building client libraries.
# Doc generation review
# Add support support for old SDK build flags
# Add previously available options.

message(WARNING "This is work in progress build script. No SDK is built so far."
"If you need to build the SDK, you need to use LEGACY_BUILD mode at this time. "
)
# -- Resolve auto-detected options --
aws_sdk_resolve_http_client()

# -- Fetch / find CRT dependencies --
aws_sdk_fetch_dependencies()

# -- Find external dependencies (curl, zlib, etc.) --
aws_sdk_find_external_dependencies()

# -- Build core library --
# The modern core uses its own CMakeLists.modern.txt
# We include it directly since the legacy CMakeLists.txt is still in the same directory
add_subdirectory(src/aws-cpp-sdk-core ${CMAKE_BINARY_DIR}/aws-cpp-sdk-core)

message(STATUS "Modern build: aws-cpp-sdk-core configured.")
message(STATUS " Platform: ${AWS_SDK_PLATFORM}")
message(STATUS " HTTP client: ${AWS_SDK_HTTP_CLIENT}")
message(STATUS " Crypto: ${AWS_SDK_CRYPTO}")
message(STATUS " Shared libs: ${BUILD_SHARED_LIBS}")

# -- Test dependencies (gated behind AWS_SDK_ENABLE_TESTING) --
if(AWS_SDK_ENABLE_TESTING)
include(fetch_test_dependencies)
aws_sdk_fetch_test_dependencies()
enable_testing()
endif()

# -- Build service clients (generated + high-level) --
include(aws_sdk_service_clients)
aws_sdk_build_service_clients()

# -- Symbol leakage verification --
enable_testing()
include(cmake/modern/symbol_check.cmake)
aws_sdk_add_symbol_check(aws-cpp-sdk-core)

# -- Test targets (gated behind AWS_SDK_ENABLE_TESTING) --
if(AWS_SDK_ENABLE_TESTING)
add_subdirectory(tests/testing-resources ${CMAKE_BINARY_DIR}/testing-resources)
add_subdirectory(tests/aws-cpp-sdk-core-tests ${CMAKE_BINARY_DIR}/aws-cpp-sdk-core-tests)
endif()

# -- Install AWSSDK backward-compatibility shim --
include(GNUInstallDirs)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modern/AWSSDKConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AWSSDK)

# -- CPack source distribution --
include(aws_sdk_packaging)
endif ()
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,67 @@ AWS SDK for C++ is now in General Availability and recommended for production us

**_NOTE:_** BUILD_ONLY is an optional flag used to list only the services you are using. Building the whole SDK can take a long time. Also, check out the list of [CMake parameters](./docs/CMake_Parameters.md)

#### Other Dependencies:
### Modern Build (Recommended)

The modern build (`-DLEGACY_BUILD=OFF`) is the recommended way to build and consume the SDK. It uses CMake's FetchContent to automatically acquire the AWS Common Runtime (CRT), eliminating the need for system-installed curl, OpenSSL, or zlib.

**Minimum requirements:** CMake 3.14+, C++14 compiler.

#### Building the SDK:

```sh
mkdir build && cd build
cmake <path-to-source> \
-DLEGACY_BUILD=OFF \
-DBUILD_ONLY="s3;dynamodb" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=<install-path>
cmake --build . --config=Release
cmake --install . --config=Release
```

> **Note:** `BUILD_ONLY` is **required** in the modern build. Specify services as a semicolon-separated list (e.g., `"s3;dynamodb;sts"`).

#### Consuming via FetchContent (Recommended):

The recommended way to use the SDK in your project is via CMake FetchContent:

```cmake
cmake_minimum_required(VERSION 3.14)
project(my_app)

include(FetchContent)
FetchContent_Declare(
aws-sdk-cpp
GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp.git
GIT_TAG <release-tag>
)
set(LEGACY_BUILD OFF CACHE BOOL "")
set(BUILD_ONLY "s3" CACHE STRING "")
FetchContent_MakeAvailable(aws-sdk-cpp)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE aws-cpp-sdk-s3 aws-cpp-sdk-core)
```

This approach handles all dependencies automatically — no system packages required beyond a C++14 compiler and CMake 3.14+.

#### Tested Configurations:

| Platform | Compiler | CMake | Status |
|----------|----------|-------|--------|
| Amazon Linux 2023 | GCC 11+ | 3.22+ | ✅ Supported |
| Ubuntu 22.04 | GCC 11+ / Clang 14+ | 3.22+ | ✅ Supported |
| macOS 13+ | Apple Clang 14+ | 3.24+ | ✅ Supported |
| Windows | MSVC 2019+ | 3.20+ | ✅ Supported |

#### Legacy build:

The legacy build (`-DLEGACY_BUILD=ON`, the default) remains available for backward compatibility. See the sections below for legacy build instructions.

---

#### Other Dependencies (Legacy Build):
To compile in Linux, you must have the header files for libcurl, libopenssl. The packages are typically available in your package manager.

Debian based Linux distributions example:
Expand Down
Loading
Loading