| 1 |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
# SPDX-License-Identifier: Apache-2.0. |
| 3 |
|
| 4 |
option(IN_SOURCE_BUILD "If the CRT libs are being built from your source tree (add_subdirectory), set this to ON" OFF) |
| 5 |
|
| 6 |
# This function handles dependency list building based on if traditional CMAKE modules via. find_package should be |
| 7 |
# used, vs if this is an in source build via. something like git submodules and add_subdirectory. |
| 8 |
# This is largely because CMake was not well planned out, and as a result, in-source and modules don't play well |
| 9 |
# together. Only use this on CRT libraries (including S2N), libcrypto will stay as an assumed external dependency. |
| 10 |
# |
| 11 |
# package_name: is the name of the package to find |
| 12 |
# DEP_AWS_LIBS: output variable will be appended after each call to this function. You don't have to use it, |
| 13 |
# but it can be passed directly target_link_libraries and it will be the properly qualified library |
| 14 |
# name and namespace based on configuration. |
| 15 |
function(aws_use_package package_name) |
| 16 |
if (IN_SOURCE_BUILD) |
| 17 |
set(DEP_AWS_LIBS ${DEP_AWS_LIBS} ${package_name} PARENT_SCOPE) |
| 18 |
else() |
| 19 |
find_package(${package_name} REQUIRED) |
| 20 |
set(DEP_AWS_LIBS ${DEP_AWS_LIBS} AWS::${package_name} PARENT_SCOPE) |
| 21 |
endif() |
| 22 |
endfunction() |