|
| 1 | +if (TARGET openssl_ssl) |
| 2 | + return() |
| 3 | +endif() |
| 4 | +if (DARWIN) |
| 5 | + find_path(OPENSSL_INCLUDE_PATH NAMES openssl/sha.h |
| 6 | + PATHS $ENV{OPENSSL_ROOT_DIR}/include /usr/include /usr/local/include /usr/local/opt/openssl/include) |
| 7 | + find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto |
| 8 | + PATHS $ENV{OPENSSL_ROOT_DIR}/lib /usr/local/opt/openssl/lib /usr/lib /usr/local/lib) |
| 9 | + find_library(OPENSSL_SSL_LIBRARY NAMES ssl |
| 10 | + PATHS $ENV{OPENSSL_ROOT_DIR}/lib /usr/local/opt/openssl/lib /usr/lib /usr/local/lib) |
| 11 | +elseif(WIN32) |
| 12 | + find_path(OPENSSL_INCLUDE_PATH NAMES openssl/sha.h |
| 13 | + PATHS "c:/local/OpenSSL-Win64/include" |
| 14 | + "c:/Program Files/OpenSSL-Win64/include") |
| 15 | + find_library(OPENSSL_CRYPTO_LIBRARY NAMES libcrypto |
| 16 | + PATHS "c:/local/OpenSSL-Win64/lib" |
| 17 | + "c:/Program Files/OpenSSL-Win64/lib") |
| 18 | + find_library(OPENSSL_SSL_LIBRARY NAMES libssl |
| 19 | + PATHS "c:/local/OpenSSL-Win64/lib" |
| 20 | + "c:/Program Files/OpenSSL-Win64/lib") |
| 21 | + |
| 22 | +else() |
| 23 | + find_package(OpenSSL) |
| 24 | + if (OpenSSL_FOUND) |
| 25 | + return() |
| 26 | + endif() |
| 27 | + |
| 28 | + find_path(OPENSSL_INCLUDE_PATH NAMES openssl/sha.h |
| 29 | + PATHS /usr/include /usr/local/include /usr/local/opt/openssl/include) |
| 30 | + find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto |
| 31 | + PATHS /usr/local/opt/openssl/lib /usr/lib /usr/local/lib) |
| 32 | + find_library(OPENSSL_SSL_LIBRARY NAMES ssl |
| 33 | + PATHS /usr/local/opt/openssl/lib /usr/lib /usr/local/lib) |
| 34 | +endif() |
| 35 | + |
| 36 | +if (OPENSSL_CRYPTO_LIBRARY STREQUAL "OPENSSL_CRYPTO_LIBRARY-NOTFOUND") |
| 37 | + message(FATAL_ERROR "Could not find libcrypto") |
| 38 | +endif() |
| 39 | +if (OPENSSL_SSL_LIBRARY STREQUAL "OPENSSL_SSL_LIBRARY-NOTFOUND") |
| 40 | + message(FATAL_ERROR "Could not find libssl") |
| 41 | +endif() |
| 42 | + |
| 43 | + |
| 44 | +add_library(openssl_ssl INTERFACE) |
| 45 | +target_include_directories(openssl_ssl INTERFACE ${OPENSSL_INCLUDE_PATH}) |
| 46 | +target_link_libraries(openssl_ssl INTERFACE ${OPENSSL_SSL_LIBRARY}) |
| 47 | +target_compile_definitions(openssl_ssl INTERFACE -DOPENSSL_SUPPRESS_DEPRECATED) |
| 48 | + |
| 49 | +add_library(openssl_crypto INTERFACE) |
| 50 | +target_include_directories(openssl_crypto INTERFACE ${OPENSSL_INCLUDE_PATH}) |
| 51 | +target_link_libraries(openssl_crypto INTERFACE ${OPENSSL_CRYPTO_LIBRARY}) |
| 52 | +target_compile_definitions(openssl_crypto INTERFACE -DOPENSSL_SUPPRESS_DEPRECATED) |
| 53 | + |
| 54 | +add_library(OpenSSL::Crypto ALIAS openssl_crypto) |
| 55 | +add_library(OpenSSL::SSL ALIAS openssl_ssl) |
| 56 | + |
0 commit comments