From 4f78b9ff2df89d5b4104f92251feb0a7f0976d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20St=C3=BCrmer?= Date: Fri, 23 Sep 2016 12:15:40 +0200 Subject: VS: Add CSharp project uuid and file extension This is in preparation for adding CSharp language support to the VS generator. --- Source/cmGlobalVisualStudio71Generator.cxx | 4 ++++ Source/cmGlobalVisualStudioGenerator.cxx | 21 +++++++++++++++++++++ Source/cmGlobalVisualStudioGenerator.h | 3 +++ 3 files changed, 28 insertions(+) diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index ffd87e2..1fa2741 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -159,6 +159,10 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, ext = ".vfproj"; project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \""; } + if (this->TargetIsCSharpOnly(t)) { + ext = ".csproj"; + project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \""; + } const char* targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT"); if (targetExt) { ext = targetExt; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6296dd2..b277391 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -734,6 +734,27 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( return false; } +bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly( + cmGeneratorTarget const* gt) +{ + // check to see if this is a C# build + std::set languages; + { + // Issue diagnostic if the source files depend on the config. + std::vector sources; + if (!gt->GetConfigCommonSourceFiles(sources)) { + return false; + } + } + gt->GetLanguages(languages, ""); + if (languages.size() == 1) { + if (*languages.begin() == "CSharp") { + return true; + } + } + return false; +} + bool cmGlobalVisualStudioGenerator::TargetCompare::operator()( cmGeneratorTarget const* l, cmGeneratorTarget const* r) const { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index a774d96..c8fc984 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -69,6 +69,9 @@ public: // return true if target is fortran only bool TargetIsFortranOnly(const cmGeneratorTarget* gt); + // return true if target is C# only + static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt); + /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); -- cgit v0.12