aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2006-01-31 20:23:33 +0000
committerAlexander Neundorf <neundorf@kde.org>2006-01-31 20:23:33 +0000
commitff3c21d2e0fe6b0accd73fa0dd54ac881a7c3fbe (patch)
treeb2c71be9b7b8e8e49c306887969d7ff46be3c163
parent85fb81dd64b58d3ce6c4a581e3057bb99732b2a5 (diff)
downloadextra-cmake-modules-ff3c21d2e0fe6b0accd73fa0dd54ac881a7c3fbe.tar.gz
extra-cmake-modules-ff3c21d2e0fe6b0accd73fa0dd54ac881a7c3fbe.tar.bz2
new cmake macro OptionalFindPackage.cmake featuring the new command optional_find_package(<name>)
e.g. optional_find_package( ZLIB) is the same as option(WITH_ZLIB "Search for ZLIB package" ON) if (WITH_ZLIB) find_package(ZLIB) endif (WITH_ZLIB) This has the effect that all packages which are searched using this new command can be manually disabled using "cmake <dir> -DWITH_<name>=OFF" (or using the cmake GUI) This can be used to disable a package although it exists on the system. The result <name>_FOUND can be used as usual with find_package() for further testing in the CMakeLists.txt Alex CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=504336 The following changes were in SVN, but were removed from git: M pics/CMakeLists.txt
-rw-r--r--modules/OptionalFindPackage.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/OptionalFindPackage.cmake b/modules/OptionalFindPackage.cmake
new file mode 100644
index 00000000..2642a993
--- /dev/null
+++ b/modules/OptionalFindPackage.cmake
@@ -0,0 +1,16 @@
+# - OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION()
+# OPTIONAL_FIND_PACKAGE( <name> [QUIT] )
+# This macro is a combination of OPTION() and FIND_PACKAGE(), it
+# works like FIND_PACKAGE(), but additionally it automatically creates
+# an option name WITH_<name>, which can be disabled via the cmake GUI.
+# or via -DWITH_<name>=OFF
+# The standard <name>_FOUND variables can be used in the same way
+# as when using the normal FIND_PACKAGE()
+
+MACRO(OPTIONAL_FIND_PACKAGE _name )
+ OPTION(WITH_${_name} "Search for ${_name} package" ON)
+ IF (WITH_${_name})
+ FIND_PACKAGE(${_name} ${ARGN})
+ ENDIF (WITH_${_name})
+ENDMACRO(OPTIONAL_FIND_PACKAGE)
+