diff options
author | Brad King <brad.king@kitware.com> | 2018-11-01 11:36:14 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-11-01 11:36:39 (GMT) |
commit | d955b4f753d450ec10a2f928fcca1a91a50816ce (patch) | |
tree | 518196d26a2930e7fb89531f8ca235f26c7bade3 /Source | |
parent | 75b85133d8cccb5d2680b0817d8720c6860238b0 (diff) | |
parent | 9040df31e2da7db351d76dcc72568d44d0223f92 (diff) | |
download | CMake-d955b4f753d450ec10a2f928fcca1a91a50816ce.zip CMake-d955b4f753d450ec10a2f928fcca1a91a50816ce.tar.gz CMake-d955b4f753d450ec10a2f928fcca1a91a50816ce.tar.bz2 |
Merge topic 'fix-custom-target-with-csharp'
9040df31e2 Merge branch 'backport-fix-custom-target-with-csharp'
1acd1c2b50 CSharp: Fix regression in VS project type selection for custom target
a56edad6d6 CSharp: Fix regression in VS project type selection for custom target
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2549
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 28 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 6 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 16 |
5 files changed, 25 insertions, 29 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4cf9dd7..bddc3c4 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -855,7 +855,7 @@ void cmExportFileGenerator::SetImportDetailProperties( std::string propval; if (auto* p = target->GetProperty("COMMON_LANGUAGE_RUNTIME")) { propval = p; - } else if (target->HasLanguage("CSharp", config)) { + } else if (target->IsCSharpOnly()) { // C# projects do not have the /clr flag, so we set the property // here to mark the target as (only) managed (i.e. no .lib file // to link to). Otherwise the COMMON_LANGUAGE_RUNTIME target diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b8c9598..71947ea 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5716,20 +5716,23 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, } } -bool cmGeneratorTarget::HasLanguage(std::string const& language, - std::string const& config, - bool exclusive) const +bool cmGeneratorTarget::IsCSharpOnly() const { - std::set<std::string> languages; - this->GetLanguages(languages, config); - // The "exclusive" check applies only to source files and not - // the linker language which may be affected by dependencies. - if (exclusive && languages.size() > 1) { + // Only certain target types may compile CSharp. + if (this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::STATIC_LIBRARY && + this->GetType() != cmStateEnums::EXECUTABLE) { return false; } - // add linker language (if it is different from compiler languages) - languages.insert(this->GetLinkerLanguage(config)); - return languages.count(language) > 0; + std::set<std::string> languages; + this->GetLanguages(languages, ""); + // Consider an explicit linker language property, but *not* the + // computed linker language that may depend on linked targets. + const char* linkLang = this->GetProperty("LINKER_LANGUAGE"); + if (linkLang && *linkLang) { + languages.insert(linkLang); + } + return languages.size() == 1 && languages.count("CSharp") > 0; } void cmGeneratorTarget::ComputeLinkImplementationLanguages( @@ -6095,6 +6098,5 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType( // C# targets are always managed. This language specific check // is added to avoid that the COMMON_LANGUAGE_RUNTIME target property // has to be set manually for C# targets. - return this->HasLanguage("CSharp", config) ? ManagedType::Managed - : ManagedType::Native; + return this->IsCSharpOnly() ? ManagedType::Managed : ManagedType::Native; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4c32558..5e7cf12 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -372,11 +372,7 @@ public: void GetLanguages(std::set<std::string>& languages, std::string const& config) const; - // Evaluate if the target uses the given language for compilation - // and/or linking. If 'exclusive' is true, 'language' is expected - // to be the only language used in source files for the target. - bool HasLanguage(std::string const& language, std::string const& config, - bool exclusive = true) const; + bool IsCSharpOnly() const; void GetObjectLibrariesCMP0026( std::vector<cmGeneratorTarget*>& objlibs) const; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index a216346..3be09b0 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -98,7 +98,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, ext = ".vfproj"; project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \""; } - if (t->HasLanguage("CSharp", "")) { + if (t->IsCSharpOnly()) { ext = ".csproj"; project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \""; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index eb1a27e..e9a1a67 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -205,12 +205,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; @@ -305,8 +304,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; @@ -1398,8 +1397,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); @@ -3800,7 +3798,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"); @@ -3826,7 +3824,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"); |