From e4c50672c2cc4a6cd8904b79c8c0d7255d2d67f4 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 13 Sep 2023 14:33:53 -0700 Subject: [PATCH] Fix aws-c-cal-config.cmake (#158) - Move `find_dependency()` calls before `include(aws-c-cal-targets.cmake)` - Use `@VAR@` style variables in the [config file](https://cmake.org/cmake/help/latest/command/configure_file.html), so that it's simpler for the installed config file to remember how it was originally built. --- cmake/aws-c-cal-config.cmake | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cmake/aws-c-cal-config.cmake b/cmake/aws-c-cal-config.cmake index 6f6b0899..9c101c5b 100644 --- a/cmake/aws-c-cal-config.cmake +++ b/cmake/aws-c-cal-config.cmake @@ -2,6 +2,18 @@ include(CMakeFindDependencyMacro) find_dependency(aws-c-common) +if (NOT @BYO_CRYPTO@ AND NOT WIN32 AND NOT APPLE) # if NOT BYO_CRYPTO AND NOT WIN32 AND NOT APPLE + if (@USE_OPENSSL@ AND NOT ANDROID) # if USE_OPENSSL AND NOT ANDROID + # aws-c-cal has been built with a dependency on OpenSSL::Crypto, + # therefore consumers of this library have a dependency on OpenSSL and must have it found + find_dependency(OpenSSL REQUIRED) + find_dependency(Threads REQUIRED) + else() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules") + find_dependency(crypto) + endif() +endif() + macro(aws_load_targets type) include(${CMAKE_CURRENT_LIST_DIR}/${type}/@PROJECT_NAME@-targets.cmake) endmacro() @@ -20,18 +32,3 @@ else() aws_load_targets(shared) endif() endif() - -if (NOT BYO_CRYPTO AND NOT WIN32 AND NOT APPLE) - get_target_property(AWS_C_CAL_DEPS AWS::aws-c-cal INTERFACE_LINK_LIBRARIES) - # pre-cmake 3.3 IN_LIST search approach - list (FIND AWS_C_CAL_DEPS "OpenSSL::Crypto" _index) - if (${_index} GREATER -1) # if USE_OPENSSL AND NOT ANDROID - # aws-c-cal has been built with a dependency on OpenSSL::Crypto, - # therefore consumers of this library have a dependency on OpenSSL and must have it found - find_dependency(OpenSSL REQUIRED) - find_dependency(Threads REQUIRED) - else() - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules") - find_dependency(crypto) - endif() -endif()