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 feature 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)
52
INCLUDE(FeatureSummary)
54
ENDIF (NOT _macroLogFeatureAlreadyIncluded)
57
MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments)
59
STRING(TOUPPER "${ARGV4}" _required)
60
SET(_minvers "${ARGV5}")
61
SET(_comments "${ARGV6}")
64
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
66
IF ("${_required}" STREQUAL "TRUE")
67
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
68
ELSE ("${_required}" STREQUAL "TRUE")
69
SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
70
ENDIF ("${_required}" STREQUAL "TRUE")
73
SET(_logtext " * ${_package}")
76
IF (${_minvers} MATCHES ".*")
77
SET(_logtext "${_logtext} (${_minvers} or higher)")
78
ENDIF (${_minvers} MATCHES ".*")
79
SET(_logtext "${_logtext} <${_url}>\n ")
81
SET(_logtext "${_logtext} - ")
84
SET(_logtext "${_logtext}${_description}")
87
IF (${_comments} MATCHES ".*")
88
SET(_logtext "${_logtext}\n ${_comments}")
89
ENDIF (${_comments} MATCHES ".*")
90
# SET(_logtext "${_logtext}\n") #double-space missing features?
93
FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n")
95
IF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3
96
SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"")
97
ENDIF(COMMAND SET_PACKAGE_INFO)
99
ENDMACRO(MACRO_LOG_FEATURE)
102
MACRO(MACRO_DISPLAY_FEATURE_LOG)
103
IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3
104
FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt
106
ENDIF(COMMAND FEATURE_SUMMARY)
108
SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
109
SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
110
SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
112
IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
113
SET(_printSummary TRUE)
114
ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
118
IF (EXISTS ${_enabledFile})
119
FILE(READ ${_enabledFile} _enabled)
120
FILE(REMOVE ${_enabledFile})
121
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}")
122
ENDIF (EXISTS ${_enabledFile})
125
IF (EXISTS ${_disabledFile})
127
FILE(READ ${_disabledFile} _disabled)
128
FILE(REMOVE ${_disabledFile})
129
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}")
130
ENDIF (EXISTS ${_disabledFile})
133
IF (EXISTS ${_missingFile})
135
FILE(READ ${_missingFile} _requirements)
136
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}")
137
FILE(REMOVE ${_missingFile})
138
SET(_haveMissingReq 1)
139
ENDIF (EXISTS ${_missingFile})
142
IF (NOT ${_missingDeps})
143
SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.")
144
ENDIF (NOT ${_missingDeps})
148
MESSAGE("-----------------------------------------------------------------------------\n")
152
MESSAGE(FATAL_ERROR "Exiting: Missing Requirements")
153
ENDIF(_haveMissingReq)
157
ENDMACRO(MACRO_DISPLAY_FEATURE_LOG)