summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-12 14:06:31 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-12 14:06:37 (GMT)
commit81ea5eb63753cbba8018d62fbb1d6218868ee8fa (patch)
treeadaa46a964c7f819d1e593a03486754eb2efc7e5 /Source
parentd42011e3cf274b5a204d64360fba72552fcc6fde (diff)
parent5c04e77e0792c0a704ec4d7c2bb228750d37d060 (diff)
downloadCMake-81ea5eb63753cbba8018d62fbb1d6218868ee8fa.zip
CMake-81ea5eb63753cbba8018d62fbb1d6218868ee8fa.tar.gz
CMake-81ea5eb63753cbba8018d62fbb1d6218868ee8fa.tar.bz2
Merge topic 'vs-lang-C' into release-3.18
5c04e77e07 VS: Restore compilation of '.C' sources as C++ Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4880
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 97c4c85..a3ccd2b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2321,11 +2321,14 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
// Force language if the file extension does not match.
+ // Note that MSVC treats the upper-case '.C' extension as C and not C++.
+ std::string const ext = sf.GetExtension();
+ std::string const extLang = ext == "C"
+ ? "C"
+ : this->GlobalGenerator->GetLanguageFromExtension(ext.c_str());
std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf);
const char* compileAs = 0;
- if (lang !=
- this->GlobalGenerator->GetLanguageFromExtension(
- sf.GetExtension().c_str())) {
+ if (lang != extLang) {
if (lang == "CXX") {
// force a C++ file type
compileAs = "CompileAsCpp";