summaryrefslogtreecommitdiffstats
path: root/Modules/FindPackageHandleStandardArgs.cmake
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-23 13:49:52 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-23 13:49:52 (GMT)
commit13db5b578ba81a72461e6d08a3b86ea698a7a0a0 (patch)
tree3bae5b3bf68b79788347c8ac00261cfcafc319b7 /Modules/FindPackageHandleStandardArgs.cmake
parentdddbad259c5d497987cbb367ce184f3953f2f137 (diff)
downloadCMake-13db5b578ba81a72461e6d08a3b86ea698a7a0a0.zip
CMake-13db5b578ba81a72461e6d08a3b86ea698a7a0a0.tar.gz
CMake-13db5b578ba81a72461e6d08a3b86ea698a7a0a0.tar.bz2
ENH: add second failure message parameter to
FIND_PACKAGE_HANDLE_STANDARD_ARGS(), so cmake modules can specify their own better failure messages. If the default is ok use "DEFAULT_MSG". Do this also for FindBoost.cmake (#5349) Alex
Diffstat (limited to 'Modules/FindPackageHandleStandardArgs.cmake')
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake22
1 files changed, 16 insertions, 6 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
index dcb9ff4..3f5156c 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -1,20 +1,30 @@
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME VAR ... )
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
# 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)
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG 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
+# If it is found, the location is reported using the VAR1 argument, so
# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
+# If the second argument is DEFAULT_MSG, the message in the failure case will
+# be "Could NOT find LibXml2", if you don't like this message you can specify
+# your own custom failure message there.
+
+MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
+
+ IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+ SET(_FAIL_MESSAGE "Could NOT find ${_NAME}")
+ ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+ SET(_FAIL_MESSAGE "${_FAIL_MSG}")
+ ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
-MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _VAR1 )
STRING(TOUPPER ${_NAME} _NAME_UPPER)
SET(${_NAME_UPPER}_FOUND TRUE)
@@ -34,10 +44,10 @@ MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _VAR1 )
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ELSE (${_NAME_UPPER}_FOUND)
IF (${_NAME}_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could NOT find ${_NAME}")
+ MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
- MESSAGE(STATUS "Could NOT find ${_NAME}")
+ MESSAGE(STATUS "${_FAIL_MESSAGE}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
ENDIF (${_NAME_UPPER}_FOUND)