2022-12-08 15:49:42 -05:00
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
2021-11-15 13:15:43 +00:00
2022-12-08 15:49:42 -05:00
# Set the minimum required version of CMake for this project.
2023-08-16 13:33:20 -04:00
cmake_minimum_required ( VERSION 3.13 )
2021-11-15 13:15:43 +00:00
2022-12-08 15:49:42 -05:00
set ( SERVICE_NAME lambda )
set ( SERVICE_COMPONENTS lambda iam )
2021-11-15 13:15:43 +00:00
2022-12-08 15:49:42 -05:00
# Set this project's name.
project ( "${SERVICE_NAME}-examples" )
2021-11-15 13:15:43 +00:00
2024-05-03 14:53:34 -04:00
# Use the MSVC variable to determine if this is a Windows build.
set ( WINDOWS_BUILD ${ MSVC } )
# Set the location for Windows to find the installed libraries of the SDK.
if ( WINDOWS_BUILD )
2022-12-08 15:49:42 -05:00
string ( REPLACE ";" "/aws-cpp-sdk-all;" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}/aws-cpp-sdk-all" )
list ( APPEND CMAKE_PREFIX_PATH ${ SYSTEM_MODULE_PATH } )
2024-05-03 14:53:34 -04:00
endif ( )
2021-11-15 13:15:43 +00:00
2022-12-08 15:49:42 -05:00
# Set the C++ standard to use to build this target.
set ( CMAKE_CXX_STANDARD 11 )
2021-11-15 13:15:43 +00:00
2022-12-08 15:49:42 -05:00
# Build shared libraries by default.
2024-05-03 14:53:34 -04:00
set ( BUILD_SHARED_LIBS ON )
2022-12-08 15:49:42 -05:00
# Find the AWS SDK for C++ package.
find_package ( AWSSDK REQUIRED COMPONENTS ${ SERVICE_COMPONENTS } )
2024-05-03 14:53:34 -04:00
if ( WINDOWS_BUILD AND AWSSDK_INSTALL_AS_SHARED_LIBS )
2022-12-08 15:49:42 -05:00
# Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging.
2024-05-03 14:53:34 -04:00
# set(BIN_SUB_DIR "/Debug") # If you are building from the command line, you may need to uncomment this
# and set the proper subdirectory to the executables' location.
2022-12-08 15:49:42 -05:00
2024-05-03 14:53:34 -04:00
AWSSDK_CPY_DYN_LIBS ( SERVICE_COMPONENTS "" ${ CMAKE_CURRENT_BINARY_DIR } ${ BIN_SUB_DIR } )
endif ( )
2022-12-08 15:49:42 -05:00
# AWSDOC_SOURCE can be defined in the command line to limit the files in a build. For example,
# you can limit files to one action.
if ( NOT DEFINED AWSDOC_SOURCE )
file ( GLOB AWSDOC_SOURCE
"*.cpp"
)
endif ( )
foreach ( file ${ AWSDOC_SOURCE } )
get_filename_component ( EXAMPLE ${ file } NAME_WE )
# Build the code example executables.
set ( EXAMPLE_EXE run_ ${ EXAMPLE } )
add_executable ( ${ EXAMPLE_EXE } ${ file } )
target_link_libraries ( ${ EXAMPLE_EXE } ${ AWSSDK_LINK_LIBRARIES }
${ AWSSDK_PLATFORM_DEPS } )
target_compile_definitions ( ${ EXAMPLE_EXE }
PRIVATE
SOURCE_DIR= "${CMAKE_CURRENT_SOURCE_DIR}"
)
2021-11-15 13:15:43 +00:00
endforeach ( )
2022-12-08 15:49:42 -05:00
if ( BUILD_TESTS )
add_subdirectory ( tests )
endif ( )