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
This commit is contained in:
Alexander Neundorf 2007-07-18 13:26:02 -04:00
parent ff9ed18dad
commit e118a62709
4 changed files with 54 additions and 15 deletions

View File

@ -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$)

View File

@ -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)

View File

@ -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)

View File

@ -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)