summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-18 17:26:02 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-18 17:26:02 (GMT)
commite118a62709fdc84e6c5b5b8d0bb055895d206ec9 (patch)
tree20e404d46f0b10d66af046e53f8af0843d88a6cc
parentff9ed18dad7281c074ce80befa47d7d510d4476b (diff)
downloadCMake-e118a62709fdc84e6c5b5b8d0bb055895d206ec9.zip
CMake-e118a62709fdc84e6c5b5b8d0bb055895d206ec9.tar.gz
CMake-e118a62709fdc84e6c5b5b8d0bb055895d206ec9.tar.bz2
ENH: add a macro FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
which handles the required and QUIET arguments and sets <NAME>_FOUND Alex
-rw-r--r--Modules/CMakeLists.txt2
-rw-r--r--Modules/FindLibXml2.cmake18
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake44
-rw-r--r--Modules/FindPythonLibs.cmake5
4 files changed, 54 insertions, 15 deletions
diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt
index c575043..01e2595 100644
--- a/Modules/CMakeLists.txt
+++ b/Modules/CMakeLists.txt
@@ -1,5 +1,5 @@
# just install the modules
-# new file added, force rerunning cmake #
+# new file added, force rerunning cmake
SUBDIRS(Platform)
INSTALL_FILES(${CMAKE_DATA_DIR}/Modules .*\\.cmake$)
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index 47136df..93507e6 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -36,21 +36,11 @@ FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
${_LibXml2LinkDir}
)
-IF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
- SET(LIBXML2_FOUND TRUE)
-ELSE (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
- SET(LIBXML2_FOUND FALSE)
-ENDIF (LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES)
+INCLUDE(FindPackageHandleStandardArgs)
-IF (LIBXML2_FOUND)
- IF (NOT LibXml2_FIND_QUIETLY)
- MESSAGE(STATUS "Found LibXml2: ${LIBXML2_LIBRARIES}")
- ENDIF (NOT LibXml2_FIND_QUIETLY)
-ELSE (LIBXML2_FOUND)
- IF (LibXml2_FIND_REQUIRED)
- MESSAGE(SEND_ERROR "Could NOT find LibXml2")
- ENDIF (LibXml2_FIND_REQUIRED)
-ENDIF (LIBXML2_FOUND)
+# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
+# all listed variables are TRUE
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES)
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
new file mode 100644
index 0000000..dcb9ff4
--- /dev/null
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -0,0 +1,44 @@
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME VAR ... )
+# This macro is intended to be used in FindXXX.cmake modules files.
+# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
+# it also sets the <UPPERCASED_NAME>_FOUND variable.
+# The package is found if all variables listed are TRUE.
+# Example:
+#
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
+#
+# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
+# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set tto TRUE.
+# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
+# independent whether QUIET was used or not.
+# If it is found, the location is reported using the VAR argument, so
+# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
+
+MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _VAR1 )
+ STRING(TOUPPER ${_NAME} _NAME_UPPER)
+
+ SET(${_NAME_UPPER}_FOUND TRUE)
+ IF(NOT ${_VAR1})
+ SET(${_NAME_UPPER}_FOUND FALSE)
+ ENDIF(NOT ${_VAR1})
+
+ FOREACH(_CURRENT_VAR ${ARGN})
+ IF(NOT ${_CURRENT_VAR})
+ SET(${_NAME_UPPER}_FOUND FALSE)
+ ENDIF(NOT ${_CURRENT_VAR})
+ ENDFOREACH(_CURRENT_VAR)
+
+ IF (${_NAME_UPPER}_FOUND)
+ IF (NOT ${_NAME}_FIND_QUIETLY)
+ MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
+ ENDIF (NOT ${_NAME}_FIND_QUIETLY)
+ ELSE (${_NAME_UPPER}_FOUND)
+ IF (${_NAME}_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could NOT find ${_NAME}")
+ ELSE (${_NAME}_FIND_REQUIRED)
+ IF (NOT ${_NAME}_FIND_QUIETLY)
+ MESSAGE(STATUS "Could NOT find ${_NAME}")
+ ENDIF (NOT ${_NAME}_FIND_QUIETLY)
+ ENDIF (${_NAME}_FIND_REQUIRED)
+ ENDIF (${_NAME_UPPER}_FOUND)
+ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 3c07225..9e9b7d0 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -3,6 +3,7 @@
# include files and libraries are. It also determines what the name of
# the library is. This code sets the following variables:
#
+# PYTHONLIBS_FOUND = have the Python libs been found
# PYTHON_LIBRARIES = path to the python library
# PYTHON_INCLUDE_PATH = path to where Python.h is found
# PYTHON_DEBUG_LIBRARIES = path to the debug library
@@ -136,3 +137,7 @@ ENDIF(Python_FRAMEWORKS)
# module.
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
+
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs PYTHON_LIBRARIES PYTHON_INCLUDE_PATH)