Skip to content

Commit 4e83a49

Browse files
committed
cmake: correct compiler info printing
Signed-off-by: Hofi <[email protected]>
1 parent 5b09e01 commit 4e83a49

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cmake/print_config_summary.cmake

+11-8
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,21 @@ function(_print_compilers_info _variableNames _importantVariableNames)
114114

115115
if(_isCompiler)
116116
set(_compilerVersion "")
117-
get_filename_component (_executable_name "${${_variableName}}" NAME_WE)
118-
execute_process (
119-
COMMAND ${${_variableName}} --version
120-
COMMAND grep -i ${_executable_name}
121-
OUTPUT_VARIABLE _compilerVersion
122-
OUTPUT_STRIP_TRAILING_WHITESPACE
123-
)
124-
execute_process (
117+
get_filename_component(_executable_name "${${_variableName}}" NAME_WE)
118+
execute_process(
125119
COMMAND which ${${_variableName}}
126120
OUTPUT_VARIABLE _compilerPath
127121
OUTPUT_STRIP_TRAILING_WHITESPACE
128122
)
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+
)
129132
_space_tabbed_string("${_variableName}" 32 _spaceTabbedVariableName)
130133
_space_tabbed_string ("${_executable_name}" 10 _spaceTabbedExecutable_name)
131134
_print_summary_line("${_spaceTabbedVariableName}" "${_spaceTabbedExecutable_name}${Green}[${Yellow}${_compilerVersion}${Green}]${ResetFG} - ${_compilerPath}" 32)

0 commit comments

Comments
 (0)