diff options
author | Brad King <brad.king@kitware.com> | 2008-03-17 15:10:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-03-17 15:10:42 (GMT) |
commit | 7a888b68daa674690088f0beaf1a83fa8e409138 (patch) | |
tree | bc21d74ec3f7bcf2ceba288da2cf0610f5fcfff1 | |
parent | 98e06794dd2b4554e1fc82314edc9a5c7a232d7d (diff) | |
download | CMake-7a888b68daa674690088f0beaf1a83fa8e409138.zip CMake-7a888b68daa674690088f0beaf1a83fa8e409138.tar.gz CMake-7a888b68daa674690088f0beaf1a83fa8e409138.tar.bz2 |
ENH: Added FindPackageMessage module
- Defines FIND_PACKAGE_MESSAGE function to help display
find result messages only once
- Added use of it to FindPackageHandleStandardArgs
- Added use of it to FindQt4, and FindX11
- This cleans up repeated messages in big projects
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 10 | ||||
-rw-r--r-- | Modules/FindPackageMessage.cmake | 35 | ||||
-rw-r--r-- | Modules/FindQt4.cmake | 6 | ||||
-rw-r--r-- | Modules/FindX11.cmake | 6 |
4 files changed, 50 insertions, 7 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 20d830c..091954f 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -17,6 +17,7 @@ # be "Could NOT find LibXml2", if you don't like this message you can specify # your own custom failure message there. +INCLUDE(FindPackageMessage) FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") @@ -27,22 +28,25 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) STRING(TOUPPER ${_NAME} _NAME_UPPER) + SET(DETAILS "") SET(${_NAME_UPPER}_FOUND TRUE) IF(NOT ${_VAR1}) SET(${_NAME_UPPER}_FOUND FALSE) + ELSE(NOT ${_VAR1}) + SET(DETAILS "${DETAILS}[${${_VAR1}}]") ENDIF(NOT ${_VAR1}) # check if all passed variables are valid FOREACH(_CURRENT_VAR ${ARGN}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) + ELSE(NOT ${_CURRENT_VAR}) + SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") 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) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_VAR1}}" "${DETAILS}") ELSE (${_NAME_UPPER}_FOUND) IF (${_NAME}_FIND_REQUIRED) MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}") diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake new file mode 100644 index 0000000..1106e0e --- /dev/null +++ b/Modules/FindPackageMessage.cmake @@ -0,0 +1,35 @@ +# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details") +# +# This macro is intended to be used in FindXXX.cmake modules files. +# It will print a message once for each unique find result. +# This is useful for telling the user where a package was found. +# The first argument specifies the name (XXX) of the package. +# The second argument specifies the message to display. +# The third argument lists details about the find result so that +# if they change the message will be displayed again. +# The macro also obeys the QUIET argument to the find_package command. +# +# Example: +# +# IF(X11_FOUND) +# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" +# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") +# ELSE(X11_FOUND) +# ... +# ENDIF(X11_FOUND) + +FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) + # Avoid printing a message repeatedly for the same find result. + IF(NOT ${pkg}_FIND_QUIETLY) + SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) + IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + # The message has not yet been printed. + MESSAGE(STATUS "${msg}") + + # Save the find details in the cache to avoid printing the same + # message again. + SET("${DETAILS_VAR}" "${details}" + CACHE INTERNAL "Details about finding ${pkg}") + ENDIF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + ENDIF(NOT ${pkg}_FIND_QUIETLY) +ENDFUNCTION(FIND_PACKAGE_MESSAGE) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index bd19027..663ff54 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1232,9 +1232,9 @@ IF (QT4_QMAKE_FOUND) # if the includes,libraries,moc,uic and rcc are found then we have it IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET( QT4_FOUND "YES" ) - IF( NOT Qt4_FIND_QUIETLY) - MESSAGE(STATUS "Found Qt-Version ${QTVERSION}") - ENDIF( NOT Qt4_FIND_QUIETLY) + INCLUDE(FindPackageMessage) + FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}" + "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]") ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET( QT4_FOUND "NO") SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index e5fff88..f3e8807 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -127,6 +127,7 @@ IF (UNIX) GET_FILENAME_COMPONENT(X11_LIBRARY_DIR ${X11_X11_LIB} PATH) ENDIF(X11_X11_LIB) + SET(X11_INCLUDE_DIR) # start with empty list IF(X11_X11_INCLUDE_PATH) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH}) ENDIF(X11_X11_INCLUDE_PATH) @@ -145,6 +146,7 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xshape_INCLUDE_PATH}) ENDIF(X11_Xshape_INCLUDE_PATH) + SET(X11_LIBRARIES) # start with empty list IF(X11_X11_LIB) SET(X11_LIBRARIES ${X11_LIBRARIES} ${X11_X11_LIB}) ENDIF(X11_X11_LIB) @@ -354,7 +356,9 @@ IF (UNIX) # Build the final list of libraries. SET(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS}) - MESSAGE(STATUS "Found X11: ${X11_X11_LIB}") + INCLUDE(FindPackageMessage) + FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" + "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") ELSE (X11_FOUND) IF (X11_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find X11") |