Skip to content

Commit 6e46eb4

Browse files
authored
Add 'aws-sdk-cpp' package (#474)
1 parent fdfcfcb commit 6e46eb4

File tree

6 files changed

+337
-0
lines changed

6 files changed

+337
-0
lines changed

cmake/configs/default.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ hunter_default_version(astc-encoder VERSION 3.0-7257cbd-p0)
200200
hunter_default_version(autobahn-cpp VERSION 0.2.0)
201201
hunter_default_version(autoutils VERSION 0.3.0)
202202
hunter_default_version(aws-c-common VERSION 0.5.6)
203+
hunter_default_version(aws-sdk-cpp VERSION 1.9.107)
203204
hunter_default_version(aws_lambda_cpp VERSION v0.2.7-p0)
204205
hunter_default_version(basis_universal VERSION 1.15-c4c0db7-p0)
205206
hunter_default_version(benchmark VERSION 1.5.0)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov
2+
# All rights reserved.
3+
4+
# !!! DO NOT PLACE HEADER GUARDS HERE !!!
5+
6+
include(hunter_add_version)
7+
include(hunter_cacheable)
8+
include(hunter_cmake_args)
9+
include(hunter_download)
10+
include(hunter_pick_scheme)
11+
12+
hunter_add_version(
13+
PACKAGE_NAME
14+
aws-sdk-cpp
15+
VERSION
16+
1.9.107
17+
URL
18+
"https://github.com/cpp-pm/aws-sdk-cpp.git"
19+
SHA1
20+
d0d1ad5cfa2130af33638ae42da022ce6d30c709
21+
)
22+
23+
hunter_cmake_args(
24+
aws-sdk-cpp
25+
CMAKE_ARGS
26+
ENABLE_TESTING=OFF
27+
AUTORUN_UNIT_TESTS=OFF
28+
BUILD_ONLY=s3
29+
HAS_MOUTLINE_ATOMICS=OFF # Avoid build error with -Werror on Intel
30+
)
31+
32+
hunter_pick_scheme(DEFAULT git_tag_cmake)
33+
hunter_cacheable(aws-sdk-cpp)
34+
hunter_download(PACKAGE_NAME aws-sdk-cpp)
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Copyright (c) 2015, Ruslan Baratov
2+
# All rights reserved.
3+
4+
cmake_minimum_required(VERSION 3.0)
5+
project(Hunter)
6+
7+
include(ExternalProject) # ExternalProject_Add
8+
9+
# Scheme for CMake projects
10+
11+
# This is universal CMake scheme that will work for
12+
# * single-configuration (`* Makefiles`)
13+
# * cmake -DCMAKE_BUILD_TYPE=${configuration}
14+
# * multi-configuration (Visual Studio, Xcode)
15+
# * cmake -DCMAKE_CONFIGURATION_TYPES=...
16+
# * cmake --build --config ${configuration}
17+
18+
list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules")
19+
20+
include(hunter_status_debug)
21+
include(hunter_assert_not_empty_string)
22+
include(hunter_user_error)
23+
24+
hunter_status_debug("Scheme: url_sha1_cmake")
25+
26+
# Check preconditions
27+
hunter_assert_not_empty_string("@HUNTER_SELF@")
28+
hunter_assert_not_empty_string("@HUNTER_EP_NAME@")
29+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@")
30+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@")
31+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@")
32+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@")
33+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@")
34+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_CONFIGURATION_TYPES@")
35+
hunter_assert_not_empty_string("@HUNTER_CACHE_FILE@")
36+
hunter_assert_not_empty_string("@HUNTER_ARGS_FILE@")
37+
hunter_assert_not_empty_string("@HUNTER_PACKAGE_LICENSE_DIR@")
38+
hunter_assert_not_empty_string("@CMAKE_GENERATOR@")
39+
hunter_assert_not_empty_string("${CMAKE_TOOLCHAIN_FILE}")
40+
hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@")
41+
42+
if(IOS)
43+
if(CMAKE_VERSION VERSION_LESS 3.5)
44+
hunter_user_error("CMake 3.5+ version should be used for iOS toolchains")
45+
endif()
46+
string(COMPARE NOTEQUAL "${IPHONESIMULATOR_ARCHS}" "" has_simulator)
47+
set(ios_opts "-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO")
48+
if(has_simulator)
49+
list(APPEND ios_opts "-DCMAKE_IOS_INSTALL_COMBINED=YES")
50+
endif()
51+
else()
52+
set(ios_opts "")
53+
endif()
54+
55+
# https://cmake.org/cmake/help/v3.4/release/3.4.html#modules
56+
# https://cmake.org/cmake/help/v3.4/module/ExternalProject.html
57+
if(CMAKE_VERSION VERSION_LESS 3.4)
58+
set(uses_terminal "")
59+
else()
60+
set(
61+
uses_terminal
62+
USES_TERMINAL_DOWNLOAD 1
63+
USES_TERMINAL_UPDATE 1
64+
USES_TERMINAL_CONFIGURE 1
65+
USES_TERMINAL_BUILD 1
66+
USES_TERMINAL_TEST 1
67+
USES_TERMINAL_INSTALL 1
68+
)
69+
endif()
70+
71+
string(COMPARE NOTEQUAL "@HUNTER_JOBS_OPTION@" "" have_jobs)
72+
if(have_jobs)
73+
string(COMPARE NOTEQUAL "@XCODE_VERSION@" "" is_xcode)
74+
if(is_xcode)
75+
set(jobs_option "-jobs" "@HUNTER_JOBS_OPTION@")
76+
elseif("@MSVC_IDE@")
77+
set(jobs_option "/maxcpucount:@HUNTER_JOBS_OPTION@")
78+
else()
79+
set(jobs_option "-j@HUNTER_JOBS_OPTION@")
80+
endif()
81+
else()
82+
set(jobs_option "")
83+
endif()
84+
85+
set(previous_project "")
86+
87+
if("@HUNTER_PACKAGE_LOG_BUILD@")
88+
set(log_build 1)
89+
else()
90+
set(log_build 0)
91+
endif()
92+
93+
if("@HUNTER_PACKAGE_LOG_INSTALL@" OR "@HUNTER_SUPPRESS_LIST_OF_FILES@")
94+
set(log_install 1)
95+
else()
96+
set(log_install 0)
97+
endif()
98+
99+
string(COMPARE EQUAL "@HUNTER_PACKAGE_PROTECTED_SOURCES@" "" is_empty)
100+
if(is_empty)
101+
set(http_credentials "")
102+
else()
103+
set(
104+
http_credentials
105+
HTTP_USERNAME "@HUNTER_PACKAGE_HTTP_USERNAME@"
106+
HTTP_PASSWORD "@HUNTER_PACKAGE_HTTP_PASSWORD@"
107+
)
108+
endif()
109+
110+
string(COMPARE NOTEQUAL "${CMAKE_MAKE_PROGRAM}" "" has_make)
111+
if(has_make)
112+
set(make_args "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
113+
else()
114+
set(make_args "")
115+
endif()
116+
117+
string(COMPARE EQUAL "${CMAKE_CFG_INTDIR}" "." is_single)
118+
119+
set(configuration_types "@HUNTER_PACKAGE_CONFIGURATION_TYPES@")
120+
list(LENGTH configuration_types len)
121+
if(len EQUAL "1")
122+
set(no_postfix TRUE)
123+
else()
124+
set(no_postfix FALSE)
125+
endif()
126+
127+
foreach(configuration ${configuration_types})
128+
# All configurations use the same URL which will be downloaded only once
129+
# i.e. overhead only for unpacking archive + no files from the previous
130+
# build will be left in case package do some insource modification (wrongly)
131+
string(TOUPPER "${configuration}" configuration_upper)
132+
string(COMPARE EQUAL "${configuration_upper}" "RELEASE" is_release)
133+
set(postfix_name "CMAKE_${configuration_upper}_POSTFIX")
134+
string(COMPARE EQUAL "${${postfix_name}}" "" is_empty)
135+
136+
if(NOT is_release AND is_empty)
137+
set("${postfix_name}" "-${configuration}")
138+
endif()
139+
140+
if(no_postfix)
141+
set("${postfix_name}" "")
142+
endif()
143+
144+
set(current_project "@HUNTER_EP_NAME@-${configuration}")
145+
146+
if(is_single)
147+
set(build_type_opts "-DCMAKE_BUILD_TYPE=${configuration}")
148+
else()
149+
set(build_type_opts "-DCMAKE_CONFIGURATION_TYPES=${configuration}")
150+
endif()
151+
152+
ExternalProject_Add(
153+
"${current_project}"
154+
GIT_REPOSITORY
155+
@HUNTER_PACKAGE_URL@
156+
GIT_TAG
157+
@HUNTER_PACKAGE_SHA1@
158+
GIT_SHALLOW
159+
${http_credentials}
160+
DOWNLOAD_DIR
161+
"@HUNTER_PACKAGE_DOWNLOAD_DIR@"
162+
TLS_VERIFY
163+
"@HUNTER_TLS_VERIFY@"
164+
SOURCE_DIR
165+
"@HUNTER_PACKAGE_SOURCE_DIR@"
166+
INSTALL_DIR
167+
"@HUNTER_PACKAGE_INSTALL_PREFIX@"
168+
# not used, just avoid creating Install/<name> empty directory
169+
SOURCE_SUBDIR
170+
"@HUNTER_PACKAGE_SOURCE_SUBDIR@"
171+
BUILD_COMMAND
172+
# Separate build and install stage so we can suppress install log
173+
# which may consist of a long list of files
174+
"@CMAKE_COMMAND@"
175+
--build .
176+
--config ${configuration}
177+
--
178+
${jobs_option}
179+
CMAKE_ARGS
180+
"-G@CMAKE_GENERATOR@"
181+
"-C@HUNTER_CACHE_FILE@"
182+
"-C@HUNTER_ARGS_FILE@"
183+
"-D${postfix_name}=${${postfix_name}}"
184+
"${build_type_opts}"
185+
"-DCMAKE_INSTALL_PREFIX=@HUNTER_PACKAGE_INSTALL_PREFIX@"
186+
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
187+
"${make_args}"
188+
${ios_opts}
189+
INSTALL_COMMAND
190+
"@CMAKE_COMMAND@"
191+
--build .
192+
--target install
193+
--config ${configuration}
194+
COMMAND # Copy license files
195+
"@CMAKE_COMMAND@"
196+
"-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES'
197+
"-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@"
198+
"-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@"
199+
-P
200+
"@HUNTER_SELF@/scripts/try-copy-license.cmake"
201+
LOG_BUILD ${log_build}
202+
LOG_INSTALL ${log_install}
203+
${uses_terminal}
204+
)
205+
206+
# Each external project must depends on previous one since they all use
207+
# the same building directory
208+
string(COMPARE EQUAL "${previous_project}" "" is_empty)
209+
if(NOT is_empty)
210+
add_dependencies(
211+
"${current_project}"
212+
"${previous_project}"
213+
)
214+
endif()
215+
set(previous_project "${current_project}")
216+
endforeach()

docs/packages/pkg/aws-sdk-cpp.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. spelling::
2+
3+
aws
4+
sdk
5+
cpp
6+
aws-sdk-cpp
7+
8+
.. index::
9+
single: unsorted ; aws-sdk-cpp
10+
11+
.. _pkg.aws-sdk-cpp:
12+
13+
aws-sdk-cpp
14+
===========
15+
16+
- `Official <https://github.com/aws/aws-sdk-cpp>`__
17+
- `Hunterized <https://github.com/cpp-pm/aws-sdk-cpp>`__
18+
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/aws-sdk-cpp/CMakeLists.txt>`__
19+
- Added by `Harry Mallon <https://github.com/hjmallon>`__ (`pr-474 <https://github.com/cpp-pm/hunter/pull/474>`__)
20+
21+
.. literalinclude:: /../examples/aws-sdk-cpp/CMakeLists.txt
22+
:language: cmake
23+
:start-after: # DOCUMENTATION_START {
24+
:end-before: # DOCUMENTATION_END }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov
2+
# All rights reserved.
3+
4+
cmake_minimum_required(VERSION 3.2)
5+
6+
# Emulate HunterGate:
7+
# * https://github.com/hunter-packages/gate
8+
include("../common.cmake")
9+
10+
project(download-aws-sdk-cpp)
11+
12+
# DOCUMENTATION_START {
13+
# You need to set which parts of the SDK you want to build (default is s3)
14+
#
15+
# hunter_config(aws-sdk-cpp
16+
# VERSION 1.9.94
17+
# CMAKE_ARGS
18+
# BUILD_ONLY=s3
19+
# )
20+
#
21+
22+
hunter_add_package(aws-sdk-cpp)
23+
find_package(AWSSDK REQUIRED COMPONENTS s3)
24+
25+
if (NOT WIN32)
26+
find_package(CURL CONFIG REQUIRED)
27+
endif()
28+
29+
add_executable(boo boo.cpp)
30+
message("${AWSSDK_LINK_LIBRARIES}")
31+
target_link_libraries(boo PUBLIC ${AWSSDK_LINK_LIBRARIES})
32+
# DOCUMENTATION_END }

examples/aws-sdk-cpp/boo.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <aws/core/Aws.h>
2+
#include <aws/core/utils/logging/LogLevel.h>
3+
#include <aws/s3/S3Client.h>
4+
#include <iostream>
5+
6+
using namespace Aws;
7+
8+
int main() {
9+
SDKOptions options;
10+
options.loggingOptions.logLevel = Utils::Logging::LogLevel::Debug;
11+
12+
InitAPI(options);
13+
{
14+
S3::S3Client client;
15+
16+
auto outcome = client.ListBuckets();
17+
if (outcome.IsSuccess()) {
18+
std::cout << "Found " << outcome.GetResult().GetBuckets().size() << " buckets\n";
19+
for (auto&& b : outcome.GetResult().GetBuckets()) {
20+
std::cout << b.GetName() << std::endl;
21+
}
22+
}
23+
else {
24+
std::cout << "Failed with error: " << outcome.GetError() << std::endl;
25+
}
26+
}
27+
28+
ShutdownAPI(options);
29+
return 0;
30+
}

0 commit comments

Comments
 (0)