diff options
author | Tuomo Rinne <me@tuomo.co.uk> | 2018-10-10 21:45:44 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-10-29 17:10:24 +0100 |
commit | fc0672b447e01595fa745a26452240918fb262ce (patch) | |
tree | d61e640b563bb7db8347a317bb7248bad13d3de0 /CMakeLists.txt | |
parent | 5728229a4fd209421fdd324dab5fd445d5917508 (diff) | |
download | curl-fc0672b447e01595fa745a26452240918fb262ce.tar.gz |
cmake: add support for transitive ZLIB target
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1867a4302..0478ae179 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() |