summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-01-22 14:25:33 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-01-22 14:25:33 (GMT)
commitddb09ec8f91e7215d867c83d9229d3558bf2c166 (patch)
tree7294d7613a0727918b340743d2996522d8fbe7f0 /Modules
parentdcf977ea1a97f41fe19a871235dc75e85891e478 (diff)
parent9b08c6233052fa1c3d393ee474c874f997491f7b (diff)
downloadCMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.zip
CMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.tar.gz
CMake-ddb09ec8f91e7215d867c83d9229d3558bf2c166.tar.bz2
Merge topic 'FindPNG-imported-targets'
9b08c623 FindPNG: Create an imported PNG::PNG target (#15911)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPNG.cmake50
1 files changed, 43 insertions, 7 deletions
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index 7cf3f22..cae41ac 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -2,13 +2,20 @@
# FindPNG
# -------
#
-# Find the native PNG includes and library
+# Find libpng, the official reference library for the PNG image format.
#
+# Imported targets
+# ^^^^^^^^^^^^^^^^
#
+# This module defines the following :prop_tgt:`IMPORTED` target:
#
-# This module searches libpng, the library for working with PNG images.
+# ``PNG::PNG``
+# The libpng library, if found.
#
-# It defines the following variables
+# Result variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module will set the following variables in your project:
#
# ``PNG_INCLUDE_DIRS``
# where to find png.h, etc.
@@ -22,19 +29,22 @@
# ``PNG_VERSION_STRING``
# the version of the PNG library found (since CMake 2.8.8)
#
-# Also defined, but not for general use are
+# Obsolete variables
+# ^^^^^^^^^^^^^^^^^^
+#
+# The following variables may also be set, for backwards compatibility:
#
# ``PNG_LIBRARY``
# where to find the PNG library.
-#
-# For backward compatiblity the variable PNG_INCLUDE_DIR is also set.
-# It has the same value as PNG_INCLUDE_DIRS.
+# ``PNG_INCLUDE_DIR``
+# where to find the PNG headers (same as PNG_INCLUDE_DIRS)
#
# Since PNG depends on the ZLib compression library, none of the above
# will be defined unless ZLib can be found.
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
+# Copyright 2016 Raumfeld
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -105,6 +115,32 @@ if(ZLIB_FOUND)
endif()
endif ()
+ if(NOT TARGET PNG::PNG)
+ add_library(PNG::PNG UNKNOWN IMPORTED)
+ set_target_properties(PNG::PNG PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "${PNG_DEFINITIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
+ if(EXISTS "${PNG_LIBRARY}")
+ set_target_properties(PNG::PNG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${PNG_LIBRARY}")
+ endif()
+ if(EXISTS "${PNG_LIBRARY_DEBUG}")
+ set_property(TARGET PNG::PNG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(PNG::PNG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${PNG_LIBRARY_DEBUG}")
+ endif()
+ if(EXISTS "${PNG_LIBRARY_RELEASE}")
+ set_property(TARGET PNG::PNG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(PNG::PNG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${PNG_LIBRARY_RELEASE}")
+ endif()
+ endif()
endif ()
if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h")