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
This commit is contained in:
parent
f478fa633d
commit
8b21aa0af0
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user