summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-15 13:22:15 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-18 19:34:17 (GMT)
commit3b547e2e4bc084ce26b8493ce37ef7d8806fe477 (patch)
treef6e40350ac69db32996a4985c8cead77022b1daf /Source/cmVisualStudio10TargetGenerator.cxx
parent27ead9d4b77c3f84dd07e762aae3e2473beeb423 (diff)
downloadCMake-3b547e2e4bc084ce26b8493ce37ef7d8806fe477.zip
CMake-3b547e2e4bc084ce26b8493ce37ef7d8806fe477.tar.gz
CMake-3b547e2e4bc084ce26b8493ce37ef7d8806fe477.tar.bz2
VS: Simplify logic adding source file C/C++ language flag to MSVC
Do not add a target-wide language flag. We need a flag on an individual source file to explicitly specify the C or C++ language if and only if the source file extension does not imply it.
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx28
1 files changed, 7 insertions, 21 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index df960b5..97f7093 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2318,21 +2318,13 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmGeneratorExpression::Find(*cincludes) != std::string::npos;
includes += *cincludes;
}
- std::string lang =
- this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
- std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
- const std::string& linkLanguage =
- this->GeneratorTarget->GetLinkerLanguage("");
- bool needForceLang = false;
- // source file does not match its extension language
- if (lang != sourceLang) {
- needForceLang = true;
- lang = sourceLang;
- }
- // if the source file does not match the linker language
- // then force c or c++
+
+ // Force language if the file extension does not match.
+ std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf);
const char* compileAs = 0;
- if (needForceLang || (linkLanguage != lang)) {
+ if (lang !=
+ this->GlobalGenerator->GetLanguageFromExtension(
+ sf.GetExtension().c_str())) {
if (lang == "CXX") {
// force a C++ file type
compileAs = "CompileAsCpp";
@@ -2341,6 +2333,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
compileAs = "CompileAsC";
}
}
+
bool noWinRT = this->TargetCompileAsWinRT && lang == "C";
// for the first time we need a new line if there is something
// produced here.
@@ -2737,13 +2730,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
langForClCompile, configName);
}
- // set the correct language
- if (linkLanguage == "C") {
- clOptions.AddFlag("CompileAs", "CompileAsC");
- }
- if (linkLanguage == "CXX") {
- clOptions.AddFlag("CompileAs", "CompileAsCpp");
- }
// Put the IPO enabled configurations into a set.
if (this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName)) {