[poppler] cmake/modules

Pino Toscano pino at kemper.freedesktop.org
Sun Oct 17 05:59:11 PDT 2010


 cmake/modules/MacroOptionalFindPackage.cmake |   40 ++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 10 deletions(-)

New commits:
commit 71ec4c7a6715a40d536d1e4b911dae48d1bba7b9
Author: Pino Toscano <pino at kde.org>
Date:   Sun Oct 17 14:57:43 2010 +0200

    [CMake] update MacroOptionalFindPackage.cmake from KDE SVN
    
    no radical changes, just a minor improvement for the "explicitly disabled" case

diff --git a/cmake/modules/MacroOptionalFindPackage.cmake b/cmake/modules/MacroOptionalFindPackage.cmake
index 816cdb7..d4ed48e 100644
--- a/cmake/modules/MacroOptionalFindPackage.cmake
+++ b/cmake/modules/MacroOptionalFindPackage.cmake
@@ -7,22 +7,42 @@
 # The standard <name>_FOUND variables can be used in the same way
 # as when using the normal FIND_PACKAGE()
 
-# Copyright (c) 2006, Alexander Neundorf, <neundorf at kde.org>
+# Copyright (c) 2006-2010 Alexander Neundorf, <neundorf at kde.org>
 #
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
+# This is just a helper macro to set a bunch of variables empty.
+# We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both:
+macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var)
+   if(DEFINED ${_name}_${_var})
+      set(${_name}_${_var} "")
+   endif(DEFINED ${_name}_${_var})
 
-MACRO (MACRO_OPTIONAL_FIND_PACKAGE _name )
-   OPTION(WITH_${_name} "Search for ${_name} package" ON)
+   string(TOUPPER ${_name} _nameUpper)
+   if(DEFINED ${_nameUpper}_${_var})
+      set(${_nameUpper}_${_var}  "")
+   endif(DEFINED ${_nameUpper}_${_var})
+endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var)
+
+
+macro (MACRO_OPTIONAL_FIND_PACKAGE _name )
+   option(WITH_${_name} "Search for ${_name} package" ON)
    if (WITH_${_name})
-      FIND_PACKAGE(${_name} ${ARGN})
+      find_package(${_name} ${ARGN})
    else (WITH_${_name})
-      set(${_name}_FOUND)
-      set(${_name}_INCLUDE_DIR)
-      set(${_name}_INCLUDES)
-      set(${_name}_LIBRARY)
-      set(${_name}_LIBRARIES)
+      string(TOUPPER ${_name} _nameUpper)
+      set(${_name}_FOUND FALSE)
+      set(${_nameUpper}_FOUND FALSE)
+
+      _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS)
+      _mofp_set_empty_if_defined(${_name} INCLUDE_DIR)
+      _mofp_set_empty_if_defined(${_name} INCLUDES)
+      _mofp_set_empty_if_defined(${_name} LIBRARY)
+      _mofp_set_empty_if_defined(${_name} LIBRARIES)
+      _mofp_set_empty_if_defined(${_name} LIBS)
+      _mofp_set_empty_if_defined(${_name} FLAGS)
+      _mofp_set_empty_if_defined(${_name} DEFINITIONS)
    endif (WITH_${_name})
-ENDMACRO (MACRO_OPTIONAL_FIND_PACKAGE)
+endmacro (MACRO_OPTIONAL_FIND_PACKAGE)
 


More information about the poppler mailing list