Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 4,165
    • Issues 4,165
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #23376
Closed
Open
Issue created Mar 31, 2022 by Erin Melucci@emelucciContributor

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.

Edited Apr 01, 2022 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking