Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix ANDROID_BUILD_OPENSSL cmake option #3023

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if (LEGACY_BUILD)
option(ENABLE_TESTING "Flag to enable/disable building unit and integration tests" ON)
option(AUTORUN_UNIT_TESTS "Flag to enable/disable automatically run unit tests after building" ON)
option(ANDROID_BUILD_CURL "When building for Android, should curl be built as well" ON)
option(ANDROID_BUILD_OPENSSL "When building for Android, should Openssl be built as well" ON)
option(ANDROID_BUILD_ZLIB "When building for Android, should Zlib be built as well" ON)
option(FORCE_CURL "Forces usage of the Curl client rather than the default OS-specific api" OFF)
option(ENABLE_ADDRESS_SANITIZER "Flags to enable/disable Address Sanitizer for gcc or clang" OFF)
Expand Down Expand Up @@ -219,9 +220,17 @@ if (LEGACY_BUILD)
set(BUILD_TESTING_PREV ${BUILD_TESTING})
set(BUILD_TESTING OFF CACHE BOOL "Disable all tests in dependencies.")
# TODO: Use same BUILD_SHARED_LIBS for Aws Common Runtime dependencies.
# libcurl and aws-sdk-cpp-core may link to different libcrypto, which leads to some issues for shared build.
if (ENABLE_OPENSSL_ENCRYPTION)
set(BUILD_SHARED_LIBS_PREV ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif ()
set(CRT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
add_subdirectory(crt/aws-crt-cpp)
set(BUILD_TESTING ${BUILD_TESTING_PREV})
if (ENABLE_OPENSSL_ENCRYPTION)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_PREV})
endif ()
else ()
# This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
Expand Down Expand Up @@ -252,6 +261,11 @@ if (LEGACY_BUILD)

include(utilities)

if (ENABLE_OPENSSL_ENCRYPTION)
set(CRYPTO_LIBS ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
set(CRYPTO_LIBS_ABSTRACT_NAME crypto ssl z)
endif ()

if (ENABLE_CURL_CLIENT)
set(CLIENT_LIBS ${CURL_LIBRARIES})
set(CLIENT_LIBS_ABSTRACT_NAME curl)
Expand Down
8 changes: 8 additions & 0 deletions cmake/external_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ if(NO_ENCRYPTION)
set(ENABLE_INJECTED_ENCRYPTION ON)
message(STATUS "Encryption: None")
message(STATUS "You will need to inject an encryption implementation before making any http requests!")
elseif (PLATFORM_ANDROID AND ANDROID_BUILD_OPENSSL)
set(ENABLE_OPENSSL_ENCRYPTION ON)
set(BUILD_OPENSSL 1)
set(CRYPTO_TARGET_NAME "crypto")
set(USE_OPENSSL ON)
message(STATUS " Building Openssl as part of AWS SDK")
set(CRYPTO_LIBS ${CRYPTO_TARGET_NAME} ${ZLIB_LIBRARIES})
set(CRYPTO_LIBS_ABSTRACT_NAME ${CRYPTO_TARGET_NAME} ssl z)
endif()

# Http client control
Expand Down
4 changes: 4 additions & 0 deletions src/aws-cpp-sdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ if(BUILD_CURL)
target_include_directories(${PROJECT_NAME} PRIVATE "${CURL_INCLUDE_DIR}")
endif()

if(BUILD_OPENSSL)
target_include_directories(${PROJECT_NAME} PRIVATE "${OPENSSL_INCLUDE_DIR}")
endif()

if (BUILD_OPTEL)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
endif ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/crypto/CryptoStream.h>
#ifdef ENABLE_COMMONCRYPTO_ENCRYPTION
#include <aws/core/utils/crypto/commoncrypto/CryptoImpl.h>
#endif

using namespace Aws::Utils;
using namespace Aws::Utils::Crypto;
Expand Down
Loading