---
 Modules/FindZLIB.cmake | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 8cc382c..d4a27d5 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -2,9 +2,18 @@
 # FindZLIB
 # --------
 #
-# Find zlib
+# Find the native ZLIB includes and library.
 #
-# Find the native ZLIB includes and library.  Once done this will define
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if
+# ZLIB has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
 #
 # ::
 #
@@ -12,8 +21,6 @@
 #   ZLIB_LIBRARIES      - List of libraries when using zlib.
 #   ZLIB_FOUND          - True if zlib found.
 #
-#
-#
 # ::
 #
 #   ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
@@ -22,7 +29,8 @@
 #   ZLIB_VERSION_PATCH  - The patch version of zlib
 #   ZLIB_VERSION_TWEAK  - The tweak version of zlib
 #
-#
+# Backward Compatibility
+# ^^^^^^^^^^^^^^^^^^^^^^
 #
 # The following variable are provided for backward compatibility
 #
@@ -32,9 +40,10 @@
 #   ZLIB_MINOR_VERSION  - The minor version of zlib
 #   ZLIB_PATCH_VERSION  - The patch version of zlib
 #
+# Hints
+# ^^^^^
 #
-#
-# An includer may set ZLIB_ROOT to a zlib installation root to tell this
+# A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
 # module where to look.
 
 #=============================================================================
@@ -104,5 +113,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_D
 if(ZLIB_FOUND)
     set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
     set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
-endif()
 
+    if(NOT TARGET ZLIB::ZLIB)
+      add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
+      set_target_properties(ZLIB::ZLIB PROPERTIES
+        IMPORTED_LOCATION "${ZLIB_LIBRARY}"
+        INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}")
+    endif()
+endif()
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to