How to set WarningLevel for CSharp targets

Hi everybody

I am currently working on transforming our hard checked-in .csproj files into CMakeLists files. I ran into the problem that I do not know how to set the warning level in this case.
This is done in the .csproj file with the tag

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    ...
    <WarningLevel>1</WarningLevel>
    ...
  </PropertyGroup>

I know that I can use the target property VS_GLOBAL_WarningLevel to add the WarningLevel to the plain PropertyGroup

  <PropertyGroup>
    ...
    <WarningLevel>1</WarningLevel>
    ...
  </PropertyGroup>

but this does not affect the value in the configuration specific PropertyGroup which seems to override the value from non config specific PropertyGroup. Is there a way to solve this problem?

I am looking for a VS_GLOBAL_<CONFIG>_<variable> target property, to access the config specific section, but I do not think that exists.

Target-specific properties are usually derived from the flags for the target and/or the CMake target properties. If you replace /W1 with /W3 in the flags (or whatever the C# spelling for these flags happens to be), does that work?

Ok it was my mistake. Adding /warn:4 to the CMAKE_CSharp_FLAGS_DEBUG works.
I am not quite sure what went wrong because I tried setting the compiler flags. Must have made some trival mistake.

I think the behavior is different to what would be expected from a C++ target.

The following code will set warning level 1 to both targets/projects.
I think for C++ this would use differnet warning levels for both targets.

set(CMAKE_CSharp_FLAGS_DEBUG "/warn:4 ..." CACHE STRING "" FORCE)
add_subdirectory(foo) # adds csharp target foo
set(CMAKE_CSharp_FLAGS_DEBUG "/warn:1 ..." CACHE STRING "" FORCE)
add_subdirectory(bar) # adds csharp target bar

Thanks for your time.