From dd10f8f823374ce74d342ac5e365f3a628fe6afd Mon Sep 17 00:00:00 2001 From: horosin Date: Tue, 25 Jun 2019 14:29:52 +0100 Subject: [PATCH] Use C++17 compile flag when possible (#41) --- setup.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index ca00254..d91ca22 100644 --- a/setup.py +++ b/setup.py @@ -52,17 +52,17 @@ def has_flag(compiler, flagname): def cpp_flag(compiler): - """Return the -std=c++[11/14] compiler flag. + """Return the -std=c++[11/14/17] compiler flag. - The c++14 is prefered over c++11 (when it is available). + The newer version is prefered over c++11 (when it is available). """ - if has_flag(compiler, '-std=c++14'): - return '-std=c++14' - elif has_flag(compiler, '-std=c++11'): - return '-std=c++11' - else: - raise RuntimeError('Unsupported compiler -- at least C++11 support ' - 'is needed!') + flags = ['-std=c++17', '-std=c++14', '-std=c++11'] + + for flag in flags: + if has_flag(compiler, flag): return flag + + raise RuntimeError('Unsupported compiler -- at least C++11 support ' + 'is needed!') class BuildExt(build_ext):