From 2ad7d0c233215232490dc8fc968b4a2636bc9aea Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Thu, 27 Feb 2025 13:31:37 +0100 Subject: [PATCH] meson: use meson.get_compiler() just once --- meson.build | 12 ++++++------ plugins/meson.build | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 8f79c1a87..82fe0681e 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,8 @@ project( ], ) +cpp = meson.get_compiler('cpp') + version = '"@0@"'.format(meson.project_version()) add_project_arguments('-DWAYFIRE_VERSION=@0@'.format(version), language: 'cpp') @@ -32,7 +34,7 @@ glm = dependency('glm', required: false) libinput = dependency('libinput', version: '>=1.7.0') pixman = dependency('pixman-1') xkbcommon = dependency('xkbcommon') -libdl = meson.get_compiler('cpp').find_library('dl') +libdl = cpp.find_library('dl') json = dependency('nlohmann_json', version: '>= 3.11.2') udev = dependency('libudev') @@ -106,11 +108,11 @@ elif get_option('use_system_wfconfig').auto() endif endif -if not glm.found() and not meson.get_compiler('cpp').check_header('glm/glm.hpp') +if not glm.found() and not cpp.check_header('glm/glm.hpp') error('GLM not found, and directly using the header \'glm/glm.hpp\' is not possible.') endif -backtrace = meson.get_compiler('cpp').find_library('execinfo', required: false) +backtrace = cpp.find_library('execinfo', required: false) wfutils = subproject('wf-utils').get_variable('wfutils') wftouch = subproject('wf-touch').get_variable('wftouch') @@ -122,7 +124,7 @@ jpeg = dependency('libjpeg', required: false) png = dependency('libpng', required: false) # backtrace() is in a separate library on FreeBSD and Linux with musl -backtrace = meson.get_compiler('cpp').find_library('execinfo', required: false) +backtrace = cpp.find_library('execinfo', required: false) conf_data = configuration_data() @@ -140,8 +142,6 @@ else conf_data.set('DEFAULT_CONFIG_BACKEND', get_option('default_config_backend')) endif -cpp = meson.get_compiler('cpp') - # needed to dlopen() plugins # -E is for RTTI/dynamic_cast across plugins add_project_link_arguments(['-rdynamic', '-Wl,-E'], language: 'cpp') diff --git a/plugins/meson.build b/plugins/meson.build index 39895db70..bd9824dec 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -3,7 +3,6 @@ subdir('common') if get_option('custom_pch') # Add a workaround for https://github.com/mesonbuild/meson/issues/4350 # We create a PCH ourselves and manage it for all plugins. - cc = meson.get_compiler('cpp') pch_file = meson.current_source_dir() / 'pch/plugin_pch.hpp' custom_pch_flags = ['@INPUT@', '-c', '-o', '@OUTPUT@', '-MD', '-MF', '@DEPFILE@', '-std=' + get_option('cpp_std'), '-pthread', '-fPIC'] + get_option('cpp_args') @@ -32,18 +31,18 @@ if get_option('custom_pch') input: pch_file, output: 'plugin_pch.hpp.gch', depfile: 'plugin_pch.hpp.d', - command: cc.cmd_array() + custom_pch_flags) + command: cpp.cmd_array() + custom_pch_flags) fs = import('fs') - if cc.get_id() == 'clang' + if cpp.get_id() == 'clang' # In clang, everything is simple, we just tell the compiler which PCH file to use plugin_pch_arg = ['-include-pch', pch.full_path(), '-pthread'] - elif cc.get_id() == 'gcc' + elif cpp.get_id() == 'gcc' # GCC requires that the .gch and the .hpp file are in the same dir. fs.copyfile(pch_file) # copy to build dir where .gch is found plugin_pch_arg = ['-I' + fs.parent(pch.full_path()), '-include', fs.name(pch_file), '-pthread', '-fpch-preprocess'] else - error('Unsupported compiler for custom pch: ' + cc.get_id()) + error('Unsupported compiler for custom pch: ' + cpp.get_id()) endif plugin_pch_dep = declare_dependency(sources: pch, compile_args: plugin_pch_arg)