mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.6k forks source link

VS2019 C++17 support #8079

Open FedorLap2006 opened 3 years ago

FedorLap2006 commented 3 years ago

Describe the bug C++17 is not working in Visual Studio 2019... and also in 2017. Especially... HAS_CXX17 is not set. P.S. I tried using vs2017, also I tried to play with different commands - nothing.

To Reproduce

project('Some project', 'cpp', default_options : ['c_std=c11', 'cpp_std=c++17'])

if meson.backend() == 'vs2019'
  add_project_arguments('/std:c++17', language : 'cpp')
endif

cmake = import('cmake')

settings = {
  'source_dir': 'src',
  'inc_dir': 'include',
  'deplist': [
  ]
}

srclist = [

]

inclist = [
]

sources = []
foreach sf : srclist
endforeach

foreach sf : inclist
endforeach

executable('proj', sources, dependencies : settings.get('deplist', []), include_directories : settings.get('inc_dir', 'include'))

Expected behavior Generated project with C++17 enabled.

System parameters

scivision commented 3 years ago

Let's try a minimal example. One issue is that many compilers allow some C++17 features without C++17 flag or compiler default to C++17.

I made a pull request https://github.com/mesonbuild/meson/pull/8102 to help reveal this issue. Try using the meson.build and main.cpp from that PR, using:

meson build

meson compile -C build -v

will reveal the compiler flags being used.

FedorLap2006 commented 3 years ago

Let's try a minimal example. One issue is that many compilers allow some C++17 features without C++17 flag or compiler default to C++17.

I made a pull request #8102 to help reveal this issue. Try using the meson.build and main.cpp from that PR, using:

meson build

meson compile -C build -v

will reveal the compiler flags being used.

Thanks, I will try. Just I was trying to use variant and optional and... this. I hope I won't go onto CMake instead again.