[poppler] 2 commits - cmake/modules configure.ac poppler/Makefile.am

Albert Astals Cid aacid at kemper.freedesktop.org
Sun May 17 03:09:31 PDT 2009


 cmake/modules/FindLCMS.cmake |   95 ++++++++++++++++++++++++++++++++-----------
 configure.ac                 |   12 +++--
 poppler/Makefile.am          |    2 
 3 files changed, 79 insertions(+), 30 deletions(-)

New commits:
commit e0fcf7055af480498a81a000dcd9f977a783df66
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun May 17 12:07:05 2009 +0200

    Use pkgconfig for autotools cms check

diff --git a/configure.ac b/configure.ac
index 4db7815..1eb8fd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -458,12 +458,14 @@ AC_ARG_ENABLE(cms,
 	      AC_HELP_STRING([--disable-cms],
 	                     [Don't use color management system.]),
               enable_cms=$enableval,
-              enable_cms="yes")
+              enable_cms="try")
 if test x$enable_cms = xyes; then
-  AC_CHECK_LIB([lcms],cmsOpenProfileFromFile,,
-	       AC_MSG_ERROR("*** lcms library not found ***"))
-  AC_CHECK_HEADERS([lcms.h],,
-		   AC_MSG_ERROR("*** lcms headers not found ***"))
+  PKG_CHECK_MODULES(LCMS, lcms)
+elif test x$enable_cms = xtry; then
+  PKG_CHECK_MODULES(LCMS, lcms, [enable_cms=yes], [enable_cms=no])
+fi
+
+if test "x$enable_cms" = "xyes"; then
   AC_DEFINE(USE_CMS, 1, [Defines if use cms])
 fi
 AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes)
diff --git a/poppler/Makefile.am b/poppler/Makefile.am
index 53bc5b2..c872fda 100644
--- a/poppler/Makefile.am
+++ b/poppler/Makefile.am
@@ -106,7 +106,7 @@ abiword_libs =					\
 endif
 
 if USE_CMS
-cms_libs = -llcms
+cms_libs = $(LCMS_LIBS)
 endif
 
 INCLUDES =					\
commit 657734c19274ab281328cba9297eca45e48777aa
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun May 17 12:06:47 2009 +0200

    Better lcms check comming from kdelibs

diff --git a/cmake/modules/FindLCMS.cmake b/cmake/modules/FindLCMS.cmake
index 32a8266..9d162d2 100644
--- a/cmake/modules/FindLCMS.cmake
+++ b/cmake/modules/FindLCMS.cmake
@@ -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, <aacid at kde.org>
+# Copyright (c) 2008, Adrian Page, <adrian at pagenet.plus.com>
 #
 # 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
+      "#include <lcms.h>\n int main()\n {\n return LCMS_VERSION;\n }\n")
+   set(FIND_LCMS_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindLCMS.cxx)
+   file(WRITE "${FIND_LCMS_VERSION_SOURCE_FILE}" "${FIND_LCMS_VERSION_SOURCE}")
 
-  #reset vars
-  set(LCMS_LIBRARIES)
-  set(LCMS_INCLUDE_DIR)
+   set(FIND_LCMS_VERSION_ADD_INCLUDES 
+      "-DINCLUDE_DIRECTORIES:STRING=${LCMS_INCLUDE_DIR}")
 
-  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 "${FIND_LCMS_VERSION_ADD_INCLUDES}"
+      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 "Found lcms version ${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}, ${LCMS_LIBRARIES}")
+      endif(NOT LCMS_FIND_QUIETLY)
+   else(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN)
+      if(NOT LCMS_FIND_QUIETLY)
+         message(STATUS "Found lcms but failed to find version ${LCMS_LIBRARIES}")
+         file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+            "Find lcms version failed with the following output:\n${OUTPUT}\nFindLCMS.cxx:\n${FIND_LCMS_VERSION_SOURCE}\n\n")
+      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 "Required package lcms NOT found")
+      else(LCMS_FIND_REQUIRED)
+         message(STATUS "lcms NOT found")
+      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})


More information about the poppler mailing list