summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-02 18:50:23 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-02 18:58:11 (GMT)
commit8b21aa0af00a6366c301241bab081f2daae6104c (patch)
treed19379897392b9ecf8ee0f7e027ad23d2457d5cb /Source/cmVisualStudio10TargetGenerator.cxx
parentf478fa633daeb1432805821adddc40730ffd283d (diff)
downloadCMake-8b21aa0af00a6366c301241bab081f2daae6104c.zip
CMake-8b21aa0af00a6366c301241bab081f2daae6104c.tar.gz
CMake-8b21aa0af00a6366c301241bab081f2daae6104c.tar.bz2
VS: Fix CSharp flag selection when linking to a static C++ library
When a CSharp target links to a static C++ library, CMake will compute the link language as C++ instead of CSharp. That may be incorrect and needs further investigation, but it does not affect how VS drives C# linking. However, it does break our flag language selection logic and causes C++ flags to be used for CSharp. In particular, this drops the `-platform:x86` flag on 32-bit builds. Fix this by always selecting the CSharp flags when generating a `.csproj` project type. Issue: #18239
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index f472d8a..b8b04ae 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2413,10 +2413,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
// Choose a language whose flags to use for ClCompile.
- static const char* clLangs[] = { "CXX", "C", "Fortran", "CSharp" };
+ static const char* clLangs[] = { "CXX", "C", "Fortran" };
std::string langForClCompile;
- if (std::find(cm::cbegin(clLangs), cm::cend(clLangs), linkLanguage) !=
- cm::cend(clLangs)) {
+ if (this->ProjectType == csproj) {
+ langForClCompile = "CSharp";
+ } else if (std::find(cm::cbegin(clLangs), cm::cend(clLangs), linkLanguage) !=
+ cm::cend(clLangs)) {
langForClCompile = linkLanguage;
} else {
std::set<std::string> languages;