Commit ea379ef5 authored by Jehan's avatar Jehan

meson: fix CC_VERSION.

The way we use CC_VERSION macro is to give information on the compiler
used during build. This information may be useful when debugging in
particular. So we can't just use `cc.version()` which only gives a
version number, not even the name of the compiler.

Restore the logics of autotools where we were using the result of `cc
-v` (for gcc and clang) and testing various CLI options for other

Also this test may fail on meson because of various bugs, which I now
reported and provided patch for (hopefully soon merged). In particular,
when using ccache, the command run fails (also I have to change newlines
in C-style `\n` myself as meson's set_quoted() creates broken header
when newlines are present).

If it fails, let's at least store the compiler name + its version, still
more useful than version only.
parent e4c7fc23
Pipeline #131097 passed with stages
in 38 minutes and 5 seconds
......@@ -1339,7 +1339,34 @@ conf.set('HAVE_FUNC_ATTRIBUTE_DESTRUCTOR',
# Compiler
conf.set_quoted('CC', cc.get_id())
conf.set_quoted('CC_VERSION', cc.version())
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
cc_cmd = run_command(cc, '-v')
# Note: the call might actually fail when using ccache.
# See:
if cc_cmd.returncode() == 0
cc_version = cc_cmd.stdout() + cc_cmd.stderr()
# Various compilers have various options. Try most common ones. This
# list of options comes from autotools checks.
foreach arg : [ '--version', '-v', '-V', '-qversion' ]
cc_cmd = run_command(cc, arg)
if cc_cmd.returncode() == 0
cc_version = cc_cmd.stdout()
if cc_version == ''
# We didn't manage to get a meaningful verbose version from the
# compiler. Just save its name and version.
cc_version = cc.get_id() + ' ' + cc.version()
# See also:
cc_version = '\\n'.join(cc_version.split('\n'))
conf.set_quoted('CC_VERSION', cc_version)
# Names
conf.set_quoted('GIMP_PACKAGE', meson.project_name())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment