-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
70 lines (49 loc) · 2.05 KB
/
Copy pathCMakeLists.txt
File metadata and controls
70 lines (49 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# Set the minimum required version of CMake for this project.
cmake_minimum_required(VERSION 3.13)
set(SERVICE_NAME lambda)
set(SERVICE_COMPONENTS lambda iam)
# Set this project's name.
project("${SERVICE_NAME}-examples")
# 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)
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})
endif ()
# Set the C++ standard to use to build this target.
set(CMAKE_CXX_STANDARD 11)
# Build shared libraries by default.
set(BUILD_SHARED_LIBS ON)
# Find the AWS SDK for C++ package.
find_package(AWSSDK REQUIRED COMPONENTS ${SERVICE_COMPONENTS})
if (WINDOWS_BUILD AND AWSSDK_INSTALL_AS_SHARED_LIBS)
# Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging.
# 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.
AWSSDK_CPY_DYN_LIBS(SERVICE_COMPONENTS "" ${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR})
endif ()
# 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}"
)
endforeach()
if(BUILD_TESTS)
add_subdirectory(tests)
endif()