From 75b30d373c26e01e95d7ec4a87e8a19f91b581db Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Tue, 16 May 2023 09:27:06 -0500
Subject: [PATCH postgres v1 07/17] Tie adding C++ support to the llvm Meson
 option

In the event the llvm option is defined to be 'auto', it is possible
that the host machine might not have a C++ compiler. If that is the
case, then we shouldn't continue reaching for the llvm dependency.
---
 meson.build | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index 3db70fb8a6..d266e2eb1f 100644
--- a/meson.build
+++ b/meson.build
@@ -743,19 +743,20 @@ endif
 
 llvmopt = get_option('llvm')
 if not llvmopt.disabled()
-  add_languages('cpp', required: true, native: false)
-  llvm = dependency('llvm', version: '>=3.9', method: 'config-tool', required: llvmopt)
+  if add_languages('cpp', required: llvmopt, native: false)
+    llvm = dependency('llvm', version: '>=3.9', method: 'config-tool', required: llvmopt)
 
-  if llvm.found()
+    if llvm.found()
 
-    cdata.set('USE_LLVM', 1)
+      cdata.set('USE_LLVM', 1)
 
-    cpp = meson.get_compiler('cpp')
+      cpp = meson.get_compiler('cpp')
 
-    llvm_binpath = llvm.get_variable(configtool: 'bindir')
+      llvm_binpath = llvm.get_variable(configtool: 'bindir')
 
-    ccache = find_program('ccache', native: true, required: false)
-    clang = find_program(llvm_binpath / 'clang', required: true)
+      ccache = find_program('ccache', native: true, required: false)
+      clang = find_program(llvm_binpath / 'clang', required: true)
+    endif
   endif
 else
   llvm = not_found_dep
-- 

Tristan Partin
Neon (https://neon.tech)

