On Wednesday 23 of May 2012 19:46:33 Albert Astals Cid wrote:
> El Divendres, 18 de maig de 2012, a les 01:56:03, Maciej Mrozowski va
> 
> escriure:
> > Hello,
> > 
> > When both libcms1 and libcms2 are present, liblcms2 is automatically
> > selected with no way to override the choice. Patch adds the choice by the
> > means of ENABLE_LCMS2 option.
> 
> This doesn't work if you do not have lcms2 installed but have lcms
> installed right?
> Because it'll go throught the first
> if(ENABLE_LCMS2)  (because i don't have a clue if i have it or not)
> and then fail at
> find_package(LCMS2)
> and then don't look for LCMS1, no?

That's... correct.
I could fix it to match expected behaviour, but I may have a better idea, how 
about doing it the same way --enable-cms is handled:
- if -DENABLE_CMS=lcms1 then only look for liblcms1
- if -DENABLE_CMS=lcms2 then only look for liblcms2
- otherwise look for lcms2, if not found, then try lcms1 as fallback

-- 
regards
MM
From f3f7c225e3a4d96bc3937346391980aed3315527 Mon Sep 17 00:00:00 2001
From: Maciej Mrozowski <[email protected]>
Date: Fri, 18 May 2012 01:47:55 +0200
Subject: [PATCH] [Buildsystem] CMake: Provide ENABLE_CMS=[auto/lcms1/lcms2] option to distinguish between available liblcms implementations when both are present during configure phase. 'auto' (default) prefers lcms2. Autotools: add --enable-cms=[auto/lcms1/lcms2].

---
 CMakeLists.txt |   20 +++++++++++++-------
 configure.ac   |   31 +++++++++++++++----------------
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f4830b..a668b00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,7 @@ option(ENABLE_SPLASH "Build the Splash graphics backend." ON)
 option(ENABLE_UTILS "Compile poppler command line utils." ON)
 option(ENABLE_CPP "Compile poppler cpp wrapper." ON)
 option(ENABLE_LIBOPENJPEG "Use libopenjpeg for JPX streams." ON)
-option(ENABLE_LCMS "Use liblcms for color management." ON)
+set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available")
 option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF)
 option(ENABLE_ZLIB "Build with zlib (not totally safe)." OFF)
 option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF)
@@ -136,16 +136,22 @@ if(ENABLE_LIBOPENJPEG)
   set(ENABLE_LIBOPENJPEG ${LIBOPENJPEG_FOUND})
   set(HAVE_OPENJPEG_H ON)
 endif(ENABLE_LIBOPENJPEG)
-if(ENABLE_LCMS)
+if(ENABLE_CMS STREQUAL "lcms2")
   find_package(LCMS2)
-  if(LCMS2_FOUND)
-    set(USE_CMS ${LCMS2_FOUND})
-  else(LCMS2_FOUND)
+  set(USE_CMS ${LCMS2_FOUND})
+elseif(ENABLE_CMS STREQUAL "lcms1")
+  find_package(LCMS)
+  set(USE_CMS ${LCMS_FOUND})
+  set(USE_LCMS1 ${LCMS_FOUND})
+else(ENABLE_CMS STREQUAL "lcms2")
+  find_package(LCMS2)
+  set(USE_CMS ${LCMS2_FOUND})
+  if(NOT LCMS2_FOUND)
     find_package(LCMS)
     set(USE_CMS ${LCMS_FOUND})
     set(USE_LCMS1 ${LCMS_FOUND})
-  endif(LCMS2_FOUND)
-endif(ENABLE_LCMS)
+  endif(NOT LCMS2_FOUND)
+endif(ENABLE_CMS STREQUAL "lcms2")
 if(ENABLE_LIBCURL)
   find_package(CURL)
   include_directories(${CURL_INCLUDE_DIR})
diff --git a/configure.ac b/configure.ac
index f9919d9..cbf217d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -660,7 +660,7 @@ AC_ARG_ENABLE(utils,
 AM_CONDITIONAL(BUILD_UTILS, test x$enable_utils = xyes)
 
 AC_ARG_ENABLE(compile-warnings,
-              AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@]
+              AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@],
                              [Turn on compiler warnings.]),,
               [enable_compile_warnings="yes"])
 
@@ -669,31 +669,30 @@ dnl   Color Management
 dnl
 
 AC_ARG_ENABLE(cms,
-	      AC_HELP_STRING([--disable-cms],
-	                     [Don't use color management system.]),
-              enable_cms=$enableval,
-              enable_cms="try")
-if test x$enable_cms = xyes; then
+              AC_HELP_STRING([--enable-cms=@<:@auto/lcms1/lcms2@:>@],
+                             [Use color management system. 'auto' prefers lcms2 over lcms1 if both are available [[default=auto]]]),
+              [enable_cms=$enableval],
+              [enable_cms="auto"])
+if test x$enable_cms = xauto; then
   PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no])
   if test x$lcms2 = xno; then
-      PKG_CHECK_MODULES(LCMS, lcms)
-  fi
-elif test x$enable_cms = xtry; then
-  PKG_CHECK_MODULES(LCMS, lcms2,[lcms2=yes],[lcms2=no])
-  if test x$lcms2 = xyes; then
-    enable_cms=yes
-  else
-      PKG_CHECK_MODULES(LCMS, lcms,[enable_cms=yes],[enable_cms=no])
+      PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no])
   fi
+elif test x$enable_cms = xlcms1; then
+  PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no])
+elif test x$enable_cms = xlcms2; then
+  PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no])
 fi
 
-if test "x$enable_cms" = "xyes"; then
+if test x$lcms1 = xyes || test x$lcms2 = xyes; then
+  enable_cms=yes
   AC_DEFINE(USE_CMS, 1, [Defines if use cms])
-  if test "x$lcms2" != "xyes"; then
+  if test x$lcms1 = xyes; then
     lcms1=yes;
     AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1])
   fi
 fi
+
 AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes)
 AM_CONDITIONAL(USE_LCMS1, test x$lcms1 = xyes)
 
-- 
1.7.3.4

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to