--- a/cmake/modules/FindLCMS2.cmake	2016-11-02 07:09:50.000000000 +0100
+++ b/cmake/modules/FindLCMS2.cmake	2018-06-02 00:43:27.309100600 +0200
@@ -13,7 +13,6 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying LICENSE file.
 
-
 # use pkg-config to get the directories and then use these values
 # in the FIND_PATH() and FIND_LIBRARY() calls
 if(NOT WIN32)
@@ -29,18 +28,30 @@
    PATH_SUFFIXES lcms2 liblcms2
 )
 
-find_library(LCMS2_LIBRARIES NAMES lcms2 liblcms2 lcms-2 liblcms-2
+include(SelectLibraryConfigurations)
+
+find_library(LCMS2_LIBRARY_RELEASE NAMES lcms2 liblcms2 lcms-2 liblcms-2
+   PATHS     
+   ${PC_LCMS2_LIBDIR}
+   ${PC_LCMS2_LIBRARY_DIRS}
+   PATH_SUFFIXES lcms2
+)
+
+find_library(LCMS2_LIBRARY_DEBUG NAMES lcms2d liblcms2d lcms-2d liblcms-2d
    PATHS     
    ${PC_LCMS2_LIBDIR}
    ${PC_LCMS2_LIBRARY_DIRS}
    PATH_SUFFIXES lcms2
 )
 
-if(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES)
+select_library_configurations(LCMS2)
+
+
+if(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARY)
    set(LCMS2_FOUND TRUE)
-else(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES)
+else(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARY)
    set(LCMS2_FOUND FALSE)
-endif(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES)
+endif(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARY)
 
 if(LCMS2_FOUND)
    file(READ ${LCMS2_INCLUDE_DIR}/lcms2.h LCMS2_VERSION_CONTENT)
@@ -50,11 +61,11 @@
       if(NOT LCMS2_FIND_QUIETLY)
          string(SUBSTRING ${LCMS2_VERSION} 0 1 LCMS2_MAJOR_VERSION)
          string(SUBSTRING ${LCMS2_VERSION} 1 2 LCMS2_MINOR_VERSION)
-         message(STATUS "Found lcms version ${LCMS2_MAJOR_VERSION}.${LCMS2_MINOR_VERSION}, ${LCMS2_LIBRARIES}")
+         message(STATUS "Found lcms version ${LCMS2_MAJOR_VERSION}.${LCMS2_MINOR_VERSION}, ${LCMS2_LIBRARY}")
       endif(NOT LCMS2_FIND_QUIETLY)
    else(LCMS2_VERSION_MATCH)
       if(NOT LCMS2_FIND_QUIETLY)
-         message(STATUS "Found lcms2 but failed to find version ${LCMS2_LIBRARIES}")
+         message(STATUS "Found lcms2 but failed to find version ${LCMS2_LIBRARY}")
       endif(NOT LCMS2_FIND_QUIETLY)
       set(LCMS2_VERSION NOTFOUND)
    endif(LCMS2_VERSION_MATCH)
@@ -68,5 +79,5 @@
    endif(NOT LCMS2_FIND_QUIETLY)
 endif(LCMS2_FOUND)
 
-mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARIES LCMS2_VERSION)
+mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY LCMS2_VERSION)
 
