]> granicus.if.org Git - curl/commitdiff
cmake: add support for transitive ZLIB target
authorTuomo Rinne <me@tuomo.co.uk>
Wed, 10 Oct 2018 20:45:44 +0000 (21:45 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 29 Oct 2018 16:10:24 +0000 (17:10 +0100)
CMakeLists.txt

index 1867a43025cc1e16921df97b98d6a6af51a4a63b..0478ae17959c3bf95754261993a4c932bee8ee2d 100644 (file)
@@ -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()