diff options
author | Brad King <brad.king@kitware.com> | 2020-06-11 18:03:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-11 18:15:18 (GMT) |
commit | 5c04e77e0792c0a704ec4d7c2bb228750d37d060 (patch) | |
tree | 080c160f00b7e96355e3174d9737fe387ac9bd42 /Source | |
parent | 01fb8d7993f2ebcc47ce8ecab1aa5144a4ca4b80 (diff) | |
download | CMake-5c04e77e0792c0a704ec4d7c2bb228750d37d060.zip CMake-5c04e77e0792c0a704ec4d7c2bb228750d37d060.tar.gz CMake-5c04e77e0792c0a704ec4d7c2bb228750d37d060.tar.bz2 |
VS: Restore compilation of '.C' sources as C++
Refactoring in commit 3b547e2e4b (VS: Simplify logic adding source file
C/C++ language flag to MSVC, 2020-05-15, v3.18.0-rc1~139^2~1) failed to
account for MSVC's treatment of `.C` extensions as C. Add this special
case to the logic to restore use of `-TP` for `.C` extensions.
Fixes: #20822
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 9 |
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"; |