From: Tuomo Rinne Date: Wed, 10 Oct 2018 20:45:44 +0000 (+0100) Subject: cmake: add support for transitive ZLIB target X-Git-Tag: curl-7_62_0~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc0672b447e01595fa745a26452240918fb262ce;p=thirdparty%2Fcurl.git cmake: add support for transitive ZLIB target --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1867a43025..0478ae1795 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,8 +515,16 @@ if(CURL_ZLIB) set(HAVE_ZLIB_H ON) set(HAVE_ZLIB ON) set(HAVE_LIBZ ON) - list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) - include_directories(${ZLIB_INCLUDE_DIRS}) + + # Depend on ZLIB 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 ZLIB::ZLIB) + else() + list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) + include_directories(${ZLIB_INCLUDE_DIRS}) + endif() list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) endif() endif()