Re: [cmake-developers] FindZLIB module should find debug and, release variants
On 09/01/2015 03:56 PM, Michael Scott wrote: > The attached patch should maintain that compatibility now. If > ZLIB_LIBRARY is set manually, then it won't try and find the library and > it'll set the ZLIB_LIBRARIES and IMPORTED_LOCATION variables using the > provided ZLIB_LIBRARY variable (if the library was found). Thanks. Applied: FindZLIB: Find debug and release variants separately http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=11097f52 -Brad -- 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
Thanks. We also need to be compatible with projects or scripts that set ZLIB_LIBRARY themselves. The attached patch should maintain that compatibility now. If ZLIB_LIBRARY is set manually, then it won't try and find the library and it'll set the ZLIB_LIBRARIES and IMPORTED_LOCATION variables using the provided ZLIB_LIBRARY variable (if the library was found). Cheers, Michael From c7905e97fa0a1412a1b05ee295d4bfa97c699b3e Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Tue, 1 Sep 2015 20:41:27 +0100 Subject: [PATCH] Support finding the debug and release variants as separate libraries, providing each variant in ZLIB_LIBRARIES and ZLIB::ZLIB's imported location properties when one is found, while maintaining support for manually setting the library via ZLIB_LIBRARY. --- Modules/FindZLIB.cmake | 45 - 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index d4a27d5..88aac56 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -74,14 +74,28 @@ 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_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) endforeach() +# Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library +if(NOT ZLIB_LIBRARY) + foreach(search ${_ZLIB_SEARCHES}) +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() + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(ZLIB) +endif() + +unset(ZLIB_NAMES) +unset(ZLIB_NAMES_DEBUG) + mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") @@ -112,12 +126,33 @@ 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 ZLIB_LIBRARIES) + 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}") + + if(ZLIB_LIBRARY_RELEASE) +set_property(TARGET ZLIB::ZLIB APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}") + endif() + + if(ZLIB_LIBRARY_DEBUG) +set_property(TARGET ZLIB::ZLIB APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}") + endif() + + if(NOT ZLIB_LIBRARY_RELEASE AND NOT ZLIB_LIBRARY_DEBUG) +set_property(TARGET ZLIB::ZLIB APPEND PROPERTY + IMPORTED_LOCATION "${ZLIB_LIBRARY}") + 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
On 08/28/2015 05:37 PM, Michael Scott wrote: > Okay, I've modified the patch to only add the DEBUG and RELEASE > configurations when the corresponding library is found, and not set the > generic IMPORTED_LOCATION property at all. Thanks. We also need to be compatible with projects or scripts that set ZLIB_LIBRARY themselves. See how FindTIFF did that here: FindTIFF: Find debug and release libraries separately http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=724fa682 Sorry I didn't notice this on the last review. Thanks, -Brad -- 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
No, there doesn't need to be. Once IMPORTED_CONFIGURATIONS is populated then we expect each configuration to have an IMPORTED_LOCATION_ setting too. CMake will choose an appropriate configuration and use that location. Okay, I've modified the patch to only add the DEBUG and RELEASE configurations when the corresponding library is found, and not set the generic IMPORTED_LOCATION property at all. Cheers, Michael From ef53d82356062a1e7babafaa588cb34832b491fc Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Sun, 23 Aug 2015 10:45:27 +0100 Subject: [PATCH] Find the debug and release variants as separate libraries, providing each variant in ZLIB_LIBRARIES and ZLIB::ZLIB's imported location properties when one is found. --- Modules/FindZLIB.cmake | 27 ++- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index d4a27d5..c6cb016 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,24 @@ 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_RELEASE) +set_property(TARGET ZLIB::ZLIB APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}") + endif() + + if(ZLIB_LIBRARY_DEBUG) +set_property(TARGET ZLIB::ZLIB APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}") + 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
On 08/25/2015 04:39 PM, Michael Scott wrote: > I'm assuming that there should be a IMPORTED_LOCATION property defined > in all cases as well? No, there doesn't need to be. Once IMPORTED_CONFIGURATIONS is populated then we expect each configuration to have an IMPORTED_LOCATION_ setting too. CMake will choose an appropriate configuration and use that location. -Brad -- 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
Please add each of the _DEBUG and _RELEASE configurations if and only if the corresponding variables are set. Grep for mention of IMPORTED_CONFIGURATIONS in other Modules/Find*.cmake files for examples. I'm assuming that there should be a IMPORTED_LOCATION property defined in all cases as well? The other Find modules aren't entirely consistent for this point, but it would make sense to me to set it to ZLIB_LIBRARY, similar to how FindOpenSSL behaves. Cheers, Michael -- 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
Re: [cmake-developers] FindZLIB module should find debug and, release variants
On 08/23/2015 04:41 PM, Michael Scott wrote: > 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. Please add each of the _DEBUG and _RELEASE configurations if and only if the corresponding variables are set. Grep for mention of IMPORTED_CONFIGURATIONS in other Modules/Find*.cmake files for examples. Thanks, -Brad P.S. Your mailer is breaking threads. -- 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
[cmake-developers] FindZLIB module should find debug and, release variants
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 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
Re: [cmake-developers] FindZLIB module should find debug and release variants
On 23/08/2015 10:07, Michael Scott wrote: Carrying on in the list of open issues to look at for contributing to CMake, I've had a look at issue "15280 - FindZLIB module should find debug and release variants". I've made some changes to the FindZLIB module which should make it so that debug and release variants are found as separate libraries, if they're both found then they're provided in ZLIB_LIBRARIES and ZLIB::ZLIB's imported location properties. Attached is the patch for FindZLIB.cmake. With this, I noticed that the Windows DLL's use different file names for the release and debug variants, but I couldn't tell if this is true on UNIX, it didn't seem to be the case. As the change to FinZLIB is based on the two variants having different names, I'm not sure these changes will have any effect on UNIX, is this expected or am I missing something/going about it the wrong way? I don't think so. The debug suffix is a Windows-ism which you don't see on UNIX. 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. Regards, Roger -- 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
Re: [cmake-developers] FindZLIB module should find debug and release variants
Michael Scott wrote: > Hi, > > Carrying on in the list of open issues to look at for contributing to > CMake, I've had a look at issue "15280 - FindZLIB module should find > debug and release variants". I've made some changes to the FindZLIB > module which should make it so that debug and release variants are found > as separate libraries, if they're both found then they're provided in > ZLIB_LIBRARIES and ZLIB::ZLIB's imported location properties. Attached > is the patch for FindZLIB.cmake. > > With this, I noticed that the Windows DLL's use different file names for > the release and debug variants, but I couldn't tell if this is true on > UNIX, it didn't seem to be the case. As the change to FinZLIB is based > on the two variants having different names, I'm not sure these changes > will have any effect on UNIX, is this expected or am I missing > something/going about it the wrong way? On Unix systems those variants usually do not exists, as there are no different standard libraries (and therefore e.g. allocators) used for release and debug mode. You should use SelectLibraryConfigurations.cmake instead of building the list of libraries yourself. Look at FindPNG.cmake, which uses it. I wonder if we should add a function or macro to SLC which does the target fiddling which is done at the bottom of the patch. Eike -- signature.asc Description: This is a digitally signed message part. -- 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
[cmake-developers] FindZLIB module should find debug and release variants
Hi, Carrying on in the list of open issues to look at for contributing to CMake, I've had a look at issue "15280 - FindZLIB module should find debug and release variants". I've made some changes to the FindZLIB module which should make it so that debug and release variants are found as separate libraries, if they're both found then they're provided in ZLIB_LIBRARIES and ZLIB::ZLIB's imported location properties. Attached is the patch for FindZLIB.cmake. With this, I noticed that the Windows DLL's use different file names for the release and debug variants, but I couldn't tell if this is true on UNIX, it didn't seem to be the case. As the change to FinZLIB is based on the two variants having different names, I'm not sure these changes will have any effect on UNIX, is this expected or am I missing something/going about it the wrong way? Cheers, Michael From 9d1aa288cc68008797cbf67d0fe86a8713b4ad29 Mon Sep 17 00:00:00 2001 From: Michael Scott 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 | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index d4a27d5..b572b09 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -74,15 +74,17 @@ 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_DEBUG NAMES ${ZLIB_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib) endforeach() -mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) +mark_as_advanced(ZLIB_LIBRARY 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 +114,25 @@ 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(ZLIB_LIBRARY_DEBUG) +set(ZLIB_LIBRARIES optimized ${ZLIB_LIBRARY} debug ${ZLIB_LIBRARY_DEBUG}) +else() +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}") + + if(ZLIB_LIBRARY_DEBUG) +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY}" + IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}") + else() +set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARY}") + 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