summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2010-10-17 14:57:43 +0200
committerPino Toscano <pino@kde.org>2010-10-17 14:57:43 +0200
commit71ec4c7a6715a40d536d1e4b911dae48d1bba7b9 (patch)
tree4a6e49a871fadbbad147b2708dcf0529c5b4d319 /cmake
parentab0049d8be5dfe1989c4aa33c2732915c62fecb2 (diff)
[CMake] update MacroOptionalFindPackage.cmake from KDE SVN
no radical changes, just a minor improvement for the "explicitly disabled" case
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/MacroOptionalFindPackage.cmake40
1 files changed, 30 insertions, 10 deletions
diff --git a/cmake/modules/MacroOptionalFindPackage.cmake b/cmake/modules/MacroOptionalFindPackage.cmake
index 816cdb7e..d4ed48e3 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@kde.org>
+# Copyright (c) 2006-2010 Alexander Neundorf, <neundorf@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)