1 # This file defines the Feature Logging macros.
3 # MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]])
4 # Logs the information so that it can be displayed at the end
6 # VAR : TRUE or FALSE, indicating whether the feature is supported
7 # FEATURE: name of the feature, e.g. "libjpeg"
8 # DESCRIPTION: description what this feature provides
10 # REQUIRED: TRUE or FALSE, indicating whether the featue is required
11 # MIN_VERSION: minimum version number. empty string if unneeded
12 # COMMENTS: More info you may want to provide. empty string if unnecessary
14 # MACRO_DISPLAY_FEATURE_LOG()
15 # Call this to display the collected results.
16 # Exits CMake with a FATAL error message if a required feature is missing
20 # INCLUDE(MacroLogFeature)
23 # MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "")
25 # MACRO_DISPLAY_FEATURE_LOG()
27 # Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
28 # Copyright (c) 2006, Allen Winter, <winter@kde.org>
29 # Copyright (c) 2009, Sebastian Trueg, <trueg@kde.org>
31 # Redistribution and use is allowed according to the terms of the BSD license.
32 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
34 IF (NOT _macroLogFeatureAlreadyIncluded)
35 SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
38 ENDIF (EXISTS ${_file})
40 SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
43 ENDIF (EXISTS ${_file})
45 SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
48 ENDIF (EXISTS ${_file})
50 SET(_macroLogFeatureAlreadyIncluded TRUE)
51 ENDIF (NOT _macroLogFeatureAlreadyIncluded)
54 MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments)
56 STRING(TOUPPER "${ARGV4}" _required)
57 SET(_minvers "${ARGV5}")
58 SET(_comments "${ARGV6}")
61 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
63 IF ("${_required}" STREQUAL "TRUE")
64 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
65 ELSE ("${_required}" STREQUAL "TRUE")
66 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
67 ENDIF ("${_required}" STREQUAL "TRUE")
70 SET(_logtext " * ${_package}")
73 IF (${_minvers} MATCHES ".*")
74 SET(_logtext "${_logtext} (${_minvers} or higher)")
75 ENDIF (${_minvers} MATCHES ".*")
76 SET(_logtext "${_logtext} <${_url}>\n ")
78 SET(_logtext "${_logtext} - ")
81 SET(_logtext "${_logtext}${_description}")
84 IF (${_comments} MATCHES ".*")
85 SET(_logtext "${_logtext}\n ${_comments}")
86 ENDIF (${_comments} MATCHES ".*")
87 # SET(_logtext "${_logtext}\n") #double-space missing features?
90 FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n")
92 ENDMACRO(MACRO_LOG_FEATURE)
95 MACRO(MACRO_DISPLAY_FEATURE_LOG)
97 SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
98 SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
99 SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
101 IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
102 SET(_printSummary TRUE)
103 ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
107 IF (EXISTS ${_enabledFile})
108 FILE(READ ${_enabledFile} _enabled)
109 FILE(REMOVE ${_enabledFile})
110 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}")
111 ENDIF (EXISTS ${_enabledFile})
114 IF (EXISTS ${_disabledFile})
116 FILE(READ ${_disabledFile} _disabled)
117 FILE(REMOVE ${_disabledFile})
118 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}")
119 ENDIF (EXISTS ${_disabledFile})
122 IF (EXISTS ${_missingFile})
124 FILE(READ ${_missingFile} _requirements)
125 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}")
126 FILE(REMOVE ${_missingFile})
127 SET(_haveMissingReq 1)
128 ENDIF (EXISTS ${_missingFile})
131 IF (NOT ${_missingDeps})
132 SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.")
133 ENDIF (NOT ${_missingDeps})
137 MESSAGE("-----------------------------------------------------------------------------\n")
141 MESSAGE(FATAL_ERROR "Exiting: Missing Requirements")
142 ENDIF(_haveMissingReq)
146 ENDMACRO(MACRO_DISPLAY_FEATURE_LOG)