1 | # This file defines the Feature Logging macros. |
---|
2 | # |
---|
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 |
---|
5 | # of the configure run |
---|
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 |
---|
9 | # URL: home page |
---|
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 |
---|
13 | # |
---|
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 |
---|
17 | # |
---|
18 | # Example: |
---|
19 | # |
---|
20 | # INCLUDE(MacroLogFeature) |
---|
21 | # |
---|
22 | # FIND_PACKAGE(JPEG) |
---|
23 | # MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") |
---|
24 | # ... |
---|
25 | # MACRO_DISPLAY_FEATURE_LOG() |
---|
26 | |
---|
27 | # Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org> |
---|
28 | # Copyright (c) 2006, Allen Winter, <winter@kde.org> |
---|
29 | # |
---|
30 | # Redistribution and use is allowed according to the terms of the BSD license. |
---|
31 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
---|
32 | |
---|
33 | IF (NOT _macroLogFeatureAlreadyIncluded) |
---|
34 | SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) |
---|
35 | IF (EXISTS ${_file}) |
---|
36 | FILE(REMOVE ${_file}) |
---|
37 | ENDIF (EXISTS ${_file}) |
---|
38 | |
---|
39 | SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) |
---|
40 | IF (EXISTS ${_file}) |
---|
41 | FILE(REMOVE ${_file}) |
---|
42 | ENDIF (EXISTS ${_file}) |
---|
43 | |
---|
44 | SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) |
---|
45 | IF (EXISTS ${_file}) |
---|
46 | FILE(REMOVE ${_file}) |
---|
47 | ENDIF (EXISTS ${_file}) |
---|
48 | |
---|
49 | SET(_macroLogFeatureAlreadyIncluded TRUE) |
---|
50 | ENDIF (NOT _macroLogFeatureAlreadyIncluded) |
---|
51 | |
---|
52 | |
---|
53 | MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) |
---|
54 | |
---|
55 | SET(_required "${ARGV4}") |
---|
56 | SET(_minvers "${ARGV5}") |
---|
57 | SET(_comments "${ARGV6}") |
---|
58 | |
---|
59 | IF (${_var}) |
---|
60 | SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) |
---|
61 | ELSE (${_var}) |
---|
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]") |
---|
67 | ENDIF (${_var}) |
---|
68 | |
---|
69 | SET(_logtext "+ ${_package}") |
---|
70 | |
---|
71 | IF (NOT ${_var}) |
---|
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? |
---|
80 | ENDIF (NOT ${_var}) |
---|
81 | FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") |
---|
82 | |
---|
83 | ENDMACRO(MACRO_LOG_FEATURE) |
---|
84 | |
---|
85 | |
---|
86 | MACRO(MACRO_DISPLAY_FEATURE_LOG) |
---|
87 | |
---|
88 | SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) |
---|
89 | IF (EXISTS ${_file}) |
---|
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}-----------------------------------------------------------------------------") |
---|
92 | FILE(REMOVE ${_file}) |
---|
93 | MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") |
---|
94 | ENDIF (EXISTS ${_file}) |
---|
95 | |
---|
96 | SET(_summary "\n") |
---|
97 | |
---|
98 | SET(_elist 0) |
---|
99 | SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) |
---|
100 | IF (EXISTS ${_file}) |
---|
101 | SET(_elist 1) |
---|
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}) |
---|
106 | |
---|
107 | SET(_dlist 0) |
---|
108 | SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) |
---|
109 | IF (EXISTS ${_file}) |
---|
110 | SET(_dlist 1) |
---|
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}) |
---|
115 | IF (${_elist}) |
---|
116 | SET(_summary "${_summary}Congratulations! All external packages have been found.\n") |
---|
117 | ENDIF (${_elist}) |
---|
118 | ENDIF (EXISTS ${_file}) |
---|
119 | |
---|
120 | IF (${_elist} OR ${_dlist}) |
---|
121 | SET(_summary "${_summary}-----------------------------------------------------------------------------\n") |
---|
122 | ENDIF (${_elist} OR ${_dlist}) |
---|
123 | MESSAGE(STATUS "${_summary}") |
---|
124 | |
---|
125 | ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) |
---|