I don't think so.  The debug suffix is a Windows-ism which you don't see
on UNIX.

Okay great, I thought this was the case.

One criticism of the patch: It's not using SelectLibraryConfigurations
to choose between the release and debug variants.  Could it be updated
to do that for consistency?  See FindPNG.cmake as an example.  This
should make the patch quite a bit simpler.

Okay no problem, I've changed the patch to use SelectLibraryConfigurations instead. I've also changed the last bit of the patch, to set the "IMPORTED_CONFIGURATIONS" target property as well when there's debug and release variants, to be consistent with other Find modules. Let me know if this shouldn't be done in this situation.

Cheers,
Michael

From 92e2d4933d57305fb1b9343c16b68d36c1a29c09 Mon Sep 17 00:00:00 2001
From: Michael Scott <michael.scott...@gmail.com>
Date: Sun, 23 Aug 2015 10:45:27 +0100
Subject: [PATCH] Find the debug and release variants as separate libraries,
 providing both in ZLIB_LIBRARIES and ZLIB::ZLIB's imported location
 properties, when both are found.

---
 Modules/FindZLIB.cmake | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index d4a27d5..5de9acc 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -74,15 +74,20 @@ set(_ZLIB_SEARCH_NORMAL
   )
 list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
 
-set(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1)
+set(ZLIB_NAMES z zlib zdll zlib1)
+set(ZLIB_NAMES_DEBUG zlibd zlibd1)
 
 # Try each search configuration.
 foreach(search ${_ZLIB_SEARCHES})
   find_path(ZLIB_INCLUDE_DIR NAMES zlib.h        ${${search}} PATH_SUFFIXES 
include)
-  find_library(ZLIB_LIBRARY  NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES 
lib)
+  find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} ${${search}} 
PATH_SUFFIXES lib)
+  find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} ${${search}} 
PATH_SUFFIXES lib)
 endforeach()
 
-mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+select_library_configurations(ZLIB)
+
+mark_as_advanced(ZLIB_LIBRARY_RELEASE ZLIB_LIBRARY_DEBUG ZLIB_INCLUDE_DIR)
 
 if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
     file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define 
ZLIB_VERSION \"[^\"]*\"$")
@@ -112,12 +117,21 @@ 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})
 
     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}")
+        
+      if(ZLIB_LIBRARY_DEBUG)
+        set_property(TARGET ZLIB::ZLIB APPEND PROPERTY 
+          IMPORTED_CONFIGURATIONS RELEASE DEBUG)
+        set_target_properties(ZLIB::ZLIB PROPERTIES
+          IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}"
+          IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}")
+      else()
+        set_target_properties(ZLIB::ZLIB PROPERTIES
+          IMPORTED_LOCATION "${ZLIB_LIBRARY_RELEASE}")
+      endif()
     endif()
 endif()
-- 
2.1.4

-- 

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