summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-07-17 18:00:01 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2019-07-18 15:10:36 (GMT)
commitdd3e4767863dfe1307d4dccd2445e5312b55473e (patch)
treef9866d982850b89c9cef725f9390951074d4d857
parente3bd5c5b666e515319d81f8218e2f71c11169304 (diff)
downloadCMake-dd3e4767863dfe1307d4dccd2445e5312b55473e.zip
CMake-dd3e4767863dfe1307d4dccd2445e5312b55473e.tar.gz
CMake-dd3e4767863dfe1307d4dccd2445e5312b55473e.tar.bz2
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 <brad.king@kitware.com>
-rw-r--r--CMakeLists.txt5
-rw-r--r--Utilities/cmcurl/CMakeLists.txt7
2 files changed, 7 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 399e79c..5efa077 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 37522fc..bc8a7dc 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -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)