Skip to content

Commit bb96468

Browse files
wps132230Pushen Wang
authored and
Pushen Wang
committed
Introduce new dependency: aws-crt-cpp
Using git submodule as a new approach to consume AWS common runtime libraries. aws-crt-cpp (https://github.com/awslabs/aws-crt-cpp) is C++ wrapper around the aws-c-* libraries, which includes aws-c-event-stream, aws-c-auth, aws-c-http and so on.
1 parent f1c34bd commit bb96468

20 files changed

+124
-342
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "aws-common-runtime/aws-crt-cpp"]
2+
path = crt/aws-crt-cpp
3+
url = https://github.com/awslabs/aws-crt-cpp.git

CI/install-test/CMakeLists.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@ set(CMAKE_CXX_STANDARD 11)
33
project(app LANGUAGES CXX)
44
find_package(AWSSDK REQUIRED COMPONENTS s3)
55
add_executable(${PROJECT_NAME} "main.cpp")
6+
if(MSVC AND BUILD_SHARED_LIBS)
7+
target_compile_definitions(${PROJECT_NAME} PUBLIC "USE_IMPORT_EXPORT")
8+
add_definitions(-DUSE_IMPORT_EXPORT)
9+
# Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging.
10+
list(APPEND SERVICE_LIST s3)
11+
AWSSDK_CPY_DYN_LIBS(SERVICE_LIST "" ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
12+
endif()
13+
set_compiler_flags(${PROJECT_NAME})
14+
set_compiler_warnings(${PROJECT_NAME})
615
target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES})
7-
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall" "-Werror")

CI/install-test/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
using namespace Aws;
77

8-
int main(int argc, char *argv[])
8+
int main()
99
{
1010
SDKOptions options;
1111
options.loggingOptions.logLevel = Utils::Logging::LogLevel::Warn;

CI/trebuchet-release-pipeline/buildspec_regenerate_code.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ phases:
44
build:
55
commands:
66
- echo $CODEBUILD_SOURCE_VERSION
7-
- git clone https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${GITHUB_PRIVATE_REPOSITORY}.git aws-sdk-cpp
7+
- git clone --recurse-submodules https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${GITHUB_PRIVATE_REPOSITORY}.git aws-sdk-cpp
88
- export RELEASE_ID=$(cat $RELEASE_ID_FILENAME)
99
- python3 aws-sdk-cpp/CI/trebuchet-release-pipeline/UpdateStatus.py -s RegenerateCode -i "$RELEASE_ID" -m "Step 1 of 4. Regenerating Code with New Models." -b $CODEBUILD_BUILD_SUCCEEDING
1010
- cp models/*.normal.json aws-sdk-cpp/code-generation/api-descriptions/

CMakeLists.txt

+43-96
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ endif()
1818
if(POLICY CMP0057)
1919
cmake_policy(SET CMP0057 NEW) # support IN_LIST
2020
endif()
21+
if (POLICY CMP0077)
22+
cmake_policy(SET CMP0077 OLD) # Enable options to get their values from normal variables
23+
endif()
2124

22-
23-
# 3.0 or higher is strongly suggested; build settings (target_compile_options/etc...) sometimes do not get propagated properly under certain conditions prior to this version
25+
# 3.12 or higher is strongly suggested; build settings (target_compile_options/etc...) sometimes do not get propagated properly under certain conditions prior to this version
2426
# Making this a hard requirement is potentially disruptive to existing customers who aren't affected by the bad behavior though, so just warn for now
25-
if(CMAKE_MAJOR_VERSION LESS 3)
26-
message(WARNING "Building with CMake 3.0 or higher is strongly suggested; current version is ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
27+
if(CMAKE_VERSION VERSION_LESS 3.12)
28+
message(WARNING "Building with CMake 3.12 or higher is strongly suggested; current version is ${CMAKE_VERSION}")
2729
endif()
2830

2931
get_filename_component(AWS_NATIVE_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
3032

31-
# git is required for Android builds and building third-party dependencies
32-
find_package(Git)
33-
3433
# Cmake invocation variables:
3534
# CUSTOM_MEMORY_MANAGEMENT - if set to ON, generates the sdk project files with custom memory management enabled, otherwise disables it
3635
# BUILD_ONLY - only build project identified by this variable, a semi-colon delimited list, if this is set we will build only the projects listed. Core will always be built as will its unit tests.
@@ -71,10 +70,7 @@ option(ENABLE_VIRTUAL_OPERATIONS "This option usually works with REGENERATE_CLIE
7170

7271
set(BUILD_ONLY "" CACHE STRING "A semi-colon delimited list of the projects to build")
7372
set(CPP_STANDARD "11" CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.")
74-
75-
if(NOT CMAKE_BUILD_TYPE)
76-
set(CMAKE_BUILD_TYPE Release)
77-
endif()
73+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Release build by default.")
7874

7975
#From https://stackoverflow.com/questions/18968979/how-to-get-colorized-output-with-cmake
8076
if(NOT WIN32)
@@ -109,10 +105,27 @@ endif()
109105

110106
set(PYTHON_CMD "python")
111107

108+
if (UNIX AND NOT APPLE)
109+
include(GNUInstallDirs)
110+
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
111+
set(CMAKE_INSTALL_LIBDIR "lib")
112+
endif()
113+
114+
if (DEFINED CMAKE_PREFIX_PATH)
115+
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
116+
endif()
117+
118+
if (DEFINED CMAKE_INSTALL_PREFIX)
119+
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
120+
endif()
121+
112122
# CMAKE_MODULE_PATH is a CMAKE variable. It contains a list of paths
113123
# which could be used to search CMAKE modules by "include()" or "find_package()", but the default value is empty.
114-
# Add cmake dir to search list
124+
# Add ${CMAKE_INSTALL_LIBDIR}/cmake and ${CMAKE_PREFIX_PATH}/lib/cmake to search list
115125
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
126+
set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
127+
string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
128+
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})
116129

117130
# include() will "load and run" cmake script
118131
include(resolve_platform)
@@ -144,90 +157,6 @@ endif()
144157
# Add Linker search paths to RPATH so as to fix the problem where some linkers can't find cross-compiled dependent libraries in customer paths when linking executables.
145158
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)
146159

147-
# build third-party targets
148-
if (BUILD_DEPS)
149-
# If building third party dependencies, we will move them to the same directory where SDK has been installed during installation.
150-
# Therefore, we should set rpath to $ORIGIN to let SDK find these third party dependencies.
151-
# Otherwise, customers are responsible for handling the linkage to these libraries.
152-
set(CMAKE_INSTALL_RPATH "$ORIGIN")
153-
set(AWS_DEPS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/.deps)
154-
if (NOT DEFINED AWS_DEPS_INSTALL_DIR)
155-
if (DEFINED CMAKE_INSTALL_PREFIX)
156-
set(AWS_DEPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE STRING "A string describes the path where 3rd-party dependencies will be or have been installed")
157-
else()
158-
set(AWS_DEPS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/.deps/install CACHE STRING "A string describes the path where 3rd-party dependencies will be or have been installed")
159-
endif()
160-
endif()
161-
if (NOT CMAKE_GENERATOR_PLATFORM STREQUAL "")
162-
set(GEN_PLATFORM_ARG "-A${CMAKE_GENERATOR_PLATFORM}")
163-
endif()
164-
file(MAKE_DIRECTORY ${AWS_DEPS_BUILD_DIR})
165-
if(TARGET_ARCH STREQUAL "ANDROID")
166-
execute_process(
167-
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
168-
-DTARGET_ARCH=${TARGET_ARCH}
169-
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
170-
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}
171-
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}
172-
-DANDROID_ABI=${ANDROID_ABI}
173-
-DANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN}
174-
-DANDROID_STL=${ANDROID_STL}
175-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
176-
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
177-
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
178-
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
179-
${GEN_PLATFORM_ARG}
180-
${CMAKE_CURRENT_SOURCE_DIR}/third-party
181-
WORKING_DIRECTORY ${AWS_DEPS_BUILD_DIR}
182-
RESULT_VARIABLE BUILD_3P_EXIT_CODE)
183-
elseif(TARGET_ARCH STREQUAL "APPLE" AND DEFINED CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
184-
message("Cross compiling third-party dependencies for architecture ${CMAKE_OSX_ARCHITECTURES}")
185-
execute_process(
186-
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
187-
-DTARGET_ARCH=${TARGET_ARCH}
188-
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
189-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
190-
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
191-
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
192-
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
193-
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
194-
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
195-
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
196-
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}/bin
197-
${GEN_PLATFORM_ARG}
198-
${CMAKE_CURRENT_SOURCE_DIR}/third-party
199-
WORKING_DIRECTORY ${AWS_DEPS_BUILD_DIR}
200-
RESULT_VARIABLE BUILD_3P_EXIT_CODE)
201-
else()
202-
execute_process(
203-
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
204-
-DTARGET_ARCH=${TARGET_ARCH}
205-
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
206-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
207-
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
208-
-DSTATIC_CRT=${STATIC_CRT}
209-
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
210-
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}/bin
211-
${GEN_PLATFORM_ARG}
212-
${CMAKE_CURRENT_SOURCE_DIR}/third-party
213-
WORKING_DIRECTORY ${AWS_DEPS_BUILD_DIR}
214-
RESULT_VARIABLE BUILD_3P_EXIT_CODE)
215-
endif()
216-
217-
if (NOT ${BUILD_3P_EXIT_CODE} EQUAL 0)
218-
message(FATAL_ERROR "Failed to configure third-party libraries.")
219-
endif()
220-
execute_process(COMMAND ${CMAKE_COMMAND} --build ${AWS_DEPS_BUILD_DIR} --config ${CMAKE_BUILD_TYPE}
221-
RESULT_VARIABLE BUILD_3P_EXIT_CODE)
222-
223-
if (NOT ${BUILD_3P_EXIT_CODE} EQUAL 0)
224-
message(FATAL_ERROR "Failed to build third-party libraries.")
225-
endif()
226-
message(STATUS "Third-party dependencies are installed at: ${AWS_DEPS_INSTALL_DIR}")
227-
list(APPEND CMAKE_PREFIX_PATH "${AWS_DEPS_INSTALL_DIR}")
228-
endif()
229-
set(THIRD_PARTY_LIBS "aws-c-event-stream;aws-checksums;aws-c-common")
230-
231160
# build the sdk targets
232161
project("aws-cpp-sdk-all" VERSION "${PROJECT_VERSION}" LANGUAGES CXX)
233162

@@ -246,6 +175,24 @@ set(CMAKE_CONFIGURATION_TYPES
246175
MinSizeRel # Like Release, but optimized for memory rather than speed.
247176
)
248177

178+
# build third-party targets
179+
if (BUILD_DEPS)
180+
set(CMAKE_INSTALL_RPATH "$ORIGIN")
181+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/crt/aws-crt-cpp/crt/aws-c-common/cmake")
182+
183+
include(AwsFindPackage)
184+
185+
set(IN_SOURCE_BUILD ON)
186+
set(BUILD_TESTING_PREV ${BUILD_TESTING})
187+
set(BUILD_TESTING OFF)
188+
add_subdirectory(crt/aws-crt-cpp)
189+
set(BUILD_TESTING ${BUILD_TESTING_PREV})
190+
else()
191+
include(AwsFindPackage)
192+
set(IN_SOURCE_BUILD OFF)
193+
endif()
194+
set(AWS_COMMON_RUNTIME_LIBS "aws-crt-cpp;aws-c-auth;aws-c-cal;aws-c-common;aws-c-compression;aws-c-event-stream;aws-c-http;aws-c-io;aws-c-mqtt;aws-c-s3;aws-checksums")
195+
249196
include(compiler_settings)
250197
# Instead of calling functions/macros inside included cmake scripts, we should call them in our main CMakeList.txt
251198
set_msvc_flags()

aws-cpp-sdk-core/CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,9 @@ endif()
493493

494494
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_DEP_LIBS} ${CLIENT_LIBS} ${CRYPTO_LIBS} ${AWS_SDK_ADDITIONAL_LIBRARIES})
495495

496-
find_package(aws-c-event-stream REQUIRED)
497-
498-
target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-c-event-stream)
496+
aws_use_package(aws-crt-cpp)
499497

498+
target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS})
500499

501500
if(USE_WINDOWS_DLL_SEMANTICS)
502501
target_compile_definitions(${PROJECT_NAME} PUBLIC "USE_WINDOWS_DLL_SEMANTICS")
@@ -530,7 +529,7 @@ endif()
530529

531530
if(SIMPLE_INSTALL)
532531
# These libs are needed by aws-cpp-sdk-core only.
533-
set(ALL_DEP_LIBS ${THIRD_PARTY_LIBS} ${PLATFORM_DEP_LIBS_ABSTRACT_NAME} ${CLIENT_LIBS_ABSTRACT_NAME} ${CRYPTO_LIBS_ABSTRACT_NAME})
532+
set(ALL_DEP_LIBS ${AWS_COMMON_RUNTIME_LIBS} ${PLATFORM_DEP_LIBS_ABSTRACT_NAME} ${CLIENT_LIBS_ABSTRACT_NAME} ${CRYPTO_LIBS_ABSTRACT_NAME})
534533
generate_pkgconfig_link_flags(ALL_DEP_LIBS ALL_DEP_LIBS_LINK_FLAGS)
535534
set(ALL_DEP_LIBS_LINK_FLAGS "${ALL_DEP_LIBS_LINK_FLAGS}")
536535
configure_file("${AWS_NATIVE_SDK_ROOT}/toolchains/pkg-config.pc.in" "${PROJECT_NAME}.pc" @ONLY)

aws-cpp-sdk-core/source/Globals.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,40 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
5+
6+
#include <aws/crt/Api.h>
57
#include <aws/core/Globals.h>
68
#include <aws/core/utils/EnumParseOverflowContainer.h>
79
#include <aws/core/utils/memory/AWSMemory.h>
10+
#include <aws/auth/auth.h>
811

912
namespace Aws
1013
{
1114
static const char TAG[] = "GlobalEnumOverflowContainer";
15+
16+
static Aws::Crt::ApiHandle* g_apiHandle;
17+
18+
Aws::Crt::ApiHandle* GetApiHandle()
19+
{
20+
return g_apiHandle;
21+
}
22+
23+
void InitializeCrt()
24+
{
25+
g_apiHandle = Aws::New<Aws::Crt::ApiHandle>(TAG, Aws::get_aws_allocator());
26+
}
27+
28+
void CleanupCrt()
29+
{
30+
aws_global_thread_creator_shutdown_wait_for(5);
31+
Aws::Crt::g_allocator = nullptr;
32+
aws_auth_library_clean_up();
33+
aws_mqtt_library_clean_up();
34+
aws_http_library_clean_up();
35+
36+
Aws::Delete(g_apiHandle);
37+
}
38+
1239
static Utils::EnumParseOverflowContainer* g_enumOverflow;
1340

1441
Utils::EnumParseOverflowContainer* GetEnumOverflowContainer()

cmake/AWSSDKConfig.cmake

+17-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ if (NOT AWSSDK_INSTALL_INCLUDEDIR)
4141
set(AWSSDK_INSTALL_INCLUDEDIR "include")
4242
endif()
4343

44+
if (DEFINED CMAKE_PREFIX_PATH)
45+
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
46+
endif()
47+
48+
if (DEFINED CMAKE_INSTALL_PREFIX)
49+
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
50+
endif()
51+
52+
set(AWS_MODULE_DIR "/${AWSSDK_INSTALL_LIBDIR}/cmake")
53+
string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
54+
string(REPLACE ";" "${AWS_MODULE_DIR};" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}${AWS_MODULE_DIR}")
55+
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH} ${SYSTEM_MODULE_PATH})
56+
4457
# On Windows, dlls are treated as runtime target and installed in bindir
4558
if (WIN32 AND AWSSDK_INSTALL_AS_SHARED_LIBS)
4659
set(AWSSDK_INSTALL_LIBDIR "${AWSSDK_INSTALL_BINDIR}")
@@ -153,7 +166,7 @@ message(STATUS "Found AWS SDK for C++, Version: ${PACKAGE_VERSION}, Install Root
153166
# copy libs of services in SERVICE_LIST and all there dependent libs to DEST_DIR
154167
# CONFIG denote copy release or debug version
155168
macro(AWSSDK_CPY_DYN_LIBS SERVICE_LIST CONFIG DEST_DIR)
156-
set(ALL_SERVICES "core" ${AWSSDK_THIRD_PARTY_LIBS})
169+
set(ALL_SERVICES "core" ${AWSSDK_COMMON_RUNTIME_LIBS})
157170

158171
foreach(SVC IN LISTS ${SERVICE_LIST})
159172
list(APPEND ALL_SERVICES ${SVC})
@@ -251,7 +264,7 @@ macro(AWSSDK_DETERMINE_LIBS_TO_LINK SERVICE_LIST OUTPUT_VAR)
251264
list(APPEND ${OUTPUT_VAR} "aws-cpp-sdk-${DEP}")
252265
endforeach()
253266
if (NOT AWSSDK_INSTALL_AS_SHARED_LIBS)
254-
list(APPEND ${OUTPUT_VAR} ${AWSSDK_THIRD_PARTY_LIBS} ${AWSSDK_PLATFORM_DEPS})
267+
list(APPEND ${OUTPUT_VAR} ${AWSSDK_COMMON_RUNTIME_LIBS} ${AWSSDK_PLATFORM_DEPS})
255268
endif()
256269
endmacro(AWSSDK_DETERMINE_LIBS_TO_LINK)
257270

@@ -282,8 +295,8 @@ if (AWSSDK_FIND_COMPONENTS)
282295

283296
# platform dependencies will be resolved automatically when doing find_package(aws-cpp-sdk-core).
284297
list(REMOVE_ITEM AWSSDK_LINK_LIBRARIES ${AWSSDK_PLATFORM_DEPS})
285-
# third_party dependencies will be resolved automatically when doing find_package(aws-cpp-sdk-core) as well.
286-
list(REMOVE_ITEM AWSSDK_LINK_LIBRARIES ${AWSSDK_THIRD_PARTY_LIBS})
298+
# AWS common runtime dependencies will be resolved automatically when doing find_package(aws-cpp-sdk-core) as well.
299+
list(REMOVE_ITEM AWSSDK_LINK_LIBRARIES ${AWSSDK_COMMON_RUNTIME_LIBS})
287300

288301
set(AWSSDK_TARGETS ${AWSSDK_LINK_LIBRARIES})
289302
list(REVERSE AWSSDK_TARGETS)

cmake/compiler_settings.cmake

-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ endmacro()
7171

7272
macro(set_msvc_flags)
7373
if(MSVC)
74-
# Put all runtime outputs, including DLLs, executables into one directory, so as to avoid copying DLLs.
75-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
76-
7774
# Based on the FORCE_SHARED_CRT and BUILD_SHARED_LIBS options, make sure our compile/link flags bring in the right CRT library
7875
# modified from gtest's version; while only the else clause is actually necessary, do both for completeness/future-proofing
7976
foreach (var

cmake/platform/android.cmake

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11

22
macro(verify_tools)
33
# TODO: don't do this if the user is supplying their own curl/openssl/zlib
4-
# minimum version of cmake that
4+
# minimum version of cmake that
55
# (1) supports ExternalProject_Add URL_HASH
66
# (2) correctly extracts OPENSSL's version number from openssl/opensslv.h in version 1.0.2d
77
cmake_minimum_required (VERSION 3.1.2)
88

99
# TODO: don't do this if the user is supplying their own curl/openssl/zlib
1010
if(NOT GIT_FOUND)
11+
find_package(Git)
1112
message(FATAL_ERROR "Unable to find git; git is required in order to build for Android")
1213
endif()
1314
endmacro()
@@ -40,7 +41,7 @@ macro(determine_stdlib_and_api)
4041

4142
# With gnustl, API level can go as low as 3, but let's make a reasonably modern default
4243
if(NOT ANDROID_NATIVE_API_LEVEL)
43-
set(ANDROID_NATIVE_API_LEVEL "android-19")
44+
set(ANDROID_NATIVE_API_LEVEL "android-19")
4445
endif()
4546

4647
else()
@@ -102,10 +103,6 @@ macro(apply_pre_project_platform_settings)
102103
endmacro()
103104

104105
macro(apply_post_project_platform_settings)
105-
# CMAKE_FIND_ROOT_PATH_MODE_PACKAGE is set to ONLY by default, which means find_package will only search packages under ${ANDROID_NDK} (which is defined by built-in cmake toolchain file.)
106-
# In Android NDK before and including 15c, we are not able to change CMAKE_FIND_ROOT_PATH_MODE_PACKAGE, we'd add AWS_DEPS_INSTALL_DIR to the search paths.
107-
list(APPEND CMAKE_FIND_ROOT_PATH "${AWS_DEPS_INSTALL_DIR}")
108-
109106
set(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/${ANDROID_ABI}-api-${ANDROID_NATIVE_API_LEVEL}")
110107

111108
set(PLATFORM_DEP_LIBS log atomic)

cmake/platform/windows.cmake

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ else()
1010
endif()
1111

1212
macro(apply_post_project_platform_settings)
13+
if(MSVC)
14+
# Put all runtime outputs, including DLLs, executables into one directory, so as to avoid copying DLLs.
15+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
16+
endif()
1317
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
1418
set(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/intel64")
1519
else()
1620
set(SDK_INSTALL_BINARY_PREFIX "${SDK_INSTALL_BINARY_PREFIX}/ia32")
17-
endif()
18-
19-
set(PLATFORM_DEP_LIBS Userenv version ws2_32)
21+
endif()
22+
23+
set(PLATFORM_DEP_LIBS Userenv version ws2_32)
2024
set(PLATFORM_DEP_LIBS_ABSTRACT_NAME Userenv version ws2_32)
2125

2226
endmacro()

0 commit comments

Comments
 (0)