From 3124f8a4872e85c39027bcca8d8f0dede86f68f2 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 7 Apr 2021 01:39:18 +0200 Subject: [PATCH] add a thingy in meson to guess c++ std since meson doesn't yet support cpp_std=c++2a or c++20 for msvc++, only gcc (and the older version we support doesn't have c++20 either), default to none and add some minimal logic which will guess it for whatever compiler we're using people can still override the standard manually, in which case our guess logic will not be used --- README.md | 2 +- meson.build | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b5578c4..a075d39 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ compilers include: * GCC 10 * Clang 11 -* Visual Studio 2019 +* Microsoft Visual C++ 2019 Older versions of GCC and Clang may work, with no guarantees. diff --git a/meson.build b/meson.build index 80306fd..49be384 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,8 @@ project('libcubescript', ['cpp'], version: '0.1.0', default_options: [ - 'buildtype=debugoptimized', 'cpp_std=c++2a', - 'warning_level=3', 'cpp_rtti=false' + 'buildtype=debugoptimized', 'warning_level=3', 'cpp_rtti=false', + 'cpp_std=none' ], meson_version: '>=0.50' ) @@ -29,6 +29,24 @@ if get_option('buildtype') != 'plain' endif endif +# Meson does not support C++20 std in a portable way in this version +# unless specified explicitly, have our own logic which will guess it +if get_option('cpp_std') == 'none' + if cxx.has_argument('-std=c++20') + # modern gcc/clang + extra_cxxflags += '-std=c++20' + elif cxx.has_argument('-std=c++2a') + # older gcc/clang + extra_cxxflags += '-std=c++2a' + elif cxx.has_argument('/std:c++20') + # future msvc++? not supported anywhere yet + extra_cxxflags += '/std:c++20' + elif cxx.has_argument('/std:c++latest') + # msvc++ 2019 + extra_cxxflags += '/std:c++latest' + endif +endif + subdir('src') subdir('tools')