From 196ac0d99c043331605d360718cadf730369bd65 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Fri, 16 Apr 2010 21:21:06 +0200 Subject: [PATCH 2/3] Use macro_log_feature to display in a nice way all additional features instead of relying on custom messages --- CMakeLists.txt | 33 ++++++--- cmake/modules/MacroLogFeature.cmake | 146 +++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 cmake/modules/MacroLogFeature.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f16acf..094941c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ endif(NOT CMAKE_BUILD_TYPE) include(TelepathyDefaults) include(Doxygen) +include(MacroLogFeature) # external dependencies @@ -58,6 +59,10 @@ int main() return 0; }" QT4_GLIB_SUPPORT) +macro_log_feature(QT4_GLIB_SUPPORT "Qt4 Glib Support" + "QtCore library using Glib's main event loop" + "http://qt.nokia.com/" FALSE "" + "Needed, together with Telepathy-Glib, to build some additional test cases") SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTDBUS_LIBRARY}) CHECK_CXX_SOURCE_COMPILES(" @@ -134,12 +139,14 @@ endif(${PYTHON_SHORT_VERSION} VERSION_GREATER ${REQUIRED_PY} OR ${PYTHON_SHORT_V execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import dbus.mainloop.glib" RESULT_VARIABLE PYTHON_DBUS_RESULT) if(PYTHON_DBUS_RESULT EQUAL 0) - message(STATUS "dbus-python installed, running additional tests") set(HAVE_TEST_PYTHON 1) else(PYTHON_DBUS_RESULT EQUAL 0) - message(STATUS "dbus-python not installed, skipping some tests") set(HAVE_TEST_PYTHON 0) endif(PYTHON_DBUS_RESULT EQUAL 0) +macro_log_feature(HAVE_TEST_PYTHON "dbus-python" + "GLib-based Python DBus support" + "http://www.python.org/" FALSE "" + "Needed to build some additional test cases") # Find GLib2, DBus and LibXml2 # Those are needed for the insane include dir dependency hell @@ -150,31 +157,35 @@ find_package(LibXml2) # Find tp-farsight set(TELEPATHY_FARSIGHT_MIN_VERSION "0.0.4") find_package(TelepathyFarsight) +macro_log_feature(TELEPATHYFARSIGHT_FOUND "Telepathy-Farsight" + "A Framework for dealing with audio/video conferencing protocols" + "http://farsight.freedesktop.org/wiki/" FALSE "0.0.4" + "Needed, together with GStreamer, to build telepathy-qt4-farsight and some additional examples") find_package(GStreamer) +macro_log_feature(GSTREAMER_FOUND "GStreamer" + "An open source multimedia framework" + "Needed, together with Tp-Farsight, to build telepathy-qt4-farsight and some additional examples" + "http://www.gstreamer.net/" FALSE) if (TELEPATHYFARSIGHT_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND DBUS_FOUND AND LIBXML2_FOUND) set (FARSIGHT_COMPONENTS_FOUND 1) else (TELEPATHYFARSIGHT_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND DBUS_FOUND AND LIBXML2_FOUND) set (FARSIGHT_COMPONENTS_FOUND 0) endif (TELEPATHYFARSIGHT_FOUND AND GSTREAMER_FOUND AND GLIB2_FOUND AND DBUS_FOUND AND LIBXML2_FOUND) -if(FARSIGHT_COMPONENTS_FOUND) - message(STATUS "telepathy-farsight and gstreamer libraries found, building additional examples") -else(FARSIGHT_COMPONENTS_FOUND) - message(STATUS "telepathy-farsight or gstreamer libraries not found, not building some examples") -endif(FARSIGHT_COMPONENTS_FOUND) - # Find telepathy-glib set(TELEPATHY_GLIB_MIN_VERSION 0.10.0) find_package(TelepathyGlib) +macro_log_feature(TELEPATHYGLIB_FOUND "Telepathy-glib" + "Glib bindings for Telepathy" + "http://telepathy.freedesktop.org/" FALSE "0.10.0" + "Needed, together with Qt Glib integration, to build some additional test cases") find_program(GLIB_GENMARSHAL glib-genmarshal) # process results... if(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND) - message(STATUS "Qt4 compiled with Glib support and telepathy-glib >= ${TELEPATHY_GLIB_MIN_VERSION} found, running additional tests") set(ENABLE_TP_GLIB_TESTS 1) else(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND) - message(STATUS "Qt4 not compiled with Glib support or telepathy-glib >= ${TELEPATHY_GLIB_MIN_VERSION} not found, skipping some tests") set(ENABLE_TP_GLIB_TESTS 0) endif(QT4_GLIB_SUPPORT AND TELEPATHYGLIB_FOUND AND GLIB2_FOUND AND DBUS_FOUND) @@ -191,3 +202,5 @@ configure_file( add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + +macro_display_feature_log() diff --git a/cmake/modules/MacroLogFeature.cmake b/cmake/modules/MacroLogFeature.cmake new file mode 100644 index 0000000..86e1c3c --- /dev/null +++ b/cmake/modules/MacroLogFeature.cmake @@ -0,0 +1,146 @@ +# This file defines the Feature Logging macros. +# +# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) +# Logs the information so that it can be displayed at the end +# of the configure run +# VAR : TRUE or FALSE, indicating whether the feature is supported +# FEATURE: name of the feature, e.g. "libjpeg" +# DESCRIPTION: description what this feature provides +# URL: home page +# REQUIRED: TRUE or FALSE, indicating whether the featue is required +# MIN_VERSION: minimum version number. empty string if unneeded +# COMMENTS: More info you may want to provide. empty string if unnecessary +# +# MACRO_DISPLAY_FEATURE_LOG() +# Call this to display the collected results. +# Exits CMake with a FATAL error message if a required feature is missing +# +# Example: +# +# INCLUDE(MacroLogFeature) +# +# FIND_PACKAGE(JPEG) +# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") +# ... +# MACRO_DISPLAY_FEATURE_LOG() + +# Copyright (c) 2006, Alexander Neundorf, +# Copyright (c) 2006, Allen Winter, +# Copyright (c) 2009, Sebastian Trueg, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +IF (NOT _macroLogFeatureAlreadyIncluded) + SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_macroLogFeatureAlreadyIncluded TRUE) +ENDIF (NOT _macroLogFeatureAlreadyIncluded) + + +MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) + + STRING(TOUPPER "${ARGV4}" _required) + SET(_minvers "${ARGV5}") + SET(_comments "${ARGV6}") + + IF (${_var}) + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + ELSE (${_var}) + IF ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + ELSE ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + ENDIF ("${_required}" STREQUAL "TRUE") + ENDIF (${_var}) + + SET(_logtext " * ${_package}") + + IF (NOT ${_var}) + IF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} (${_minvers} or higher)") + ENDIF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} <${_url}>\n ") + ELSE (NOT ${_var}) + SET(_logtext "${_logtext} - ") + ENDIF (NOT ${_var}) + + SET(_logtext "${_logtext}${_description}") + + IF (NOT ${_var}) + IF (${_comments} MATCHES ".*") + SET(_logtext "${_logtext}\n ${_comments}") + ENDIF (${_comments} MATCHES ".*") +# SET(_logtext "${_logtext}\n") #double-space missing features? + ENDIF (NOT ${_var}) + + FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") + +ENDMACRO(MACRO_LOG_FEATURE) + + +MACRO(MACRO_DISPLAY_FEATURE_LOG) + + SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + + IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + SET(_printSummary TRUE) + ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + + IF(_printSummary) + SET(_missingDeps 0) + IF (EXISTS ${_enabledFile}) + FILE(READ ${_enabledFile} _enabled) + FILE(REMOVE ${_enabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n-----------------------------------------------------------------------------\n${_enabled}") + ENDIF (EXISTS ${_enabledFile}) + + + IF (EXISTS ${_disabledFile}) + SET(_missingDeps 1) + FILE(READ ${_disabledFile} _disabled) + FILE(REMOVE ${_disabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n-----------------------------------------------------------------------------\n${_disabled}") + ENDIF (EXISTS ${_disabledFile}) + + + IF (EXISTS ${_missingFile}) + SET(_missingDeps 1) + FILE(READ ${_missingFile} _requirements) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- You must install these packages before continuing.\n-----------------------------------------------------------------------------\n${_requirements}") + FILE(REMOVE ${_missingFile}) + SET(_haveMissingReq 1) + ENDIF (EXISTS ${_missingFile}) + + + IF (NOT ${_missingDeps}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.") + ENDIF (NOT ${_missingDeps}) + + + MESSAGE(${_summary}) + MESSAGE("-----------------------------------------------------------------------------\n") + + + IF(_haveMissingReq) + MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") + ENDIF(_haveMissingReq) + + ENDIF(_printSummary) + +ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) -- 1.7.0.6