Commit dd3e4767 authored by Kyle Edwards's avatar Kyle Edwards

OpenSSL: Issue an error if OpenSSL is not found

When building with the built-in Curl, CMAKE_USE_OPENSSL is only set
to ON by default if an OpenSSL installation is detected. However, this
can cause the user to mistakenly build without OpenSSL support if
OpenSSL is not installed, because CMAKE_USE_OPENSSL is set to OFF in
that case. Always set CMAKE_USE_OPENSSL to ON by default on systems
where it could be available, skipping the initial detection, resulting
in an error when we try to use OpenSSL later on. Detect this error
and advise the user to either install OpenSSL or set CMAKE_USE_OPENSSL
to OFF.
Co-Authored-by: Brad King's avatarBrad King <brad.king@kitware.com>
parent e3bd5c5b
......@@ -429,10 +429,7 @@ macro (CMAKE_BUILD_UTILITIES)
set(_CMAKE_USE_OPENSSL_DEFAULT OFF)
if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE
AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)")
find_package(OpenSSL QUIET)
if(OPENSSL_FOUND)
set(_CMAKE_USE_OPENSSL_DEFAULT ON)
endif()
set(_CMAKE_USE_OPENSSL_DEFAULT ON)
endif()
option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT})
mark_as_advanced(CMAKE_USE_OPENSSL)
......
......@@ -449,7 +449,12 @@ if(CMAKE_USE_SECTRANSP)
endif()
if(CMAKE_USE_OPENSSL)
find_package(OpenSSL REQUIRED)
find_package(OpenSSL)
if(NOT OpenSSL_FOUND)
message(FATAL_ERROR
"Could not find OpenSSL. Install an OpenSSL development package or "
"configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.")
endif()
set(SSL_ENABLED ON)
set(USE_OPENSSL ON)
set(HAVE_LIBCRYPTO ON)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment