diff options
author | Brad King <brad.king@kitware.com> | 2024-12-09 17:08:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-12-09 19:19:51 (GMT) |
commit | 57da8712c1527fa697e65dc823b09fb9de570d89 (patch) | |
tree | 04bfb2d31a2a393e743911dc83812153f2289858 | |
parent | 793c5f11f6863284ec1561970bee816037e40b91 (diff) | |
download | CMake-57da8712c1527fa697e65dc823b09fb9de570d89.zip CMake-57da8712c1527fa697e65dc823b09fb9de570d89.tar.gz CMake-57da8712c1527fa697e65dc823b09fb9de570d89.tar.bz2 |
VS: Factor out check for mixed C and C++ target
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 694976e..95ff7e6 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3354,6 +3354,14 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, langForClCompile, configName); } + bool const isCXXwithC = [this, &configName]() -> bool { + if (this->LangForClCompile != "CXX"_s) { + return false; + } + std::set<std::string> languages; + this->GeneratorTarget->GetLanguages(languages, configName); + return languages.find("C") != languages.end(); + }(); // Put the IPO enabled configurations into a set. if (this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName)) { @@ -3504,21 +3512,17 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } // Add C-specific flags expressible in a ClCompile meant for C++. - if (langForClCompile == "CXX"_s) { - std::set<std::string> languages; - this->GeneratorTarget->GetLanguages(languages, configName); - if (languages.count("C")) { - std::string flagsC; - this->LocalGenerator->AddLanguageFlags( - flagsC, this->GeneratorTarget, cmBuildStep::Compile, "C", configName); - this->LocalGenerator->AddCompileOptions(flagsC, this->GeneratorTarget, - "C", configName); - Options optC(this->LocalGenerator, Options::Compiler, - gg->GetClFlagTable()); - optC.Parse(flagsC); - if (const char* stdC = optC.GetFlag("LanguageStandard_C")) { - clOptions.AddFlag("LanguageStandard_C", stdC); - } + if (isCXXwithC) { + std::string flagsC; + this->LocalGenerator->AddLanguageFlags( + flagsC, this->GeneratorTarget, cmBuildStep::Compile, "C", configName); + this->LocalGenerator->AddCompileOptions(flagsC, this->GeneratorTarget, "C", + configName); + Options optC(this->LocalGenerator, Options::Compiler, + gg->GetClFlagTable()); + optC.Parse(flagsC); + if (const char* stdC = optC.GetFlag("LanguageStandard_C")) { + clOptions.AddFlag("LanguageStandard_C", stdC); } } |