Require specific compiler versions
Quite often do I compile this project, and see an error message that
makes no sense. Multiple times I've seen posted about compiler errors
that amount to using an old version of clang or gcc.
Explicitly require clang-17 and gcc-13 in the meson config, and give
better errors if they're not present.
This also allows simplifying our warning flags (which probably need
a review soon) by making two sets of flags, one for each compiler.
Note, clang has the -Weverything flag, which we use, so explicitly
enabling warnings isn't really required, only disabling the ones
that we don't use.
Tested: Code compiles.
Change-Id: I09fa74e6d36feaf05710a4bb7d266f80ff1cc592
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/meson.build b/meson.build
index 2d5f00e..0c5277e 100644
--- a/meson.build
+++ b/meson.build
@@ -130,24 +130,13 @@
# Add compiler arguments
-# -Wpedantic, -Wextra comes by default with warning level
-add_project_arguments(
- cxx.get_supported_arguments([
- '-Wcast-align',
- '-Wconversion',
- '-Wformat=2',
- '-Woverloaded-virtual',
- '-Wsign-conversion',
- '-Wunused',
- '-Wno-attributes',
- ]),
- language: 'cpp'
-)
-
-if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0'))
-add_project_arguments(
- cxx.get_supported_arguments([
+if (cxx.get_id() == 'clang')
+ if (cxx.version().version_compare('<17.0'))
+ error('This project requires clang-17 or higher')
+ endif
+ add_project_arguments(
'-Weverything',
+ '-Wformat=2',
'-Wno-c++98-compat-pedantic',
'-Wno-c++98-compat',
'-Wno-documentation-unknown-command',
@@ -161,25 +150,30 @@
'-Wno-weak-vtables',
'-Wno-switch-enum',
'-Wno-unused-macros',
- ]),
- language:'cpp')
+ language:'cpp')
endif
-# if compiler is gnu-gcc , and version is > 8.0 then we add few more
-# compiler arguments , we know that will pass
+if (cxx.get_id() == 'gcc')
+ if (cxx.version().version_compare('<13.0'))
+ error('This project requires gcc-13 or higher')
+ endif
-if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0'))
add_project_arguments(
- cxx.get_supported_arguments([
- '-Wduplicated-cond',
- '-Wduplicated-branches',
- '-Wlogical-op',
- '-Wnull-dereference',
- '-Wunused-parameter',
- '-Wdouble-promotion',
- '-Wshadow',
- '-Wno-psabi',
- ]),
+ '-Wformat=2',
+ '-Wcast-align',
+ '-Wconversion',
+ '-Woverloaded-virtual',
+ '-Wsign-conversion',
+ '-Wunused',
+ '-Wduplicated-cond',
+ '-Wduplicated-branches',
+ '-Wlogical-op',
+ '-Wnull-dereference',
+ '-Wunused-parameter',
+ '-Wdouble-promotion',
+ '-Wshadow',
+ '-Wno-psabi',
+ '-Wno-attributes',
language:'cpp')
endif