summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-30 13:37:07 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-31 13:13:19 (GMT)
commita56edad6d61268204af8228b8d58fa26d8f72269 (patch)
tree0d3fb5b71f8f83db49b7eed811defe2902f48c44 /Source/cmVisualStudio10TargetGenerator.cxx
parentf87d5f13c29a961238ccf623d4954d2d0636adaa (diff)
downloadCMake-a56edad6d61268204af8228b8d58fa26d8f72269.zip
CMake-a56edad6d61268204af8228b8d58fa26d8f72269.tar.gz
CMake-a56edad6d61268204af8228b8d58fa26d8f72269.tar.bz2
CSharp: Fix regression in VS project type selection for custom target
A target created by `add_custom_target` should always be a `.vcxproj` file even if it has `.cs` sources involved in custom commands and such. The latter case was broken by refactoring in commit v3.12.0-rc1~160^2~7 (remove TargetIsCSharpOnly() and use methods from cmGeneratorTarget, 2018-03-19). The reason is that the `HasLanguage` method added by commit v3.12.0-rc1~239^2~6 (cmGeneratorTarget: add HasLanguage() as wrapper for GetLanguages(), 2018-03-19) does not check the target type and so is not a suitable check for deciding the project file extension. The `HasLanguage` method was an attempt at an abstraction that turns out not to work very well. Replace it with a dedicated `IsCSharpOnly` method that considers the target type, sources, and non-transitive `LINKER_LANGUAGE`. Fixes: #18515
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx16
1 files changed, 7 insertions, 9 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 09c08d3..334c15b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -215,12 +215,11 @@ static bool cmVS10IsTargetsFile(std::string const& path)
return cmSystemTools::Strucmp(ext.c_str(), ".targets") == 0;
}
-static std::string computeProjectFileExtension(cmGeneratorTarget const* t,
- const std::string& config)
+static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
{
std::string res;
res = ".vcxproj";
- if (t->HasLanguage("CSharp", config)) {
+ if (t->IsCSharpOnly()) {
res = ".csproj";
}
return res;
@@ -315,8 +314,8 @@ void cmVisualStudio10TargetGenerator::Generate()
this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) {
return;
}
- const std::string ProjectFileExtension = computeProjectFileExtension(
- this->GeneratorTarget, *this->Configurations.begin());
+ const std::string ProjectFileExtension =
+ computeProjectFileExtension(this->GeneratorTarget);
if (ProjectFileExtension == ".vcxproj") {
this->ProjectType = vcxproj;
this->Managed = false;
@@ -1409,8 +1408,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
path += "/";
path += this->Name;
- path += computeProjectFileExtension(this->GeneratorTarget,
- *this->Configurations.begin());
+ path += computeProjectFileExtension(this->GeneratorTarget);
path += ".filters";
cmGeneratedFileStream fout(path);
fout.SetCopyIfDifferent(true);
@@ -3812,7 +3810,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
path = lg->GetCurrentBinaryDirectory();
path += "/";
path += dt->GetName();
- path += computeProjectFileExtension(dt, *this->Configurations.begin());
+ path += computeProjectFileExtension(dt);
}
ConvertToWindowsSlash(path);
Elem e2(e1, "ProjectReference");
@@ -3838,7 +3836,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
}
// Workaround for static library C# targets
if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) {
- referenceNotManaged = !dt->HasLanguage("CSharp", "");
+ referenceNotManaged = !dt->IsCSharpOnly();
}
if (referenceNotManaged) {
e2.Element("ReferenceOutputAssembly", "false");