From 5a7ff42100dfec3e9b84f531153842198f59cd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Tue, 10 Jun 2014 10:54:24 +0200 Subject: [PATCH] FindZLIB: Add imported target and documentation --- Modules/FindZLIB.cmake | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 8cc382c6e..d4a27d5a1 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()