21
21
#
22
22
# ############################################################################
23
23
24
- string (ASCII 27 Esc)
25
- set (Red "${Esc} [31m" )
26
- set (Green "${Esc} [32m" )
27
- set (Yellow "${Esc} [33m" )
28
- set (ResetFG "${Esc} [39m" )
24
+ string (ASCII 27 Esc)
25
+ set (Red "${Esc} [31m" )
26
+ set (Green "${Esc} [32m" )
27
+ set (Yellow "${Esc} [33m" )
28
+ set (Blue "${Esc} [34m" )
29
+ set (ResetFG "${Esc} [39m" )
30
+
31
+ set (_maxHeaderLen 39)
32
+
33
+ list (APPEND _envInfo "CMAKE_HOST_SYSTEM" "CMAKE_HOST_SYSTEM_NAME" "CMAKE_HOST_SYSTEM_PROCESSOR" "CMAKE_HOST_SYSTEM_VERSION" )
34
+ list (APPEND _subModules "IVYKIS_SOURCE" )
35
+ list (APPEND _compilersInfo "CMAKE_C_COMPILER" "CMAKE_CXX_COMPILER" "CMAKE_OBJC_COMPILER" )
36
+ list (APPEND _compilationsOptions "CMAKE_BUILD_TYPE" "BUILD_TESTING" "ENABLE_EXTRA_WARNINGS" )
37
+ if (APPLE )
38
+ list (APPEND _compilationsOptions "FORCE_CLASSIC_LINKING" )
39
+ endif ()
40
+
41
+ option (SUMMARY_LEVEL "Detail level of the cmake options summary information (0,1 or 2)" 0)
29
42
30
43
function (_space_tabbed_string _variableName _maxVarNameLen _outputVariable)
31
44
set (_spaces "" )
@@ -38,7 +51,7 @@ function(_space_tabbed_string _variableName _maxVarNameLen _outputVariable)
38
51
set (_variableNameLen 0)
39
52
endif ()
40
53
41
- string (REPEAT " " ${_variableNameLen} _spaces)
54
+ string (REPEAT " " ${_variableNameLen} _spaces)
42
55
endif ()
43
56
44
57
set (${_outputVariable} "${_variableName}${_spaces} " PARENT_SCOPE)
@@ -57,12 +70,25 @@ function(_print_summary_line _variableName _variableValue _maxVarNameLen)
57
70
elseif (_upperValue STREQUAL "OFF" OR _upperValue STREQUAL "FALSE" )
58
71
message ("${_spaceTabbedVariableName}${Red} Off${ResetFG} " )
59
72
else ()
60
- message ("${_spaceTabbedVariableName}${Green }${_variableValue}${ResetFG} " )
73
+ message ("${_spaceTabbedVariableName}${Blue }${_variableValue}${ResetFG} " )
61
74
endif ()
62
75
endfunction ()
63
76
64
- function (_print_separator)
65
- message (NOTICE "-----------------------------------" )
77
+ function (_print_separator _header)
78
+ string (LENGTH "${_header} " _headerLen)
79
+ if (_headerLen LESS_EQUAL 0)
80
+ string (REPEAT "-" ${_maxHeaderLen} _header)
81
+ else ()
82
+ math (EXPR _headerSeparatorLen "(${_maxHeaderLen} - ${_headerLen} - 2) / 2" )
83
+ math (EXPR _total_len "((${_headerSeparatorLen} * 2) + ${_headerLen} + 2)" )
84
+ set (_padding "" )
85
+ if (_total_len LESS ${_maxHeaderLen} )
86
+ set (_padding "-" )
87
+ endif ()
88
+ string (REPEAT "-" ${_headerSeparatorLen} _headerSeparator)
89
+ set (_header "${_headerSeparator} ${_header} ${_headerSeparator}${_padding} " )
90
+ endif ()
91
+ message (NOTICE "${_header} " )
66
92
endfunction ()
67
93
68
94
function (_print_libraries _variableNames)
@@ -72,36 +98,40 @@ function(_print_libraries _variableNames)
72
98
string (REGEX MATCH ".*(INCLUDE_DIR|INCLUDEDIR|INCLUDE_DIRS|INCLUDE_OPTS)$" _match_incl "${_variableName} " )
73
99
string (REGEX MATCH "^(CMAKE_|_).*" _cmakeInternal "${_variableName} " )
74
100
75
- if ((_match_lib OR _match_incl OR _match_found) AND NOT _cmakeInternal)
101
+ if ((_match_lib OR _match_incl OR _match_found) AND NOT _cmakeInternal)
76
102
_print_summary_line("${_variableName} =" "${${_variableName} }" 0)
77
103
endif ()
78
104
endforeach ()
79
105
endfunction ()
80
106
81
- function (_print_importants _variableNames _importantVariableNames)
82
- foreach (_variableName ${_variableNames } )
83
- foreach (_importantVariableName ${_importantVariableNames } )
107
+ function (_print_compilers_info _variableNames _importantVariableNames)
108
+ foreach (_importantVariableName ${_importantVariableNames } )
109
+ foreach (_variableName ${_variableNames } )
84
110
string (REGEX MATCH "^${_importantVariableName} $" _match "${_variableName} " )
85
111
86
112
if (_match)
87
113
string (REGEX MATCH ".*(_COMPILER)$" _isCompiler "${_variableName} " )
88
114
89
115
if (_isCompiler)
90
116
set (_compilerVersion "" )
91
- get_filename_component (_executable_name "${${_variableName} }" NAME_WE )
92
- execute_process (
93
- COMMAND ${${_variableName} } --version
94
- COMMAND grep -i ${_executable_name}
95
- OUTPUT_VARIABLE _compilerVersion
96
- OUTPUT_STRIP_TRAILING_WHITESPACE
97
- )
98
- execute_process (
117
+ get_filename_component (_executable_name "${${_variableName} }" NAME_WE )
118
+ execute_process (
99
119
COMMAND which ${${_variableName} }
100
120
OUTPUT_VARIABLE _compilerPath
101
121
OUTPUT_STRIP_TRAILING_WHITESPACE
102
122
)
123
+ execute_process (
124
+ COMMAND "${_compilerPath} " --version
125
+ # version info does not always contain the exact executable name (clang++ -> clang)
126
+ # using now the hardcoded first line content instead :S
127
+ #COMMAND grep -i ${_executable_name}
128
+ COMMAND head -n 1
129
+ OUTPUT_VARIABLE _compilerVersion
130
+ OUTPUT_STRIP_TRAILING_WHITESPACE
131
+ )
103
132
_space_tabbed_string("${_variableName} " 32 _spaceTabbedVariableName)
104
- _print_summary_line("${_spaceTabbedVariableName}${_executable_name} " "[${Yellow}${_compilerVersion}${Green} ]${ResetFG} - ${_compilerPath} " 40)
133
+ _space_tabbed_string ("${_executable_name} " 10 _spaceTabbedExecutable_name)
134
+ _print_summary_line("${_spaceTabbedVariableName} " "${_spaceTabbedExecutable_name}${Green} [${Yellow}${_compilerVersion}${Green} ]${ResetFG} - ${_compilerPath} " 32)
105
135
unset (_compilerVersion)
106
136
else ()
107
137
_print_summary_line("${_importantVariableName} " "${${_importantVariableName} }" 32)
@@ -111,16 +141,27 @@ function(_print_importants _variableNames _importantVariableNames)
111
141
endforeach ()
112
142
endfunction ()
113
143
114
- function (_print_options _variableNames)
144
+ function (_print_module_options _variableNames)
115
145
foreach (_variableName ${_variableNames} )
116
146
string (REGEX MATCH "^ENABLE_" _match "${_variableName} " )
147
+ list (FIND _compilationsOptions "${_variableName} " _index)
117
148
118
- if (_match)
149
+ if (_match AND _index LESS 0 )
119
150
_print_summary_line("${_variableName} " "${${_variableName} }" 32)
120
151
endif ()
121
152
endforeach ()
122
153
endfunction ()
123
154
155
+ function (_print_options _variableNames _options)
156
+ foreach (_option ${_options} )
157
+ list (FIND _variableNames "${_option} " _index)
158
+
159
+ if (_index GREATER_EQUAL 0)
160
+ _print_summary_line("${_option} " "${${_option} }" 32)
161
+ endif ()
162
+ endforeach ()
163
+ endfunction ()
164
+
124
165
function (_print_full _variableNames)
125
166
foreach (_variableName ${_variableNames} )
126
167
message ("${_variableName} =${${_variableName} }" )
@@ -133,29 +174,35 @@ endfunction()
133
174
function (print_config_summary)
134
175
get_cmake_property (_variableNames VARIABLES )
135
176
list (SORT _variableNames)
136
- list (REMOVE_DUPLICATES _variableNames)
137
-
138
- _print_separator()
139
- message (NOTICE "syslog-ng Open Source Edition ${SYSLOG_NG_VERSION} configured" )
140
- _print_separator()
177
+ list (REMOVE_DUPLICATES _variableNames)
141
178
142
- if (SUMMARY_FULL)
179
+ if (SUMMARY_FULL OR SUMMARY_LEVEL GREATER_EQUAL 2)
180
+ _print_separator("" )
143
181
_print_full("${_variableNames} " )
144
182
else ()
145
- if (SUMMARY_VERBOSE)
183
+ if (SUMMARY_VERBOSE OR SUMMARY_LEVEL EQUAL 1)
184
+ _print_separator("" )
146
185
_print_libraries("${_variableNames} " )
147
- _print_separator()
148
186
endif ()
187
+ endif ()
149
188
150
- list (APPEND _importantVariableNames "IVYKIS_INTERNAL" "BUILD_TESTING" "CMAKE_C_COMPILER" "CMAKE_CXX_COMPILER" "CMAKE_OBJC_COMPILER" "CMAKE_BUILD_TYPE" )
151
- if (APPLE )
152
- list (APPEND _importantVariableNames "FORCE_CLASSIC_LINKING" )
153
- endif ()
154
- _print_importants("${_variableNames} " "${_importantVariableNames} " )
155
- _print_separator()
189
+ _print_separator("" )
190
+ message (NOTICE "syslog-ng Open Source Edition ${SYSLOG_NG_VERSION} configured" )
156
191
157
- _print_options("${_variableNames} " )
158
- endif ()
192
+ _print_separator("Environment" )
193
+ _print_options ("${_variableNames} " "${_envInfo} " )
194
+
195
+ _print_separator("Compilers" )
196
+ _print_compilers_info("${_variableNames} " "${_compilersInfo} " )
197
+
198
+ _print_separator("Compilation" )
199
+ _print_options("${_variableNames} " "${_compilationsOptions} " )
200
+
201
+ _print_separator("Sub-modules" )
202
+ _print_options("${_variableNames} " "${_subModules} " )
203
+
204
+ _print_separator("Modules" )
205
+ _print_module_options("${_variableNames} " )
159
206
160
- _print_separator()
207
+ _print_separator("" )
161
208
endfunction ()
0 commit comments