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_DOTNETwhich when set will prefer using .Net CLI for identifying and testing C# toolchain. - When
CMAKE_CSHARP_DOTNETisTRUE, modifyCMakeDetermineCSharpCompiler.cmaketo see ifdotnet build,dotnet run, anddotnet testsucceed. - If
dotnet buildsucceeds, Ninja generator can be used. - If
dotnet builddoesn’t succeed, Ninja generator can’t be used. CMake will see ifcscis available and if so, use that for VS generator. - Introduce a new per-target property
DOTNET_SDK_STYLE_PROJECTwhich will generateSDK-styleproject for C# files.
Open question:
- How do we set
DOTNET_SDK_STYLE_PROJECTto 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
).