diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-07-18 17:26:02 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-07-18 17:26:02 (GMT) |
commit | e118a62709fdc84e6c5b5b8d0bb055895d206ec9 (patch) | |
tree | 20e404d46f0b10d66af046e53f8af0843d88a6cc /Modules/FindPackageHandleStandardArgs.cmake | |
parent | ff9ed18dad7281c074ce80befa47d7d510d4476b (diff) | |
download | CMake-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
Diffstat (limited to 'Modules/FindPackageHandleStandardArgs.cmake')
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
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) |