### Setup Installation Rules Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/testing-resources/CMakeLists.txt Configures the installation process for various testing-related header files into their respective directories. ```cmake setup_install() install (FILES ${AWS_TESTING_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing) install (FILES ${AWS_TESTING_EXTERNAL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/external) install (FILES ${AWS_TESTING_GTEST_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/external/gtest) install (FILES ${AWS_TESTING_GTEST_HEADERS_INTERNAL} DESTINATION ${INCLUDE_DIRECTORY}/aws/external/gtest/internal) install (FILES ${AWS_TESTING_GTEST_HEADERS_INTERNAL_CUSTOM} DESTINATION ${INCLUDE_DIRECTORY}/aws/external/gtest/internal/custom) install (FILES ${AWS_TESTING_PLATFORM_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/platform) install (FILES ${AWS_TESTING_UTILS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/utils) install (FILES ${AWS_TESTING_AUTH_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/aws/auth) install (FILES ${AWS_TESTING_CLIENT_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/aws/client) install (FILES ${AWS_TESTING_EVENT_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/event) install (FILES ${AWS_TESTING_HTTP_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/http) install (FILES ${AWS_TESTING_MONITORING_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/monitoring) ``` -------------------------------- ### Install Documentation Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Installs the OpenSSL documentation to the 'share' directory. ```cmake install( DIRECTORY doc DESTINATION share ) ``` -------------------------------- ### Compile and Install SDK Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 Compiles, links, and installs the AWS C++ SDK. This step may take a few minutes. ```bash $ make $ sudo make install ``` -------------------------------- ### AWS Configuration File Example Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 An example of the AWS configuration file format, specifying the region for a given profile. ```ini [default] region=us-west-2 ``` -------------------------------- ### Install Crypto Library Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/crypto/CMakeLists.txt Installs the crypto target to specified runtime, library, and archive destinations. ```cmake install( TARGETS crypto RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) ``` -------------------------------- ### Install aws-sdk-cpp using vcpkg Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Follow these steps to clone vcpkg, integrate it with your system, and install the aws-sdk-cpp package. The port is maintained by Microsoft and the community. ```sh git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install aws-sdk-cpp ``` -------------------------------- ### Simplify Installation Path with SIMPLE_INSTALL Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md SIMPLE_INSTALL, defaulting to ON, prevents the inclusion of platform-specific intermediate directories (e.g., bin/, lib/) in the install process. Turn OFF for multi-platform releases under a single directory. ```sh -DSIMPLE_INSTALL=OFF ``` -------------------------------- ### Install aws-sdk-cpp using Conan Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Use this command to install aws-sdk-cpp via the Conan package manager. The recipe is maintained by JFrog and the community. ```sh conan install --requires="aws-sdk-cpp/[*]" --build="aws-*" ``` -------------------------------- ### Install libcurl for Debian/Ubuntu Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Install the libcurl development headers on Debian-based Linux distributions. ```sh sudo apt-get install libcurl-dev ``` -------------------------------- ### Install libcurl for RPM-based systems Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Install the libcurl development headers on RPM-based Linux distributions using yum or dnf. ```sh sudo [yum|dnf|zypper] install libcurl-devel ``` -------------------------------- ### Install zlib for Debian/Ubuntu Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Install the zlib development headers on Debian-based Linux distributions, required for request compression. ```sh sudo apt-get install zlib1g-dev ``` -------------------------------- ### Configure CMake Command Arguments for Hello S3 App Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Visual_Studio_building_and_debugging.md Specify the installation path of the AWS SDK for C++ in your CMakeSettings.json for the 'hello_s3' project. Replace '' with the actual path. ```json -DCMAKE_PREFIX_PATH="" ``` -------------------------------- ### Install Encryption Headers Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Installs the UTILS_CRYPTO_CRT_HEADERS to the specified include directory for encryption-related functionality. ```cmake install (FILES ${UTILS_CRYPTO_CRT_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/crypto/crt) ``` -------------------------------- ### Build Android on Windows with JOM Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md To speed up builds for Android on Windows, install JOM and use this CMake command. This is an alternative to using nmake directly. ```sh cmake -G "NMake Makefiles JOM" -DTARGET_ARCH=ANDROID .. ``` -------------------------------- ### Configure and Build AWS SDK for C++ Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Configure the build using CMake, specifying build type, installation prefix, and optionally limiting the build to specific services. Then, build and install the SDK. ```sh cd cmake \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX= \ -DBUILD_ONLY="s3" cmake --build . --config=Debug cmake --install . --config=Debug ``` -------------------------------- ### Install OpenSSL Public Headers Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Finds all public header files in the build directory and installs them to the appropriate include path for external use. ```cmake file( GLOB PUBLIC_HEADERS "${PROJECT_BINARY_DIR}/include/openssl/*.h" ) install( FILES ${PUBLIC_HEADERS} DESTINATION include/openssl ) ``` -------------------------------- ### Install Build Dependencies on Ubuntu Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 Installs GCC, CMake, and development headers for zlib, OpenSSL, and CURL required for building the AWS C++ SDK. ```bash $ sudo apt install g++ cmake -y ``` ```bash $ sudo apt install zlib1g-dev libssl-dev libcurl4-openssl-dev -y ``` -------------------------------- ### Install zlib for RPM-based systems Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Install the zlib development headers on RPM-based Linux distributions using yum or dnf, required for request compression. ```sh sudo yum install zlib-devel or sudo dnf install zlib-devel ``` -------------------------------- ### Initialize and Shutdown SDK Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/SDK_usage_guide.md All code using the AWS SDK for C++ must include initialization and shutdown calls. This ensures proper setup and cleanup of SDK resources. ```cpp #include ... Aws::SDKOptions options; Aws::InitAPI(options); //use the sdk Aws::ShutdownAPI(options); ``` -------------------------------- ### Configure Platform-Specific Directories Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Sets installation directories for OpenSSL and its engines based on the operating system (Windows/MSVC vs. others). ```cmake if( MSVC ) include( MSVCRuntime ) configure_msvc_runtime() set( OPENSSLDIR "C:/ssl" ) set( ENGINESDIR "C:/engines-1.1" ) else() set( OPENSSLDIR "/usr/local/ssl" ) set( ENGINESDIR "/usr/local/engines-1.1" ) endif() add_definitions( "-DOPENSSLDIR=\"${OPENSSLDIR}\"" ) add_definitions( "-DENGINESDIR=\"${ENGINESDIR}\"" ) ``` -------------------------------- ### Example Error Output for FileSystemAlreadyExists Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 Illustrates the detailed error information provided by the SDK when a FileSystemAlreadyExists exception occurs. This includes HTTP response code, remote host IP, request ID, exception name, error message, and response headers. ```text File system with ID: fs-ada1e82d already exists. Failed to create file system. Error details: HTTP response code: 409 Resolved remote host IP address: 52.94.226.247 Request ID: e831b56f-4261-48d9-a43c-a4a37daf38da Exception name: FileSystemAlreadyExists Error message: File system 'fs-ada1e82d' already exists with creation token 'file-system-creation-token-test' 6 response headers: connection : close content-length : 175 content-type : application/json date : Mon, 23 Mar 2020 20:27:06 GMT x-amzn-errortype : FileSystemAlreadyExists: x-amzn-requestid : e831b56f-4261-48d9-a43c-a4a37daf38da ``` -------------------------------- ### Configure Windows HTTP Client (Generic) Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Configures the generic Windows HTTP client by globbing all header and source files starting with 'Win' in the respective directories. This is used when `ENABLE_WINDOWS_CLIENT` is true and `USE_IXML_HTTP_REQUEST_2` is false. ```cmake file(GLOB HTTP_WINDOWS_CLIENT_HEADERS "include/aws/core/http/windows/Win*.h") file(GLOB HTTP_WINDOWS_CLIENT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/Win*.cpp") ``` -------------------------------- ### Configure CPack for Packaging Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Sets up CPack, CMake's packaging utility, to create installers for the OpenSSL build. This includes defining the package name, version, and file name format. ```cmake # Generate the package target set( CPACK_GENERATOR ZIP TGZ ) set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}" ) set( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) set( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) set( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION_STRING}" ) include( CPack ) ``` -------------------------------- ### Configure SDK Build with CMake Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 Configures the SDK build using CMake, specifying to build only the S3 service as a shared library in Release with Debug Info mode. CMake will use the default installation path `/usr/local/lib`. ```bash $ cmake .. -DBUILD_ONLY=s3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON ``` -------------------------------- ### Configure S3 GetObject with File Stream Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Advanced_topics.md This C++ example shows how to configure an S3 GetObject request to use a file stream for the response, preventing the entire object from being loaded into memory. It utilizes a lambda factory to create the file stream. ```cpp GetObjectRequest getObjectRequest; getObjectRequest.SetBucket(fullBucketName); getObjectRequest.SetKey(keyName); getObjectRequest.SetResponseStreamFactory([](){ return Aws::New( ALLOCATION_TAG, DOWNLOADED_FILENAME, std::ios_base::out ); }); auto getObjectOutcome = s3Client->GetObject(getObjectRequest); ``` -------------------------------- ### Initialize SDK with Default Options Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/SDK_usage_guide.md Use this snippet to initialize the SDK with default settings when no custom configurations are needed. ```cpp Aws::SDKOptions options; Aws::InitAPI(options); ..... Aws::ShutdownAPI(options); ``` -------------------------------- ### Build and Run S3 Sample Program on EC2 Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 Steps to create a directory, write C++ source and CMake files, build the sample program with shared libraries enabled, and run it, ensuring the library path is set correctly. ```bash cd ~ mkdir s3sample vim program.cpp vim CMakeLists.txt mkdir build; cd build; cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON make export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./s3sample s3.us-west-2.amazonaws.com SomeBucket SomeKey ALocalFile ``` -------------------------------- ### Initialize SDK with Info Log Level Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/SDK_usage_guide.md Configure the SDK's logging system to capture informational messages during initialization. This is helpful for debugging and monitoring SDK operations. ```cpp SDKOptions options; options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info; Aws::InitAPI(options); //do SDK stuff; Aws::ShutdownAPI(options); ``` -------------------------------- ### Add Project Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/geo-routes-gen-tests/CMakeLists.txt Defines the project name, description, and its dependencies. This is a standard CMake command to initialize a project. ```cmake add_project(geo-routes-gen-tests "Tests for the AWS GEO-ROUTES C++ SDK" testing-resources aws-cpp-sdk-geo-routes aws-cpp-sdk-core) ``` -------------------------------- ### Initialize SDK with Custom HTTP Client Factory Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/SDK_usage_guide.md Override the default HTTP client factory to use a custom implementation. This allows for advanced network configurations or custom HTTP client logic. ```cpp Aws::SDKOptions options; options.httpOptions.httpClientFactory_create_fn = [](){ return Aws::MakeShared("ALLOC_TAG", arg1); }; Aws::InitAPI(options); ..... Aws::ShutdownAPI(options); ``` -------------------------------- ### Add Project Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/timestream-write-gen-tests/CMakeLists.txt Defines the project name, description, and its dependencies. This is a standard CMake command to set up a new project. ```cmake add_project(timestream-write-gen-tests "Tests for the AWS TIMESTREAM-WRITE C++ SDK" testing-resources aws-cpp-sdk-timestream-write aws-cpp-sdk-core) ``` -------------------------------- ### Clone SDK and Create Build Directory Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 Clones the AWS SDK for C++ repository and sets up a build directory for CMake. ```bash $ git clone https://github.com/aws/aws-sdk-cpp.git $ mkdir build $ cd build ``` -------------------------------- ### Define Polly Sample Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/aws-cpp-sdk-polly-sample/CMakeLists.txt Defines the Polly sample project, its description, and its dependencies on other AWS SDK modules. ```cmake add_project(polly_sample "Sample driver app for polly app." aws-cpp-sdk-text-to-speech aws-cpp-sdk-polly aws-cpp-sdk-core) ``` -------------------------------- ### Uninstall AWS SDK Libraries Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Advanced_topics.md Use 'make uninstall' to remove all installed libraries. For sub-projects, 'make uninstall-awssdk' can be used to uninstall only SDK-related libraries. ```sh make uninstall ``` ```sh make uninstall-awssdk ``` -------------------------------- ### Add KinesisAnalytics Generated Tests Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/kinesisanalytics-gen-tests/CMakeLists.txt Defines the KinesisAnalytics generated tests project, specifying its dependencies and source directories. This is a standard CMake command for project setup. ```cmake add_project(kinesisanalytics-gen-tests "Tests for the AWS KINESISANALYTICS C++ SDK" testing-resources aws-cpp-sdk-kinesisanalytics aws-cpp-sdk-core) ``` -------------------------------- ### Sample S3 GetObject Program Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 A C++ program that demonstrates downloading a file from S3 using the AWS SDK. It requires command-line arguments for the region endpoint, bucket name, S3 key, and local destination path. ```cpp // program.cpp #include #include #include #include #include #include #include #include #include using namespace Aws; int main(int argc, char *argv[]) { if (argc < 5) { std::cout << " Usage: s3sample \n" << "Example: s3sample s3.us-west-2.amazonaws.com MyBucket MyKey MyLocalFile.pdf" << std::endl; return 0; } SDKOptions options; options.loggingOptions.logLevel = Utils::Logging::LogLevel::Error; InitAPI(options); { Client::ClientConfiguration config; config.endpointOverride = argv[1]; config.scheme = Http::Scheme::HTTPS; S3::S3Client client(config); S3::Model::GetObjectRequest request; request.WithBucket(argv[2]).WithKey(argv[3]); request.SetResponseStreamFactory([argv] { return new std::fstream(argv[4], std::ios_base::out); }); auto outcome = client.GetObject(request); if (outcome.IsSuccess()) { std::cout << "Completed!" << std::endl; } else { std::cout << "Failed with error: " << outcome.GetError() << std::endl; } } ShutdownAPI(options); return 0; } ``` -------------------------------- ### Initialize SDK with Custom Memory Manager Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/SDK_usage_guide.md Configure the SDK to use a custom memory manager by providing an instance during initialization. This is useful for specific memory allocation strategies. ```cpp MyMemoryManager memoryManager; Aws::SDKOptions options; options.memoryManagementOptions.memoryManager = &memoryManager; Aws::InitAPI(options); ..... Aws::ShutdownAPI(options); ``` -------------------------------- ### CMakeLists.txt for AWS SDK Project Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 This CMakeLists.txt file configures a C++ project to use the AWS SDK, specifically the S3 component. Ensure the AWS SDK is installed or discoverable by CMake. ```cmake cmake_minimum_required(VERSION 3.5) project(s3sample) find_package(AWSSDK REQUIRED COMPONENTS s3) set(CMAKE_CXX_STANDARD 11) add_executable(s3sample "program.cpp") ``` -------------------------------- ### Add Project Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/cleanroomsml-gen-tests/CMakeLists.txt Defines the project name, description, and dependencies for the cleanroomsml-gen-tests. ```cmake add_project(cleanroomsml-gen-tests "Tests for the AWS CLEANROOMSML C++ SDK" testing-resources aws-cpp-sdk-cleanroomsml aws-cpp-sdk-core) ``` -------------------------------- ### CMakeLists.txt for Sample Program Source: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2 The CMakeLists.txt file required to build the sample C++ program that uses the AWS SDK for S3. ```cmake ``` -------------------------------- ### Curl Logging Example Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 When ENABLE_CURL_LOGGING is enabled, Curl's internal logs are piped to the SDK's logger at DEBUG level or higher. This provides detailed information about network communication, TLS handshakes, and HTTP headers. ```text [DEBUG] 2020-04-07 19:58:06.792 CURL [0x10d6c65c0] (Text) Rebuilt URL to: https://s3.amazonaws.com/ [DEBUG] 2020-04-07 19:58:06.824 CURL [0x10d6c65c0] (Text) Trying 52.216.29.46... [DEBUG] 2020-04-07 19:58:06.824 CURL [0x10d6c65c0] (Text) TCP_NODELAY set [DEBUG] 2020-04-07 19:58:06.924 CURL [0x10d6c65c0] (Text) Connected to s3.amazonaws.com (52.216.29.46) port 443 (#0 [DEBUG] 2020-04-07 19:58:06.924 CURL [0x10d6c65c0] (Text) ALPN, offering h2 [DEBUG] 2020-04-07 19:58:06.924 CURL [0x10d6c65c0] (Text) ALPN, offering http/1.1 [DEBUG] 2020-04-07 19:58:06.924 CURL [0x10d6c65c0] (Text) Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH [DEBUG] 2020-04-07 19:58:06.931 CURL [0x10d6c65c0] (Text) successfully set certificate verify locations [DEBUG] 2020-04-07 19:58:06.931 CURL [0x10d6c65c0] (Text) CAfile: /etc/ssl/cert.pem CApath: none [DEBUG] 2020-04-07 19:58:06.931 CURL [0x10d6c65c0] (Text) TLSv1.2 (OUT), TLS handshake, Client hello (1): [DEBUG] 2020-04-07 19:58:06.931 CURL [0x10d6c65c0] (SSLDataOut) 222bytes [DEBUG] 2020-04-07 19:58:07.034 CURL [0x10d6c65c0] (Text) TLSv1.2 (IN), TLS handshake, Server hello (2): [DEBUG] 2020-04-07 19:58:07.034 CURL [0x10d6c65c0] (SSLDataIn) 91bytes ... [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) ALPN, server did not agree to a protocol [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) Server certificate: [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) subject: C=US; ST=Washington; L=Seattle; O=Amazon.com, Inc.; CN=s3.amazonaws.com [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) start date: Nov 9 00:00:00 2019 GMT [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) expire date: Dec 2 12:00:00 2020 GMT [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) subjectAltName: host "s3.amazonaws.com" matched cert's "s3.amazonaws.com" [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert Baltimore CA-2 G2 [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (Text) SSL certificate verify ok. [DEBUG] 2020-04-07 19:58:07.140 CURL [0x10d6c65c0] (HeaderOut) GET / HTTP/1.1 host: s3.amazonaws.com Accept: */* authorization: AWS4-HMAC-SHA256 Credential=AKIAJYTC5UXRVQGPK73Q/20200407/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=62e7d2da86ec118357ee86aa7deda5afafb93936ee46b59299881683ded50d5a user-agent: aws-sdk-cpp/1.7.266 Darwin/18.7.0 x86_64 Clang/10.0.1 x-amz-content-sha256: UNSIGNED-PAYLOAD x-amz-date: 20200407T195806Z [DEBUG] 2020-04-07 19:58:07.284 CURL [0x10d6c65c0] (HeaderIn) HTTP/1.1 200 OK [TRACE] 2020-04-07 19:58:07.284 CurlHttpClient [0x10d6c65c0] HTTP/1.1 200 OK [DEBUG] 2020-04-07 19:58:07.284 CURL [0x10d6c65c0] (HeaderIn) x-amz-id-2: i4Y+p7ujlZjUYoLsYSEx0hlfYaJJil3JBqaumJXjbUCgUEZwKETc3rvOrfjnpE31tqgRC9SpZeY= [TRACE] 2020-04-07 19:58:07.284 CurlHttpClient [0x10d6c65c0] x-amz-id-2: i4Y+p7ujlZjUYoLsYSEx0hlfYaJJil3JBqaumJXjbUCgUEZwKETc3rvOrfjnpE31tqgRC9SpZeY= ... [TRACE] 2020-04-07 19:58:07.285 CurlHttpClient [0x10d6c65c0] Server: AmazonS3 [TRACE] 2020-04-07 19:58:07.285 CurlHttpClient [0x10d6c65c0] [DEBUG] 2020-04-07 19:58:07.285 CURL [0x10d6c65c0] (HeaderIn) [DEBUG] 2020-04-07 19:58:07.287 CURL [0x10d6c65c0] (DataIn) 1664 [DEBUG] 2020-04-07 19:58:07.287 CURL [0x10d6c65c0] (DataIn) 0 [DEBUG] 2020-04-07 19:58:07.287 CURL [0x10d6c65c0] (Text) Connection #0 to host s3.amazonaws.com left intact ``` -------------------------------- ### Create DynamoDB Client with Manual Credentials Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Service_Client.md Constructs a DynamoDB client by manually providing access key ID and secret key along with a client configuration. ```cpp auto client = Aws::MakeShared(ALLOCATION_TAG, AWSCredentials("access_key_id", "secret_key"), config); ``` -------------------------------- ### Configure Separate Logging for CRT Source: https://github.com/aws/aws-sdk-cpp/wiki/Improving-S3-Throughput-with-AWS-SDK-for-CPP-v1.9 Redirect AWS Common Runtime library logs to a separate file or set a less verbose log level for CRT messages. This example sets the CRT log level to 'Info'. ```c++ options.loggingOptions.crt_logger_create_fn = [](){ return Aws::MakeShared("CRTLogSystem", Aws::Utils::Logging::LogLevel::Info); }; ``` -------------------------------- ### Regenerate Client Code with REGENERATE_CLIENTS Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md Set REGENERATE_CLIENTS to 1 to wipe out existing generated code and regenerate client directories from the code-generation/api-definitions folder. This requires Python 2.7, Java (JDK 1.8), and Maven to be installed and in the executable path. ```sh -DREGENERATE_CLIENTS=1 ``` -------------------------------- ### Perform Packaging Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/testing-resources/CMakeLists.txt Executes the packaging process for the project. ```cmake do_packaging() ``` -------------------------------- ### Initialize SDK with Custom Memory Manager Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Memory_Management.md In your `main` function, instantiate your custom memory manager and pass it to `SDKOptions` before initializing the AWS SDK API. This ensures all SDK memory operations use your manager. ```cpp int main(void) { MyMemoryManager sdkMemoryManager; SDKOptions options; options.memoryManagementOptions.memoryManager = &sdkMemoryManager; Aws::InitAPI(options); // ... do stuff Aws::ShutdownAPI(options); return 0; } ``` -------------------------------- ### Minimize Binary Size with MINIMIZE_SIZE Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md Enable MINIMIZE_SIZE to activate ENABLE_UNITY_BUILD and additional binary size reduction settings, including symbol stripping. This is an experimental feature and may change. ```sh -DMINIMIZE_SIZE=ON ``` -------------------------------- ### Build Android on Windows with NMake Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Use this CMake command when building for Android on Windows with NMake. Ensure 'git' and 'patch' are in your PATH. ```sh cmake -G "NMake Makefiles" -DTARGET_ARCH=ANDROID .. ``` -------------------------------- ### Enable/Disable Unity Build with ENABLE_UNITY_BUILD Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md ENABLE_UNITY_BUILD, which defaults to ON, compiles most SDK libraries into a single .cpp file to reduce size and speed up compilation. This option can be turned off if not desired. ```sh -DENABLE_UNITY_BUILD=OFF ``` -------------------------------- ### Executable or Library Target Creation Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/dsql-gen-tests/CMakeLists.txt Configures whether to build an executable or a library based on platform and build settings. ```cmake if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_DSQL_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_DSQL_GENERATED_TEST_SRC}") endif() ``` -------------------------------- ### Configure Windows HTTP Client (IXmlHttpRequest2) Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Configures the Windows HTTP client using IXmlHttpRequest2. Note that HTTP/2 is not supported with this implementation. Includes additional headers and sources for bypassing the default proxy if `BYPASS_DEFAULT_PROXY` is enabled. ```cmake set(HTTP_WINDOWS_CLIENT_HEADERS "include/aws/core/http/windows/IXmlHttpRequest2HttpClient.h") set(HTTP_WINDOWS_CLIENT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/IXmlHttpRequest2HttpClient.cpp") if(BYPASS_DEFAULT_PROXY) # add winhttp since IXmlHttpRequest2 can't bypass proxy list(APPEND HTTP_WINDOWS_CLIENT_HEADERS "include/aws/core/http/windows/WinSyncHttpClient.h" "include/aws/core/http/windows/WinHttpSyncHttpClient.h" "include/aws/core/http/windows/WinConnectionPoolMgr.h" "include/aws/core/http/windows/WinHttpConnectionPoolMgr.h") list(APPEND HTTP_WINDOWS_CLIENT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/WinSyncHttpClient.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/WinHttpSyncHttpClient.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/WinConnectionPoolMgr.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/source/http/windows/WinHttpConnectionPoolMgr.cpp") endif() ``` -------------------------------- ### Configure Network Source Files by Platform Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Selects network-related source files based on the target platform. It uses specific directories for Windows, Linux/macOS/Android, and other platforms. ```cmake if (PLATFORM_WINDOWS) file(GLOB NET_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/net/windows/*.cpp") elseif(PLATFORM_LINUX OR PLATFORM_APPLE OR PLATFORM_ANDROID) file(GLOB NET_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/net/linux-shared/*.cpp") else() file(GLOB NET_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/net/*.cpp") endif() ``` -------------------------------- ### Create DynamoDB Client with Custom Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Service_Client.md Constructs a DynamoDB client using a specialized configuration, including rate limiters and timeouts. Ensure the Aws::InitAPI() has been called before creating clients. ```cpp auto limiter = Aws::MakeShared>(ALLOCATION_TAG, 200000); // Create a client ClientConfiguration config; config.scheme = Scheme::HTTPS; config.connectTimeoutMs = 30000; config.requestTimeoutMs = 30000; config.readRateLimiter = m_limiter; config.writeRateLimiter = m_limiter; auto client = Aws::MakeShared(ALLOCATION_TAG, config); ``` -------------------------------- ### Add Project Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/bcm-data-exports-gen-tests/CMakeLists.txt Defines the project name, description, and dependencies for the bcm-data-exports-gen-tests. ```cmake add_project(bcm-data-exports-gen-tests "Tests for the AWS BCM-DATA-EXPORTS C++ SDK" testing-resources aws-cpp-sdk-bcm-data-exports aws-cpp-sdk-core) ``` -------------------------------- ### Configure Include Directories for Testing Library Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/testing-resources/CMakeLists.txt Sets public include directories for the testing resources library, including build-time and install-time paths. ```cmake target_include_directories(${PROJECT_NAME} PUBLIC $ $ $) ``` -------------------------------- ### Add Executable or Library for Tests Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/wellarchitected-gen-tests/CMakeLists.txt Configures the project as either an executable or a shared library based on platform and build settings. ```cmake if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_WELLARCHITECTED_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_WELLARCHITECTED_GENERATED_TEST_SRC}") endif() ``` -------------------------------- ### Add Project Configuration Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/sagemaker-metrics-gen-tests/CMakeLists.txt Defines the sagemaker-metrics-gen-tests project, its description, and its dependencies. ```cmake add_project(sagemaker-metrics-gen-tests "Tests for the AWS SAGEMAKER-METRICS C++ SDK" testing-resources aws-cpp-sdk-sagemaker-metrics aws-cpp-sdk-core) ``` -------------------------------- ### Basic CMake Integration with Components Source: https://github.com/aws/aws-sdk-cpp/wiki/Example-CMake-Scripts-to-Build-Your-Project-Against-the-CPP-SDK Use this for basic integration where you want to link against multiple AWS SDK components. It simplifies dependency management by automatically resolving high-level dependencies. ```cmake find_package(AWSSD REQUIRED COMPONENTS transfer s3-encryption dynamodb) target_link_libraries(target ${AWSSDK_LINK_LIBRARIES}) ``` -------------------------------- ### Windows Specific Settings Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Configures library prefixes for Windows and defines system-specific macros, including flags to avoid conflicts and enable DLL builds. ```cmake if( WIN32 ) set( CMAKE_SHARED_LIBRARY_PREFIX "lib" ) set( CMAKE_STATIC_LIBRARY_PREFIX "lib" ) endif() if( WIN32 AND NOT CYGWIN ) add_definitions( -DOPENSSL_SYSNAME_WIN32 ) add_definitions( -DWIN32_LEAN_AND_MEAN ) add_definitions( -D_CRT_SECURE_NO_WARNINGS ) if(BUILD_SHARED_LIBS) # avoid conflict: ocsp.h and wincrypt.h add_definitions( -D_WINDLL ) endif() endif() ``` -------------------------------- ### Define Launch Wizard Generated Tests Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/launch-wizard-gen-tests/CMakeLists.txt Defines the launch-wizard-gen-tests project, its description, and its dependencies. ```cmake add_project(launch-wizard-gen-tests "Tests for the AWS LAUNCH-WIZARD C++ SDK" testing-resources aws-cpp-sdk-launch-wizard aws-cpp-sdk-core) ``` -------------------------------- ### Build Executable or Library Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/redshift-gen-tests/CMakeLists.txt Configures the project to build either an executable or a shared library based on platform and build settings. ```cmake if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_REDSHIFT_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_REDSHIFT_GENERATED_TEST_SRC}") endif() ``` -------------------------------- ### Enable Testing Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/aws-cpp-sdk-monitoring-unit-tests/CMakeLists.txt Enables the testing framework for the project. ```cmake enable_testing() ``` -------------------------------- ### Add Custom Build Command for Test Execution Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/amplifybackend-gen-tests/CMakeLists.txt Configures a custom post-build command to run the AmplifyBackend tests with specific arguments, including setting the LD_LIBRARY_PATH environment variable. ```cmake if (AUTORUN_UNIT_TESTS) ADD_CUSTOM_COMMAND( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${AWS_AUTORUN_LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH} $ ARGS "--gtest_brief=1") endif() ``` -------------------------------- ### Define Project and Dependencies Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/iot-jobs-data-gen-tests/CMakeLists.txt Defines the test project for the AWS IOT-JOBS-DATA C++ SDK and lists its dependencies, including testing resources and core SDK components. ```cmake add_project(iot-jobs-data-gen-tests "Tests for the AWS IOT-JOBS-DATA C++ SDK" testing-resources aws-cpp-sdk-iot-jobs-data aws-cpp-sdk-core) ``` -------------------------------- ### Enable Zlib Request Compression Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Enable gzip/deflate request compression support by setting the CMake parameter. Zlib is optional and only required if this feature is enabled. ```cmake -DENABLE_ZLIB_REQUEST_COMPRESSION=ON ``` -------------------------------- ### Define Partnercentral Selling Tests Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/partnercentral-selling-gen-tests/CMakeLists.txt Defines the main test project and its dependencies. Includes tests for the AWS PARTNERCENTRAL-SELLING C++ SDK. ```cmake add_project(partnercentral-selling-gen-tests "Tests for the AWS PARTNERCENTRAL-SELLING C++ SDK" testing-resources aws-cpp-sdk-partnercentral-selling aws-cpp-sdk-core) ``` -------------------------------- ### Explicit Region Configuration Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 Demonstrates how to explicitly set the AWS region using the ClientConfiguration object before creating a service client. ```cpp Aws::Client::ClientConfiguration config; config.region = Aws::Region::US_WEST_2; Aws::S3::S3Client s3Client(config); ``` -------------------------------- ### Link Libraries Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/resiliencehubv2-gen-tests/CMakeLists.txt Links the necessary libraries to the test project. ```cmake target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS}) ``` -------------------------------- ### Define Testing Library and Alias Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/testing-resources/CMakeLists.txt Creates a library for testing resources and an alias for it. Also defines the gtest_main library. ```cmake add_library(${PROJECT_NAME} ${TestingResources_SRC}) add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) add_library(aws_test_main source/external/gtest/src/gtest_main.cc) ``` -------------------------------- ### Use CRT HTTP Client with USE_CRT_HTTP_CLIENT Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md Enable USE_CRT_HTTP_CLIENT to use the common runtime HTTP client, excluding legacy clients like WinHttp and libcurl. Defaults to OFF. ```sh -DUSE_CRT_HTTP_CLIENT=ON ``` -------------------------------- ### Copy Resources Before Build Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/aws-cpp-sdk-core-tests/CMakeLists.txt Adds a custom command to copy resource files from the source directory to the binary directory before the target 'aws-cpp-sdk-core-tests' is built. This ensures test resources are available during execution. ```cmake add_custom_command(TARGET aws-cpp-sdk-core-tests PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/resources ${CMAKE_CURRENT_BINARY_DIR}) ``` -------------------------------- ### Configure Crypto Configuration Headers Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/crypto/CMakeLists.txt Writes configuration definitions to temporary CMake files and then configures them into final header files for bn_conf.h and dso_conf.h. These headers define build-time configurations for big number arithmetic and dynamic shared object handling. ```cmake file(WRITE ${PROJECT_BINARY_DIR}/bn_conf.h.cmake "${BN_CONF}") file(WRITE ${PROJECT_BINARY_DIR}/dso_conf.h.cmake "#define DSO_EXTENSION \".so\" #define DSO_DLFCN #define HAVE_DLFCN_H") configure_file( ${PROJECT_BINARY_DIR}/bn_conf.h.cmake ${PROJECT_BINARY_DIR}/include/crypto/bn_conf.h ) configure_file( ${PROJECT_BINARY_DIR}/dso_conf.h.cmake ${PROJECT_BINARY_DIR}/include/crypto/dso_conf.h ) ``` -------------------------------- ### Add Executable or Library for PINPOINT Tests Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/pinpoint-gen-tests/CMakeLists.txt Configures the build to create either an executable or a library for the PINPOINT tests based on platform and shared library build settings. ```cmake if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_PINPOINT_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_PINPOINT_GENERATED_TEST_SRC}") endif() ``` -------------------------------- ### Enable/Disable Testing with ENABLE_TESTING Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md ENABLE_TESTING controls the building of unit and integration test projects. Defaults to ON. ```sh -DENABLE_TESTING=OFF ``` -------------------------------- ### Add proton-gen-tests Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/proton-gen-tests/CMakeLists.txt Defines the project name, description, and its dependencies. ```cmake add_project(proton-gen-tests "Tests for the AWS PROTON C++ SDK" testing-resources aws-cpp-sdk-proton aws-cpp-sdk-core) file(GLOB AWS_PROTON_GENERATED_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" ) if(MSVC AND BUILD_SHARED_LIBS) add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) endif() if (CMAKE_CROSSCOMPILING) set(AUTORUN_UNIT_TESTS OFF) endif() if (AUTORUN_UNIT_TESTS) enable_testing() endif() if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_PROTON_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_PROTON_GENERATED_TEST_SRC}") endif() set_compiler_flags(${PROJECT_NAME}) set_compiler_warnings(${PROJECT_NAME}) target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS}) if (AUTORUN_UNIT_TESTS) ADD_CUSTOM_COMMAND( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${AWS_AUTORUN_LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH} $ ARGS "--gtest_brief=1") endif() if(NOT CMAKE_CROSSCOMPILING) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) endif() ``` -------------------------------- ### Custom HTTP Client Factory Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 Create a custom HTTP client factory by extending Aws::Http::HttpClientFactory and implementing the CreateHttpClient method to return a custom HTTP client. ```cpp class MyHttpClientFactory : public Aws::Http::HttpClientFactory { std::shared_ptr CreateHttpClient(const Aws::Client::ClientConfiguration& clientConfiguration) const override { return Aws::MakeShared(ALLOCATION_TAG, clientConfiguration); } }; ``` -------------------------------- ### Configure CMake Command Arguments for SDK Build Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Visual_Studio_building_and_debugging.md Add this argument to your CMakeSettings.json to specify that only the 's3' module should be built, reducing build time and size. ```json -DBUILD_ONLY="s3" ``` -------------------------------- ### Use IXmlHttpRequest2 on Windows with USE_IXML_HTTP_REQUEST_2 Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md On Windows, enabling USE_IXML_HTTP_REQUEST_2 uses the IXmlHttpRequest2 COM object for the HTTP stack. Defaults to OFF. ```sh -DUSE_IXML_HTTP_REQUEST_2=ON ``` -------------------------------- ### Enable Endpoint Discovery in Client Configuration (Pre-v1.9) Source: https://github.com/aws/aws-sdk-cpp/wiki/Improving-S3-Throughput-with-AWS-SDK-for-CPP-v1.9 In SDK versions prior to v1.9, endpoint discovery was explicitly enabled or disabled in the client configuration. This snippet shows how to enable it. ```cpp Aws::Client::ClientCOnfiguration config; config.enableEndpointDiscovery = true; ``` -------------------------------- ### Build with ENABLE_UNITY_BUILD ON Source: https://github.com/aws/aws-sdk-cpp/wiki/What’s-New-in-AWS-SDK-for-CPP-Version-1.8 Configure CMake to enable UNITY_BUILD, specify the S3 module, and disable shared libraries. This command is used to measure compile time and binary size when UNITY_BUILD is on. ```bash cmake -DENABLE_UNITY_BUILD=ON -DBUILD_ONLY=s3 -DBUILD_SHARED_LIBS=OFF make -j8 ``` -------------------------------- ### Enabling Unity Build Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Enables unity build for the 'core' target if the ENABLE_UNITY_BUILD option is set. ```cmake if(ENABLE_UNITY_BUILD) enable_unity_build("core" AWS_NATIVE_SDK_UNITY_SRC) endif() ``` -------------------------------- ### Add mailmanager-gen-tests Project Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/mailmanager-gen-tests/CMakeLists.txt Defines the main project and its dependencies. Include this when building the mailmanager-gen-tests executable. ```cmake add_project(mailmanager-gen-tests "Tests for the AWS MAILMANAGER C++ SDK" testing-resources aws-cpp-sdk-mailmanager aws-cpp-sdk-core) ``` -------------------------------- ### Aggregating All SDK Source Files Source: https://github.com/aws/aws-sdk-cpp/blob/main/src/aws-cpp-sdk-core/CMakeLists.txt Aggregates unified headers, unity build sources, and non-unity sources into the final list of source files for the SDK. ```cmake file(GLOB AWS_NATIVE_SDK_SRC ${AWS_NATIVE_SDK_UNIFIED_HEADERS} ${AWS_NATIVE_SDK_UNITY_SRC} ${AWS_NATIVE_SDK_NON_UNITY_SRC} ) ``` -------------------------------- ### Generate Build Information Header Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/crypto/CMakeLists.txt Generates a build information header file with the current UTC timestamp. This is useful for tracking build details. ```cmake string(TIMESTAMP BUILDINF_DATE "%Y-%m-%d %H:%M:%S UTC" UTC) configure_file( buildinf.h.cmake buildinf.h ) ``` -------------------------------- ### Clone AWS SDK for C++ Repository Source: https://github.com/aws/aws-sdk-cpp/blob/main/README.md Use this command to clone the AWS SDK for C++ repository, including all submodules. ```sh git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp ``` -------------------------------- ### Define Core Tests Library or Executable Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/aws-cpp-sdk-core-tests/CMakeLists.txt Configures the project to build either a library or an executable for the core tests based on the PROJECT_NAME variable. Includes source files and sets compiler flags and warnings. ```cmake add_library(${PROJECT_NAME} ${AWS_CPP_SDK_CORE_TESTS_SRC}) else() add_executable(${PROJECT_NAME} ${AWS_CPP_SDK_CORE_TESTS_SRC}) endif() set_compiler_flags(${PROJECT_NAME}) set_compiler_warnings(${PROJECT_NAME}) ``` -------------------------------- ### Run Code Generation for Custom Clients Source: https://github.com/aws/aws-sdk-cpp/blob/main/docs/Advanced_topics.md Execute the code generation script to create custom AWS clients. Ensure your model files are placed in the correct directories before running. ```bash python3 tools/scripts/run_code_generation.py --client_list mycustomservice ``` -------------------------------- ### Add Executable or Library for Tests Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/comprehendmedical-gen-tests/CMakeLists.txt Adds either an executable or a library for the test project based on platform and build type. ```cmake if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) add_library(${PROJECT_NAME} "${AWS_COMPREHENDMEDICAL_GENERATED_TEST_SRC}") else() add_executable(${PROJECT_NAME} "${AWS_COMPREHENDMEDICAL_GENERATED_TEST_SRC}") endif() ``` -------------------------------- ### Glob Source Files Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/sagemaker-metrics-gen-tests/CMakeLists.txt Finds all .cpp files in the current source directory and assigns them to AWS_SAGEMAKER_METRICS_GENERATED_TEST_SRC. ```cmake file(GLOB AWS_SAGEMAKER-METRICS_GENERATED_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" ) ``` -------------------------------- ### Fetch cxxopts Dependency Source: https://github.com/aws/aws-sdk-cpp/blob/main/tests/performance-tests/CMakeLists.txt Declares and makes available the cxxopts library, used for command-line argument parsing in performance tests. ```cmake include(FetchContent) FetchContent_Declare( cxxopts GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git GIT_TAG v3.1.1 ) FetchContent_MakeAvailable(cxxopts) ``` -------------------------------- ### Build all_services_test Executable Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/CI/install-test/CMakeLists.txt Defines the all_services_test executable and links it with all AWS SDK libraries. It also specifies the include directories required for the SDK. ```cmake add_executable(all_services_test all_services_test.cpp) target_link_libraries(all_services_test ${AWSSDK_LINK_LIBRARIES}) target_include_directories(all_services_test PRIVATE ${AWSSDK_INCLUDE_DIRS}) ``` -------------------------------- ### MinGW Specific Settings Source: https://github.com/aws/aws-sdk-cpp/blob/main/tools/android-build/cmakefiles/openssl-cmake/CMakeLists.txt Applies specific linker flags for MinGW builds to export all symbols. ```cmake if( MINGW ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all" ) endif() ``` -------------------------------- ### Discover Test Source Files Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/iot-jobs-data-gen-tests/CMakeLists.txt Uses file globbing to find all .cpp files in the current source directory for the test executable. ```cmake file(GLOB AWS_IOT-JOBS-DATA_GENERATED_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" ) ``` -------------------------------- ### Glob Source Files for Invoicing Tests Source: https://github.com/aws/aws-sdk-cpp/blob/main/generated/tests/invoicing-gen-tests/CMakeLists.txt Discovers all .cpp source files within the current directory for the invoicing tests. ```cmake file(GLOB AWS_INVOICING_GENERATED_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" ) ```