From 0e867ef702e1388a357d8cf51aeb89b30626292d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 7 Mar 2024 12:14:31 +0100
Subject: [PATCH] Build system: enforce minimal GCC version

---
 meson.build | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meson.build b/meson.build
index ca8c3fce87..b2cc39ae66 100644
--- a/meson.build
+++ b/meson.build
@@ -17,6 +17,18 @@ cpp_compiler = meson.get_compiler('cpp')
 fortran_compiler = meson.get_compiler('fortran')
 c_compiler = meson.get_compiler('c')
 
+# If this is GCC, enforce minimal version
+# Other compilers are unsupported, but do not fail in that case
+gcc_minimal_version = 10
+if ((cpp_compiler.get_id() == 'gcc'
+     and cpp_compiler.version().version_compare('<' + gcc_minimal_version.to_string()))
+    or (fortran_compiler.get_id() == 'gcc'
+        and fortran_compiler.version().version_compare('<' + gcc_minimal_version.to_string()))
+    or (c_compiler.get_id() == 'gcc'
+        and c_compiler.version().version_compare('<' + gcc_minimal_version.to_string())))
+  error('GCC is too old. Version ' + gcc_minimal_version.to_string() + ' or higher is required.')
+endif
+
 ### Preprocessor
 
 subdir('preprocessor/src')
-- 
GitLab