-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
123 lines (101 loc) · 4.24 KB
/
CMakeLists.txt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.9)
project(aws-crt-ffi C)
message(STATUS "CMake ${CMAKE_VERSION}")
option(BUILD_DEPS "Builds aws common runtime dependencies as part of build. Turn off if you want to control your dependency chain." ON)
option(BUILD_SHARED_LIBS "Build shared library for FFI: default: ON" ON)
if (DEFINED CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
if (UNIX AND NOT APPLE)
set(FIND_LIBRARY_USE_LIB64_PATHS true)
endif()
# This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
# Append that generated list to the module search path
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})
if (BUILD_DEPS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/crt/aws-c-common/cmake")
include(AwsFindPackage)
set(IN_SOURCE_BUILD ON)
set(SEARCH_LIBCRYPTO OFF CACHE BOOL "Let S2N use libcrypto from AWS-LC.")
# Don't compile tests in subdirectories.
# Turn off using `option` instead of `set`, or CTest will declare
# it as an option later and override the existing variable.
set(BUILD_TESTING OFF)
# Disable BUILD_SHARED_LIBS for all CRT libs
set(SHARED_FFI_LIB ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
# CRT Libraries
add_subdirectory(crt/aws-c-common)
if (UNIX AND NOT APPLE)
include(AwsPrebuildDependency)
if (NOT USE_OPENSSL)
set(AWSLC_CMAKE_ARGUMENTS
-DDISABLE_GO=ON # Build without using Go, we don't want the extra dependency
-DDISABLE_PERL=ON # Build without using Perl, we don't want the extra dependency
-DBUILD_LIBSSL=OFF # Don't need libssl, only need libcrypto
-DBUILD_TESTING=OFF
)
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0")
# Disable AVX512 on old GCC that not supports it.
list(APPEND AWSLC_CMAKE_ARGUMENTS -DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX=ON)
endif()
# s2n-tls uses libcrypto during its configuration, so we need to prebuild aws-lc.
aws_prebuild_dependency(
DEPENDENCY_NAME AWSLC
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crt/aws-lc
CMAKE_ARGUMENTS ${AWSLC_CMAKE_ARGUMENTS}
)
endif()
# prebuild s2n-tls.
aws_prebuild_dependency(
DEPENDENCY_NAME S2N
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crt/s2n
CMAKE_ARGUMENTS
-DUNSAFE_TREAT_WARNINGS_AS_ERRORS=OFF
-DBUILD_TESTING=OFF
)
endif()
add_subdirectory(crt/aws-c-sdkutils)
add_subdirectory(crt/aws-c-io)
add_subdirectory(crt/aws-c-cal)
add_subdirectory(crt/aws-c-compression)
add_subdirectory(crt/aws-c-http)
add_subdirectory(crt/aws-c-auth)
add_subdirectory(crt/aws-c-event-stream)
add_subdirectory(crt/aws-checksums)
else()
include(AwsFindPackage)
set(IN_SOURCE_BUILD OFF)
endif()
# Restore BUILD_SHARED_LIBS for this project
set(BUILD_SHARED_LIBS ${SHARED_FFI_LIB})
include(AwsCFlags)
include(AwsSharedLibSetup)
include(AwsSanitizers)
file(GLOB AWS_CRT_SRC "src/*.h" "src/*.c")
add_library(${PROJECT_NAME} ${AWS_CRT_SRC})
aws_set_common_properties(${PROJECT_NAME})
aws_prepare_shared_lib_exports(${PROJECT_NAME})
aws_use_package(aws-c-common)
aws_use_package(aws-c-sdkutils)
aws_use_package(aws-c-io)
aws_use_package(aws-c-cal)
aws_use_package(aws-c-compression)
aws_use_package(aws-c-http)
aws_use_package(aws-c-auth)
aws_use_package(aws-c-event-stream)
aws_use_package(aws-checksums)
aws_add_sanitizers(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE ${DEP_AWS_LIBS})
aws_set_common_properties(${PROJECT_NAME})
configure_file("cmake/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/"
COMPONENT Development)