<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,37 +1,84 @@
-# - Try to find the liblcms library
-# Once done this will define
-#
-#  LCMS_FOUND - system has liblcms
-#  LCMS_INCLUDE_DIRS - the liblcms include directories
-#  LCMS_LIBRARIES - Link these to use liblcms
-#  LCMS_INCLUDE_DIR is internal and deprecated for use
+# - Find LCMS
+# Find the LCMS includes and library
+# This module defines
+#  LCMS_INCLUDE_DIR, where to find lcms.h
+#  LCMS_LIBRARIES, the libraries needed to use LCMS.
+#  LCMS_VERSION, The value of LCMS_VERSION defined in lcms.h
+#  LCMS_FOUND, If false, do not try to use LCMS.
+
 
-# Copyright (c) 2008, Albert Astals Cid, &lt;aacid@kde.org&gt;
+# Copyright (c) 2008, Adrian Page, &lt;adrian@pagenet.plus.com&gt;
 #
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
 
-if (LCMS_LIBRARIES AND LCMS_INCLUDE_DIR)
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+if(NOT WIN32)
+   find_package(PkgConfig)
+   pkg_check_modules(PC_LCMS lcms)
+   set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER})
+endif(NOT WIN32)
+
+find_path(LCMS_INCLUDE_DIR lcms.h
+   PATHS
+   ${PC_LCMS_INCLUDEDIR}
+   ${PC_LCMS_INCLUDE_DIRS}
+   PATH_SUFFIXES lcms liblcms1
+)
+
+find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1
+   PATHS     
+   ${PC_LCMS_LIBDIR}
+   ${PC_LCMS_LIBRARY_DIRS}
+   PATH_SUFFIXES lcms
+)
 
-  # in cache already
-  set(LCMS_FOUND TRUE)
+if(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES)
+   set(LCMS_FOUND TRUE)
+else(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES)
+   set(LCMS_FOUND FALSE)
+endif(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES)
 
-else (LCMS_LIBRARIES AND LCMS_INCLUDE_DIR)
+if(LCMS_FOUND)
+   set(FIND_LCMS_VERSION_SOURCE
+      &quot;#include &lt;lcms.h&gt;\n int main()\n {\n return LCMS_VERSION;\n }\n&quot;)
+   set(FIND_LCMS_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindLCMS.cxx)
+   file(WRITE &quot;${FIND_LCMS_VERSION_SOURCE_FILE}&quot; &quot;${FIND_LCMS_VERSION_SOURCE}&quot;)
 
-  #reset vars
-  set(LCMS_LIBRARIES)
-  set(LCMS_INCLUDE_DIR)
+   set(FIND_LCMS_VERSION_ADD_INCLUDES 
+      &quot;-DINCLUDE_DIRECTORIES:STRING=${LCMS_INCLUDE_DIR}&quot;)
 
-  find_path (LCMS_INCLUDE_DIR lcms.h)
-  find_library(LCMS_LIBRARIES lcms)
-  if(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES)
-    set(LCMS_FOUND TRUE)
-  endif(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES)
+   try_run(LCMS_VERSION LCMS_COMPILE_RESULT
+      ${CMAKE_BINARY_DIR}
+      ${FIND_LCMS_VERSION_SOURCE_FILE}
+      CMAKE_FLAGS &quot;${FIND_LCMS_VERSION_ADD_INCLUDES}&quot;
+      OUTPUT_VARIABLE OUTPUT)
 
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(LCMS DEFAULT_MSG LCMS_LIBRARIES LCMS_INCLUDE_DIR)
+   if(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN)
+      if(NOT LCMS_FIND_QUIETLY)
+         string(SUBSTRING ${LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION)
+         string(SUBSTRING ${LCMS_VERSION} 1 2 LCMS_MINOR_VERSION)
+         message(STATUS &quot;Found lcms version ${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}, ${LCMS_LIBRARIES}&quot;)
+      endif(NOT LCMS_FIND_QUIETLY)
+   else(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN)
+      if(NOT LCMS_FIND_QUIETLY)
+         message(STATUS &quot;Found lcms but failed to find version ${LCMS_LIBRARIES}&quot;)
+         file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+            &quot;Find lcms version failed with the following output:\n${OUTPUT}\nFindLCMS.cxx:\n${FIND_LCMS_VERSION_SOURCE}\n\n&quot;)
+      endif(NOT LCMS_FIND_QUIETLY)
+      set(LCMS_VERSION NOTFOUND)
+   endif(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN)
+else(LCMS_FOUND)
+   if(NOT LCMS_FIND_QUIETLY)
+      if(LCMS_FIND_REQUIRED)
+         message(FATAL_ERROR &quot;Required package lcms NOT found&quot;)
+      else(LCMS_FIND_REQUIRED)
+         message(STATUS &quot;lcms NOT found&quot;)
+      endif(LCMS_FIND_REQUIRED)
+   endif(NOT LCMS_FIND_QUIETLY)
+endif(LCMS_FOUND)
 
-endif (LCMS_LIBRARIES AND LCMS_INCLUDE_DIR)
+mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION)
 
-set(LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})</diff>
      <filename>cmake/modules/FindLCMS.cmake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0974b7b4bfe3f8cf3a1408741ddf01c667c28044</id>
    </parent>
  </parents>
  <author>
    <name>Albert Astals Cid</name>
    <email>aacid@kde.org</email>
  </author>
  <url>http://github.com/kou/poppler-test/commit/657734c19274ab281328cba9297eca45e48777aa</url>
  <id>657734c19274ab281328cba9297eca45e48777aa</id>
  <committed-date>2009-05-17T03:08:53-07:00</committed-date>
  <authored-date>2009-05-17T03:06:47-07:00</authored-date>
  <message>Better lcms check comming from kdelibs</message>
  <tree>077aff86ddf716c71ed6916a575e200dd297c205</tree>
  <committer>
    <name>Albert Astals Cid</name>
    <email>aacid@kde.org</email>
  </committer>
</commit>
