| 1 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
# SPDX-License-Identifier: Apache-2.0 OR ISC |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 3.5...3.31) |
| 5 |
|
| 6 |
project(AWS_LC_RUST NONE) |
| 7 |
enable_language(C) |
| 8 |
|
| 9 |
function(set_my_target_properties ...) |
| 10 |
set_target_properties(crypto PROPERTIES ${ARGV}) |
| 11 |
if (BUILD_LIBSSL) |
| 12 |
set_target_properties(ssl PROPERTIES ${ARGV}) |
| 13 |
endif() |
| 14 |
endfunction() |
| 15 |
|
| 16 |
if(BUILD_SHARED_LIBS) |
| 17 |
add_definitions(-DBORINGSSL_SHARED_LIBRARY) |
| 18 |
endif() |
| 19 |
|
| 20 |
add_subdirectory(aws-lc aws-lc EXCLUDE_FROM_ALL) |
| 21 |
if(NOT EXISTS "${AWS_LC_RUST_SOURCE_DIR}/aws-lc/CMakeLists.txt") |
| 22 |
message(WARNING "###### WARNING: MISSING GIT SUBMODULE ###### Did you initialize the repo's git submodules? CMakeLists.txt not found.\n -- run 'git submodule update --init --recursive' to initialize.") |
| 23 |
endif() |
| 24 |
|
| 25 |
if (BUILD_LIBSSL) |
| 26 |
add_definitions(-DAWS_LC_RUST_INCLUDE_SSL) |
| 27 |
endif() |
| 28 |
|
| 29 |
# Custom target needed because aws-lc is added with EXCLUDE_FROM_ALL, so its targets aren't built by default. |
| 30 |
if (BUILD_LIBSSL) |
| 31 |
add_custom_target(aws_lc_sys ALL DEPENDS crypto ssl) |
| 32 |
else() |
| 33 |
add_custom_target(aws_lc_sys ALL DEPENDS crypto) |
| 34 |
endif() |
| 35 |
|
| 36 |
# The aws-lc Windows FIPS shared-library build may define a fips_integrity |
| 37 |
# target that patches the correct integrity hash into crypto.dll after it is |
| 38 |
# linked. Because aws-lc is added with EXCLUDE_FROM_ALL, that target would not |
| 39 |
# be part of this project's ALL target and would otherwise never be built. |
| 40 |
if (FIPS AND TARGET fips_integrity) |
| 41 |
add_dependencies(aws_lc_sys fips_integrity) |
| 42 |
endif() |
| 43 |
|
| 44 |
set(FINAL_ARTIFACTS_DIRECTORY ${CMAKE_BINARY_DIR}/artifacts) |
| 45 |
|
| 46 |
# Places the compiled library files at the root of the binary directory so we can have a consistent |
| 47 |
# location to find the artifacts cross-platform. |
| 48 |
set_my_target_properties( |
| 49 |
ARCHIVE_OUTPUT_DIRECTORY ${FINAL_ARTIFACTS_DIRECTORY} |
| 50 |
RUNTIME_OUTPUT_DIRECTORY ${FINAL_ARTIFACTS_DIRECTORY} |
| 51 |
LIBRARY_OUTPUT_DIRECTORY ${FINAL_ARTIFACTS_DIRECTORY}) |
| 52 |
|
| 53 |
# Based on https://stackoverflow.com/a/7750816 as some generators, like MSVC, will try to prefix the output directory |
| 54 |
# which is not needed in our case. |
| 55 |
foreach (OUT_NAME ${CMAKE_CONFIGURATION_TYPES}) |
| 56 |
string(TOUPPER ${OUT_NAME} OUT_NAME) |
| 57 |
set_my_target_properties( |
| 58 |
ARCHIVE_OUTPUT_DIRECTORY_${OUT_NAME} ${FINAL_ARTIFACTS_DIRECTORY} |
| 59 |
RUNTIME_OUTPUT_DIRECTORY_${OUT_NAME} ${FINAL_ARTIFACTS_DIRECTORY} |
| 60 |
LIBRARY_OUTPUT_DIRECTORY_${OUT_NAME} ${FINAL_ARTIFACTS_DIRECTORY}) |
| 61 |
endforeach () |
| 62 |
|
| 63 |
if (BORINGSSL_PREFIX) |
| 64 |
if (MSVC) |
| 65 |
set(TARGET_PREFIX "${BORINGSSL_PREFIX}") |
| 66 |
set_my_target_properties(IMPORT_PREFIX ${TARGET_PREFIX}) |
| 67 |
else() |
| 68 |
set(TARGET_PREFIX "lib${BORINGSSL_PREFIX}") |
| 69 |
endif() |
| 70 |
set_my_target_properties(PREFIX ${TARGET_PREFIX}) |
| 71 |
|
| 72 |
# This BORINGSSL_PREFIX has an "_" appended, so we must remove it |
| 73 |
string(REGEX REPLACE "_$" "" BORINGSSL_PREFIX_MACRO ${BORINGSSL_PREFIX}) |
| 74 |
add_definitions(-DBORINGSSL_PREFIX=${BORINGSSL_PREFIX_MACRO}) |
| 75 |
endif () |