| 1 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
# SPDX-License-Identifier: Apache-2.0. |
| 3 |
cmake_minimum_required(VERSION 3.9...3.31) |
| 4 |
|
| 5 |
# This CMakeLists.txt exists so we can build all the C libraries we depend on |
| 6 |
# simultaneously. This is much faster than building dependencies one at a time. |
| 7 |
# |
| 8 |
# This CMakeLists.txt does NOT build the Python extension itself. |
| 9 |
# We let setuptools handle that. |
| 10 |
project(aws-crt-dependencies) |
| 11 |
|
| 12 |
# Note: set() calls must use CACHE, and must be called before the option() they're overriding, |
| 13 |
# or they won't work right on CMake 3.12 and below. |
| 14 |
# see: https://cmake.org/cmake/help/v3.13/policy/CMP0077.html |
| 15 |
|
| 16 |
# This magic lets us build everything all at once |
| 17 |
set(IN_SOURCE_BUILD ON CACHE BOOL "") |
| 18 |
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/aws-c-common/cmake) |
| 19 |
include(AwsFindPackage) |
| 20 |
|
| 21 |
# Build dependencies as static libs |
| 22 |
set(BUILD_SHARED_LIBS OFF CACHE BOOL "") |
| 23 |
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "") |
| 24 |
|
| 25 |
# Don't build the dependencies' tests |
| 26 |
set(BUILD_TESTING OFF CACHE BOOL "") |
| 27 |
include(CTest) |
| 28 |
|
| 29 |
option(AWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE "Set this if you want to use libcrypto to support ed25519 on Window/Apple" ON) |
| 30 |
|
| 31 |
# Use minimal debug info to reduce binary size. |
| 32 |
string(REPLACE "-g" "-g1" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") |
| 33 |
string(REPLACE "-g" "-g1" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") |
| 34 |
|
| 35 |
# On Linux and BSD, we use S2N for TLS and AWS-LC crypto. |
| 36 |
# On Windows, we use the default OS libraries. |
| 37 |
# On Apple, we use the default OS libraries by default, but support S2N usage. |
| 38 |
if (UNIX OR AWS_USE_LIBCRYPTO_TO_SUPPORT_ED25519_EVERYWHERE) |
| 39 |
option(USE_OPENSSL "Set this if you want to use your system's OpenSSL compatible libcrypto" OFF) |
| 40 |
include(AwsPrebuildDependency) |
| 41 |
|
| 42 |
if(NOT USE_OPENSSL) |
| 43 |
|
| 44 |
set(AWSLC_CMAKE_ARGUMENTS |
| 45 |
-DDISABLE_GO=ON # Build without using Go, we don't want the extra dependency |
| 46 |
-DDISABLE_PERL=ON # Build without using Perl, we don't want the extra dependency |
| 47 |
-DBUILD_LIBSSL=OFF # Don't need libssl, only need libcrypto |
| 48 |
-DBUILD_TESTING=OFF |
| 49 |
-DCMAKE_BUILD_TYPE=RelWithDebInfo # Use the same build type as the rest of the project |
| 50 |
) |
| 51 |
|
| 52 |
if (WIN32) |
| 53 |
# Libcrypto implementations typically have several chunky pregenerated tables that add a lot |
| 54 |
# to artifact size. We dont really need them for ed25519 case on win/mac, so favor |
| 55 |
# smaller binary over perf here. |
| 56 |
# In future if there is more usage of lc on win/mac consider removing this |
| 57 |
list(APPEND AWSLC_CMAKE_ARGUMENTS -DOPENSSL_SMALL=1) |
| 58 |
endif() |
| 59 |
|
| 60 |
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0") |
| 61 |
# Disable AVX512 on old GCC that not supports it. |
| 62 |
list(APPEND AWSLC_CMAKE_ARGUMENTS -DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX=ON) |
| 63 |
endif() |
| 64 |
|
| 65 |
# s2n-tls uses libcrypto during its configuration, so we need to prebuild aws-lc. |
| 66 |
aws_prebuild_dependency( |
| 67 |
DEPENDENCY_NAME AWSLC |
| 68 |
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/aws-lc |
| 69 |
CMAKE_ARGUMENTS ${AWSLC_CMAKE_ARGUMENTS} |
| 70 |
) |
| 71 |
endif() |
| 72 |
|
| 73 |
|
| 74 |
endif() |
| 75 |
|
| 76 |
# Build s2n-tls on all Unix platforms (Linux, BSD, macOS). |
| 77 |
# On macOS (Darwin), both Secure Transport and s2n are built; the TLS backend |
| 78 |
# is selected at runtime via the AWS_CRT_USE_NON_FIPS_TLS_13 environment variable. |
| 79 |
if(UNIX) |
| 80 |
# prebuild s2n-tls. |
| 81 |
aws_prebuild_dependency( |
| 82 |
DEPENDENCY_NAME S2N |
| 83 |
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/s2n |
| 84 |
CMAKE_ARGUMENTS |
| 85 |
-DUNSAFE_TREAT_WARNINGS_AS_ERRORS=OFF |
| 86 |
-DBUILD_TESTING=OFF |
| 87 |
# On Intel Macs, Homebrew installs to /usr/local, which is in the default |
| 88 |
# system header search path. Without this flag, s2n picks up Homebrew's OpenSSL |
| 89 |
# headers instead of the bundled aws-lc headers. Not needed on ARM where Homebrew |
| 90 |
# uses /opt/homebrew (not in default search paths), but harmless to set everywhere. |
| 91 |
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON |
| 92 |
) |
| 93 |
endif() |
| 94 |
|
| 95 |
add_subdirectory(aws-c-common) |
| 96 |
add_subdirectory(aws-c-sdkutils) |
| 97 |
add_subdirectory(aws-c-cal) |
| 98 |
add_subdirectory(aws-c-io) |
| 99 |
add_subdirectory(aws-checksums) |
| 100 |
add_subdirectory(aws-c-compression) |
| 101 |
add_subdirectory(aws-c-event-stream) |
| 102 |
add_subdirectory(aws-c-http) |
| 103 |
add_subdirectory(aws-c-auth) |
| 104 |
add_subdirectory(aws-c-mqtt) |
| 105 |
add_subdirectory(aws-c-s3) |