I'm trying to generate C# project for Visual Studio 2017 with a CMake 3.16.3, but I'm having problems setting C# language version. Even if I'm specifying it at top of CMakeLists.txt file as such:
target_compile_options(<MyApp> PRIVATE "/langversion:latest")
Or like this:
set(CMAKE_CSharp_FLAGS "/langversion:latest")
Inside the *.csproj file it is always set like this:
<Project>
...
<PropertyGroup>
...
<AdditionalOptions>/langversion:latest</AdditionalOptions>
...
<LangVersion>3</LangVersion>
...
</PropertyGroup>
...
</Project>
So no matter what value I put there, it is always version 3 (which is minimum version). Without specifying language version, it set to default and that is latestMajor, Version 7.0.
Only way around this problem so far is to create Directory.Build.props file inside build folder. And it looks like this:
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
I'm quite new with CMake and its documentation is quite complex, so I probably have missed some steps. Or is this a bug in CMake and has anyone had any better solutions for this problem?
Here is link for projects Gitlab page