No, there doesn't need to be. Once IMPORTED_CONFIGURATIONS is populated then we expect each configuration to have an IMPORTED_LOCATION_<CONFIG> 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 <[email protected]> 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
