VS: DOTNET_SDK compile definitions ignored for C# projects
Minimal reproducer:
cmake_minimum_required(VERSION 3.23)
project(NET6Test LANGUAGES CSharp)
include(CSharpUtilities)
if(NOT CMAKE_DOTNET_SDK)
set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk")
endif()
set(CMAKE_DOTNET_TARGET_FRAMEWORK "net6.0")
set(CMAKE_CSharp_FLAGS "/langversion:10")
add_executable(test Program.cs)
target_compile_definitions(test PUBLIC ADEFINMITION)
With the above CMakeLists, target_compile_definitions()
is ignored.
When not using CMAKE_DOTNET_SDK, the generated project contains <DefineConstants>ADEFINMITION</DefineConstants>
as expected.