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 124 125 126
|
# - Try to find LibCrypto include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(crypto)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Variables defined by this module:
#
# crypto_FOUND System has libcrypto, include and library dirs found
# crypto_INCLUDE_DIR The crypto include directories.
# crypto_LIBRARY The crypto library, depending on the value of BUILD_SHARED_LIBS.
# crypto_SHARED_LIBRARY The path to libcrypto.so
# crypto_STATIC_LIBRARY The path to libcrypto.a
# crypto_STATIC_LIBRARY The path to libcrypto.a
# the next branch exists purely for cmake compatibility with versions older than 3.15. Please do not remove it before
# we baseline on a newer version. It does not like duplicate target declarations. Work around that by checking it isn't
# defined first.
if (TARGET crypto OR TARGET AWS::crypto)
if (TARGET crypto)
set(TARGET_NAME "crypto")
else()
set(TARGET_NAME "AWS::crypto")
endif()
get_target_property(crypto_INCLUDE_DIR ${TARGET_NAME} INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "aws-c-cal found target: ${TARGET_NAME}")
message(STATUS "crypto Include Dir: ${crypto_INCLUDE_DIR}")
set(CRYPTO_FOUND true)
set(crypto_FOUND true)
else()
find_path(crypto_INCLUDE_DIR
NAMES openssl/crypto.h
HINTS
${CMAKE_PREFIX_PATH}/include
${CMAKE_INSTALL_PREFIX}/include
)
find_library(crypto_SHARED_LIBRARY
NAMES libcrypto.so libcrypto.dylib
HINTS
${CMAKE_PREFIX_PATH}/build/crypto
${CMAKE_PREFIX_PATH}/build
${CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}/lib64
${CMAKE_PREFIX_PATH}/lib
${CMAKE_INSTALL_PREFIX}/build/crypto
${CMAKE_INSTALL_PREFIX}/build
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/lib64
${CMAKE_INSTALL_PREFIX}/lib
)
find_library(crypto_STATIC_LIBRARY
NAMES libcrypto.a
HINTS
${CMAKE_PREFIX_PATH}/build/crypto
${CMAKE_PREFIX_PATH}/build
${CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}/lib64
${CMAKE_PREFIX_PATH}/lib
${CMAKE_INSTALL_PREFIX}/build/crypto
${CMAKE_INSTALL_PREFIX}/build
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/lib64
${CMAKE_INSTALL_PREFIX}/lib
)
if (BUILD_SHARED_LIBS OR AWS_USE_CRYPTO_SHARED_LIBS)
if (crypto_SHARED_LIBRARY)
set(crypto_LIBRARY ${crypto_SHARED_LIBRARY})
else()
set(crypto_LIBRARY ${crypto_STATIC_LIBRARY})
endif()
else()
if (crypto_STATIC_LIBRARY)
set(crypto_LIBRARY ${crypto_STATIC_LIBRARY})
else()
set(crypto_LIBRARY ${crypto_SHARED_LIBRARY})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(crypto DEFAULT_MSG
crypto_LIBRARY
crypto_INCLUDE_DIR
)
mark_as_advanced(
crypto_ROOT_DIR
crypto_INCLUDE_DIR
crypto_LIBRARY
crypto_SHARED_LIBRARY
crypto_STATIC_LIBRARY
)
# some versions of cmake have a super esoteric bug around capitalization differences between
# find dependency and find package, just avoid that here by checking and
# setting both.
if(CRYPTO_FOUND OR crypto_FOUND)
set(CRYPTO_FOUND true)
set(crypto_FOUND true)
message(STATUS "LibCrypto Include Dir: ${crypto_INCLUDE_DIR}")
message(STATUS "LibCrypto Shared Lib: ${crypto_SHARED_LIBRARY}")
message(STATUS "LibCrypto Static Lib: ${crypto_STATIC_LIBRARY}")
if (NOT TARGET AWS::crypto AND
(EXISTS "${crypto_LIBRARY}")
)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
add_library(AWS::crypto UNKNOWN IMPORTED)
set_target_properties(AWS::crypto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${crypto_INCLUDE_DIR}")
set_target_properties(AWS::crypto PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${crypto_LIBRARY}")
add_dependencies(AWS::crypto Threads::Threads)
endif()
endif()
endif()
|