host_cpu = host_machine.cpu_family()
cc = meson.get_compiler('c')
+have_cxx = add_languages('cpp', required: false, native: false)
+if have_cxx
+ cxx = meson.get_compiler('cpp')
+endif
not_found_dep = dependency('', required: false)
thread_dep = dependency('threads')
llvmopt = get_option('llvm')
llvm = not_found_dep
-if add_languages('cpp', required: llvmopt, native: false)
+if have_cxx
llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt)
if llvm.found()
cdata.set('USE_LLVM', 1)
- cxx = meson.get_compiler('cpp')
-
llvm_binpath = llvm.get_variable(configtool: 'bindir')
ccache = find_program('ccache', native: true, required: false)
# find via PATH, too.
clang = find_program(llvm_binpath / 'clang', 'clang', required: true)
endif
-elif llvmopt.auto()
- message('llvm requires a C++ compiler')
+else
+ msg = 'llvm requires a C++ compiler'
+ if llvmopt.auto()
+ message(msg)
+ elif llvmopt.enabled()
+ error(msg)
+ endif
endif
# We need to repeat the test for C++ because gcc and clang prefer different
# format archetypes.
-if llvm.found()
+if have_cxx
attrib_error_args = cxx.get_supported_arguments('-Werror=format', '-Werror=ignored-attributes')
foreach a : printf_attributes
if cxx.compiles(testsrc.format(a),
]
cflags += cc.get_supported_arguments(common_functional_flags)
-if llvm.found()
+if have_cxx
cxxflags += cxx.get_supported_arguments(common_functional_flags)
endif
]
cflags_warn += cc.get_supported_arguments(common_warning_flags)
-if llvm.found()
+if have_cxx
cxxflags_warn += cxx.get_supported_arguments(common_warning_flags)
endif
if cc.has_argument('-W' + w)
cflags_warn += '-Wno-' + w
endif
- if llvm.found() and cxx.has_argument('-W' + w)
+ if have_cxx and cxx.has_argument('-W' + w)
cxxflags_warn += '-Wno-' + w
endif
endforeach
endif
cflags_builtin = cc.get_supported_arguments(common_builtin_flags)
-if llvm.found()
+if have_cxx
cxxflags_builtin = cxx.get_supported_arguments(common_builtin_flags)
endif
section: 'Compiler Flags',
)
-if llvm.found()
+if have_cxx
summary(
{
'C++ compiler': '@0@ @1@'.format(cxx.get_id(), cxx.version()),
var_cc = ' '.join(cc.cmd_array())
var_cpp = ' '.join(cc.cmd_array() + ['-E'])
var_cflags = ' '.join(cflags + cflags_builtin + cflags_warn + get_option('c_args'))
-if llvm.found()
+if have_cxx
+ var_cxx = ' '.join(cxx.cmd_array())
var_cxxflags = ' '.join(cxxflags + cxxflags_builtin + cxxflags_warn + get_option('cpp_args'))
else
+ # Default to 'g++' so that PGXS users get a clear "g++ not found"
+ # error when building C++ extensions. Otherwise, they'd get a
+ # confusing error because no binary is specified in the build
+ # commands and the first flag would be interpreted as the program.
+ var_cxx = 'g++'
var_cxxflags = ''
endif
var_cppflags = ' '.join(cppflags)