My thinking was to have the process of generating the project files be a per-target process. In the draft MR, I have the variable IsDotNetSdkTarget
a member variable of cmGeneratorTarget
. What I am not sure is how do we get there?
My thinking of introducing the language was to enable the switch at global level. That doesn’t seem a good idea given your comments. How about we do the following?
- Introduce a flag
CMAKE_CSHARP_DOTNET
which when set will prefer using .Net CLI for identifying and testing C# toolchain. - When
CMAKE_CSHARP_DOTNET
isTRUE
, modifyCMakeDetermineCSharpCompiler.cmake
to see ifdotnet build
,dotnet run
, anddotnet test
succeed. - If
dotnet build
succeeds, Ninja generator can be used. - If
dotnet build
doesn’t succeed, Ninja generator can’t be used. CMake will see ifcsc
is available and if so, use that for VS generator. - Introduce a new per-target property
DOTNET_SDK_STYLE_PROJECT
which will generateSDK-style
project for C# files.
Open question:
- How do we set
DOTNET_SDK_STYLE_PROJECT
to true for all projects? - Do we need the policy introduced in MR 6634 at all?
Thoughts/comments?
From implementation perspective, I can modify MR 6634 to use a per-target property and the rest of the code there shouldn’t need to be changed. Then, the next change would be introducing CMAKE_CSHARP_DOTNET
(or other names that people want to use ).