[cmake] use FindOpenSSL cmake module to search for OpenSSL
github:
@@ -377,20 +377,14 @@ endif()
set(CRYPTO_LIBRARY "")
if(WITH_OPENSSL)
- if(APPLE)
- set(CMAKE_REQUIRED_INCLUDES /opt/local/include)
- endif()
- check_include_files(openssl/ssl.h HAVE_OPENSSL_SSL_H)
- if(APPLE)
- set(CMAKE_REQUIRED_INCLUDES)
- endif()
- if(HAVE_OPENSSL_SSL_H)
- check_library_exists(crypto RAND_bytes "" HAVE_LIBCRYPTO)
- if(HAVE_LIBCRYPTO)
- set(CRYPTO_LIBRARY crypto)
- check_library_exists(ssl SSL_new "" HAVE_LIBSSL)
- set(HAVE_OPENSSL 1)
- endif()
+ find_package(OpenSSL)
+ if(OPENSSL_FOUND)
+ set(HAVE_OPENSSL_SSL_H 1)
+ set(HAVE_LIBSSL 1)
+ set(CRYPTO_LIBRARY OpenSSL::Crypto)
+ else()
+ unset(HAVE_OPENSSL_SSL_H)
+ unset(HAVE_LIBSSL)
endif()
else()
unset(HAVE_OPENSSL_SSL_H)
@@ -1180,7 +1174,7 @@ if(NOT ${CRYPTO_LIBRARY} EQUAL "")
target_link_libraries(test_mod ${CRYPTO_LIBRARY})
endif()
-if(HAVE_OPENSSL)
+if(OPENSSL_FOUND)
add_and_install_library(mod_openssl "mod_openssl.c")
set(L_MOD_OPENSSL ${L_MOD_OPENSSL} ssl crypto)
target_link_libraries(mod_openssl ${L_MOD_OPENSSL})
