summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-01 15:26:35 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-02 18:58:11 (GMT)
commit375b420fdfe4eb34e92b98bb648ba37de3691c2e (patch)
treedd9fefe53eae946d7b80394d931090cb62635318 /Source
parent8b21aa0af00a6366c301241bab081f2daae6104c (diff)
downloadCMake-375b420fdfe4eb34e92b98bb648ba37de3691c2e.zip
CMake-375b420fdfe4eb34e92b98bb648ba37de3691c2e.tar.gz
CMake-375b420fdfe4eb34e92b98bb648ba37de3691c2e.tar.bz2
CSharp: Fix regression in VS project type selection
A that target contains only `.cs` sources should be generated as a `.csproj` project even if it links to non-CSharp static libraries. 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) enforces its "exclusive" check on the combined set of source file languages and the link language. To restore the original `TargetIsCSharpOnly` semantics, update `HasLanguage` to enforce exclusiveness only on the list of sources. Fixes: #18239
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx8
-rw-r--r--Source/cmGeneratorTarget.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index b223c5e..8aab1be 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5227,10 +5227,14 @@ bool cmGeneratorTarget::HasLanguage(std::string const& language,
{
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) {
+ return false;
+ }
// add linker language (if it is different from compiler languages)
languages.insert(this->GetLinkerLanguage(config));
- return (languages.size() == 1 || !exclusive) &&
- languages.count(language) > 0;
+ return languages.count(language) > 0;
}
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 2132b15..2810887 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -366,7 +366,7 @@ public:
// 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 for the target.
+ // 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;