-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cpp_std option for Visual Studio C++ compiler #2836
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,10 +207,20 @@ def __init__(self, exelist, version, is_cross, exe_wrap, is_64): | |
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like | ||
|
||
def get_options(self): | ||
c_stds = ['none', 'c++11'] | ||
# Visual Studio 2015 Update 3 and later | ||
if version_compare(self.version, '>=19.10.25017'): | ||
c_stds += ['c++14', 'c++latest'] | ||
# Visual Studio 2017 and later | ||
if version_compare(self.version, '>=19.11'): | ||
c_stds += ['c++17'] | ||
return {'cpp_eh': coredata.UserComboOption('cpp_eh', | ||
'C++ exception handling type.', | ||
['none', 'a', 's', 'sc'], | ||
'sc'), | ||
'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use', | ||
c_stds, | ||
'none'), | ||
'cpp_winlibs': coredata.UserArrayOption('cpp_winlibs', | ||
'Windows libs to link against.', | ||
msvc_winlibs) | ||
|
@@ -221,6 +231,9 @@ def get_option_compile_args(self, options): | |
std = options['cpp_eh'] | ||
if std.value != 'none': | ||
args.append('/EH' + std.value) | ||
std = options['cpp_std'] | ||
if std.value not in ['none', 'c++11']: | ||
args.append('/std:' + std.value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why isn't this value added for Also, why aren't we warning when |
||
return args | ||
|
||
def get_option_link_args(self, options): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[[nodiscard]] int foo() { | ||
return 0; | ||
} | ||
|
||
int main() { | ||
return foo(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
project('wincpp', 'cpp') | ||
|
||
if meson.get_compiler('cpp').version().version_compare('<19.11') | ||
error('MESON_SKIP_TEST Visual Studio 2017 (version 15.3) or later is required for C++17 support') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you skipping the test here? Also where's the |
||
endif | ||
|
||
exe = executable('prog', 'main.cpp', override_options: ['cpp_std=c++17']) | ||
test('wincpp', exe) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be added into the
docs/markdown/snippets
directory.