From 8b21aa0af00a6366c301241bab081f2daae6104c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Oct 2018 14:50:23 -0400 Subject: 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 --- Source/cmVisualStudio10TargetGenerator.cxx | 8 +++++--- 1 file 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 languages; -- cgit v0.12