From ff3c21d2e0fe6b0accd73fa0dd54ac881a7c3fbe Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 31 Jan 2006 20:23:33 +0000 Subject: new cmake macro OptionalFindPackage.cmake featuring the new command optional_find_package() 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 -DWITH_=OFF" (or using the cmake GUI) This can be used to disable a package although it exists on the system. The result _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 --- modules/OptionalFindPackage.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/OptionalFindPackage.cmake (limited to 'modules/OptionalFindPackage.cmake') 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( [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_, which can be disabled via the cmake GUI. +# or via -DWITH_=OFF +# The standard _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) + -- cgit v1.2.1