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>
30 # Redistribution and use is allowed according to the terms of the BSD license.
31 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
33 IF (NOT _macroLogFeatureAlreadyIncluded)
34 SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
37 ENDIF (EXISTS ${_file})
39 SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
42 ENDIF (EXISTS ${_file})
44 SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
47 ENDIF (EXISTS ${_file})
49 SET(_macroLogFeatureAlreadyIncluded TRUE)
50 ENDIF (NOT _macroLogFeatureAlreadyIncluded)
53 MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments)
55 SET(_required "${ARGV4}")
56 SET(_minvers "${ARGV5}")
57 SET(_comments "${ARGV6}")
60 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
62 IF (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
63 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
64 ELSE (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
65 SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
66 ENDIF (${_required} MATCHES "[Tt][Rr][Uu][Ee]")
69 SET(_logtext "+ ${_package}")
72 IF (${_minvers} MATCHES ".*")
73 SET(_logtext "${_logtext}, ${_minvers}")
74 ENDIF (${_minvers} MATCHES ".*")
75 SET(_logtext "${_logtext}: ${_description} <${_url}>")
76 IF (${_comments} MATCHES ".*")
77 SET(_logtext "${_logtext}\n${_comments}")
78 ENDIF (${_comments} MATCHES ".*")
79 # SET(_logtext "${_logtext}\n") #double-space missing features?
81 FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n")
83 ENDMACRO(MACRO_LOG_FEATURE)
86 MACRO(MACRO_DISPLAY_FEATURE_LOG)
88 SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
90 FILE(READ ${_file} _requirements)
91 MESSAGE(STATUS "\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- Please install them before continuing this software installation.\n-----------------------------------------------------------------------------\n${_requirements}-----------------------------------------------------------------------------")
93 MESSAGE(FATAL_ERROR "Exiting: Missing Requirements")
94 ENDIF (EXISTS ${_file})
99 SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
102 FILE(READ ${_file} _enabled)
103 FILE(REMOVE ${_file})
104 SET(_summary "${_summary}-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n${_enabled}")
105 ENDIF (EXISTS ${_file})
108 SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
111 FILE(READ ${_file} _disabled)
112 FILE(REMOVE ${_file})
113 SET(_summary "${_summary}-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n${_disabled}")
114 ELSE (EXISTS ${_file})
116 SET(_summary "${_summary}Congratulations! All external packages have been found.\n")
118 ENDIF (EXISTS ${_file})
120 IF (${_elist} OR ${_dlist})
121 SET(_summary "${_summary}-----------------------------------------------------------------------------\n")
122 ENDIF (${_elist} OR ${_dlist})
123 MESSAGE(STATUS "${_summary}")
125 ENDMACRO(MACRO_DISPLAY_FEATURE_LOG)