[PATCH libgpiod] build: do not require a C++ compiler if it is not needed

Edgar Bonet <[email protected]>
Newsgroups org.kernel.vger.linux-gpio
Message-ID <[email protected]>
Languages specified in the meson project() function are considered hard
dependencies. When trying to build libgpiod in an environment lacking a
C++ compiler, the build fails with an obscure error message ("ERROR:
Unable to get gcc pre-processor defines").

As the C++ compiler is only needed for building the C++ bindings, do not
require it unless the option bindings-cxx is enabled.

Signed-off-by: Edgar Bonet <[email protected]>
---
Note that this issue has caused a few failures on the Buildroot
autobuilders, e.g.:
https://autobuild.buildroot.org/results/d1c19ffa0c599bd2ba9be965a98fc8f778d6e366
https://autobuild.buildroot.org/results/c6b3c9311d628bdb4ea103431767493fab9a3668
https://autobuild.buildroot.org/results/8e799050c5779c680ff5e5136571f57d29239f2f
https://autobuild.buildroot.org/results/d6d8833acfe00559579defbbf3ca34c0edbe7869
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 7a6306d..a8a5b0b 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
 
-project('libgpiod', ['c', 'cpp'],
+project('libgpiod', 'c',
   version: '2.4',
   license: 'LGPL-2.1-or-later',
   default_options: [
@@ -56,6 +56,10 @@ opt_dbus                = get_option('dbus')
 opt_introspection       = get_option('introspection')
 opt_systemd             = get_option('systemd')
 
+if opt_bindings_cxx.allowed()
+  add_languages('cpp')
+endif
+
 if get_option('profiling')
   profiling_c_args    = ['-fprofile-arcs', '-ftest-coverage']
   profiling_link_args = ['-lgcov']

base-commit: 7d7b07738885d051a28bdfb5025c8eb73cdf23f8
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.