summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-09-28 20:26:12 (GMT)
committerBrad King <brad.king@kitware.com>2020-09-29 11:26:36 (GMT)
commitb3254849284f973316a4ffef2d8f7851642c6413 (patch)
treed9e15266a6611e0c3fadde635a483367cb067c18 /Source/cmVisualStudio10TargetGenerator.cxx
parent39677de5e209445c8cbc5957c1e79088d5d2a03a (diff)
downloadCMake-b3254849284f973316a4ffef2d8f7851642c6413.zip
CMake-b3254849284f973316a4ffef2d8f7851642c6413.tar.gz
CMake-b3254849284f973316a4ffef2d8f7851642c6413.tar.bz2
VS: Fix C language standard in target with C++ sources
Add C-language standard to target-wide C++ settings. Fixes: #21195
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ae4a5be..a7b90b4 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2868,6 +2868,23 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
}
+ // Add C-specific flags expressible in a ClCompile meant for C++.
+ if (langForClCompile == "CXX") {
+ std::set<std::string> languages;
+ this->GeneratorTarget->GetLanguages(languages, configName);
+ if (languages.count("C")) {
+ std::string flagsC;
+ 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);
+ }
+ }
+ }
+
// Add a definition for the configuration name.
std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
clOptions.AddDefine(configDefine);