diff --git a/CMakeLists.txt b/CMakeLists.txt index e571e5561..e42136fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,20 +255,21 @@ endif() option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) mark_as_advanced(CMAKE_USE_OPENSSL) if(CMAKE_USE_OPENSSL) - if(WIN32) - find_package(OpenSSL) - if(OPENSSL_FOUND) - set(USE_SSLEAY TRUE) - set(USE_OPENSSL TRUE) - list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} ) - else() - set(CMAKE_USE_OPENSSL FALSE) - message(STATUS "OpenSSL NOT Found, disabling CMAKE_USE_OPENSSL") - endif() - else(WIN32) - check_library_exists_concat("crypto" CRYPTO_lock HAVE_LIBCRYPTO) - check_library_exists_concat("ssl" SSL_connect HAVE_LIBSSL) - endif(WIN32) + + set(USE_SSLEAY OFF) + set(USE_OPENSSL OFF) + set(HAVE_LIBCRYPTO OFF) + set(HAVE_LIBSSL OFF) + + find_package(OpenSSL) + if(OPENSSL_FOUND) + list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + set(USE_SSLEAY ON) + set(USE_OPENSSL ON) + set(HAVE_LIBCRYPTO ON) + set(HAVE_LIBSSL ON) + endif(OPENSSL_FOUND) endif(CMAKE_USE_OPENSSL) # If we have features.h, then do the _BSD_SOURCE magic @@ -334,14 +335,17 @@ check_include_file_concat("net/if.h" HAVE_NET_IF_H) check_include_file_concat("netdb.h" HAVE_NETDB_H) check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H) check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H) -check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) -check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) -check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H) -check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H) -check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) -check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H) -check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H) -check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H) +if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND) + check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) + check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) + check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H) + check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H) + check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) + check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H) + check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H) + check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H) + check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H) +endif(CMAKE_USE_OPENSSL AND OPENSSL_FOUND) check_include_file_concat("pem.h" HAVE_PEM_H) check_include_file_concat("poll.h" HAVE_POLL_H) check_include_file_concat("pwd.h" HAVE_PWD_H) @@ -377,10 +381,6 @@ check_include_file_concat("sockio.h" HAVE_SOCKIO_H) check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H) check_include_file_concat("idna.h" HAVE_IDNA_H) -if(CMAKE_USE_OPENSSL) - check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H) -endif(CMAKE_USE_OPENSSL) - if(NOT HAVE_LDAP_H) message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)