curl-library
[PATCH] cmake: Backport to work with CMake 3.0 again
From: Brad King <brad.king_at_kitware.com>
Date: Fri, 21 Sep 2018 11:59:33 -0400
Date: Fri, 21 Sep 2018 11:59:33 -0400
Changes in commit 7867aaa9a0 (cmake: link curl to the OpenSSL targets
instead of lib absolute paths, 2018-07-17) and commit f826b4ce98 (cmake:
bumped minimum version to 3.4, 2018-07-19) required CMake 3.4 to fix
issue #2746. This broke support for users on older versions of CMake
even if they just want to build curl and do not care whether transitive
dependencies work.
Backport the logic to work with CMake 3.0 again by implementing the
fix only when the version of CMake is at least 3.4.
--- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e432a95..17cbd5da9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ # To check: # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. # (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options. -cmake_minimum_required(VERSION 3.4 FATAL_ERROR) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") include(Utilities) include(Macros) @@ -352,7 +352,16 @@ if(CMAKE_USE_OPENSSL) set(USE_OPENSSL ON) set(HAVE_LIBCRYPTO ON) set(HAVE_LIBSSL ON) - list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto) + + # Depend on OpenSSL via imported targets if supported by the running + # version of CMake. This allows our dependents to get our dependencies + # transitively. + if(NOT CMAKE_VERSION VERSION_LESS 3.4) + list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto) + else() + list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) + include_directories(${OPENSSL_INCLUDE_DIR}) + endif() set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) -- 2.18.0 --------------94498D819F04AC65FB16D957 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLQpVbnN1YnNjcmliZTogaHR0cHM6Ly9jb29sLmhheHguc2UvbGlzdC9saXN0aW5m by9jdXJsLWxpYnJhcnkKRXRpcXVldHRlOiAgIGh0dHBzOi8vY3VybC5oYXh4LnNlL21haWwvZXRp cXVldHRlLmh0bWw= --------------94498D819F04AC65FB16D957--Received on 2001-09-17