-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Updated sample App CMake definition to not depend on larger project internals #2350
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,53 @@ | ||
cmake_minimum_required(VERSION 3.3) | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
# -- Preamble -- | ||
project("sample_app" | ||
LANGUAGES CXX | ||
VERSION 1.0 | ||
DESCRIPTION "A testing app using AWS SDK for C++" | ||
) | ||
|
||
# -- Project wide setup -- | ||
# Setting C++ minimum requirements | ||
set(CMAKE_CXX_STANDARD 11) | ||
project(app LANGUAGES CXX) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Setting build to hide symbols in targets by default | ||
set(CMAKE_CXX_VISIBILITY_PRESET hidden) | ||
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) | ||
|
||
# Preventing writes to package registry by default | ||
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) | ||
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}") | ||
endif () | ||
endif () | ||
|
||
# -- Dependencies -- | ||
find_package(AWSSDK REQUIRED COMPONENTS s3-crt) | ||
add_executable(${PROJECT_NAME} "main.cpp") | ||
if(MSVC AND BUILD_SHARED_LIBS) | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC "USE_IMPORT_EXPORT") | ||
add_definitions(-DUSE_IMPORT_EXPORT) | ||
# Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging. | ||
list(APPEND SERVICE_LIST s3-crt) | ||
AWSSDK_CPY_DYN_LIBS(SERVICE_LIST "" ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) | ||
endif() | ||
set_compiler_flags(${PROJECT_NAME}) | ||
set_compiler_warnings(${PROJECT_NAME}) | ||
target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES}) | ||
|
||
# -- main build target -- | ||
add_executable(app "main.cpp") | ||
target_link_libraries(app ${AWSSDK_LINK_LIBRARIES}) | ||
target_include_directories(app PRIVATE ${AWSSDK_INCLUDE_DIRS}) | ||
|
||
# -- install target -- | ||
include(GNUInstallDirs) | ||
set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}) | ||
|
||
install(TARGETS app | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0. | ||
|
||
# This script builds a sample app | ||
# Directories created and files are prefixed with PREFIX_DIR argument | ||
# SDK installation is expected to be in ${PREFIX_DIR}/mac-install and a clone of aws-sdk-cpp is expected to be in ${PREFIX_DIR}/aws-sdk-cpp | ||
# A AWS_ACCOUNT with proper role setup is required to run the built app, if passed argument, app is tried to run after build | ||
# Platform: Windows | ||
|
||
param($PREFIX_DIR) | ||
|
||
cd "${PREFIX_DIR}/aws-sdk-cpp/tools/CI/install-test" | ||
mkdir "${PREFIX_DIR}/sample-build" | ||
mkdir "${PREFIX_DIR}/sample-install" | ||
cd "${PREFIX_DIR}/sample-build" | ||
&'C:\\Program Files\\CMake\\bin\\cmake.exe' ../aws-sdk-cpp/tools/CI/install-test -DCMAKE_CXX_FLAGS="-ggdb -fsanitize=address" -DCMAKE_PREFIX_PATH="${PREFIX_DIR}/win-install" -DCMAKE_INSTALL_PREFIX="${PREFIX_DIR}/sample_install" | ||
&'C:\\Program Files\\CMake\\bin\\cmake.exe' --build . | ||
&'C:\\Program Files\\CMake\\bin\\cmake.exe' --build . --target install | ||
|
||
echo "Setting the run environment" | ||
$TEST_ASSUME_ROLE_ARN = "arn:aws:iam::${env:AWS_ACCOUNT}:role/IntegrationTest" | ||
${env:TEST_LAMBDA_CODE_PATH} = "${env:PREFIX_DIR}/aws-sdk-cpp/tests/aws-cpp-sdk-lambda-integration-tests/resources" | ||
$sts = aws sts assume-role --role-arn "${TEST_ASSUME_ROLE_ARN}" --role-session-name "${env:AWS_ROLE_SESSION_NAME}" --query "Credentials.[AccessKeyId, SecretAccessKey, SessionToken]" | ||
$sts | ||
aws configure set aws_access_key_id (${sts}[1] -replace " " -replace "`"" -replace ",") | ||
aws configure set aws_secret_access_key (${sts}[2] -replace " " -replace "`"" -replace ",") | ||
aws configure set aws_session_token (${sts}[3] -replace " " -replace "`"" -replace ",") | ||
aws configure list | ||
# Run tests | ||
cd "${PREFIX_DIR}/sample_install/bin" | ||
app |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.