From 7dc930d40037c99d87b09de09a882d5f86f157d5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 6 Aug 2018 13:47:18 +0200 Subject: qmake vcxproj generator: Fix compilation of generated C++ sources Generated C++ source files with extensions other than .cpp would not get compiled, because the code ignored all other C++ source extensions like .cc and .cxx. Fix this by respecting the value of QMAKE_EXT_CPP and QMAKE_EXT_C. Task-number: QTBUG-69770 Change-Id: I097dfef6920e353a351c97891cdbfdc9a859815f Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 9f82ce4f8e..e58999bb97 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -1977,6 +1977,15 @@ bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, Xml return fileAdded; } +static bool isFileClCompatible(const QString &filePath) +{ + auto filePathEndsWith = [&filePath] (const QString &ext) { + return filePath.endsWith(ext, Qt::CaseInsensitive); + }; + return std::any_of(Option::cpp_ext.cbegin(), Option::cpp_ext.cend(), filePathEndsWith) + || std::any_of(Option::c_ext.cbegin(), Option::c_ext.cend(), filePathEndsWith); +} + void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &filePath, const QString &filterName) { @@ -2000,7 +2009,7 @@ void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, << attrTagS("Filter", filterName); xml << tag("ClInclude") << attrTag("Include", nativeFilePath); - } else if (filePath.endsWith(".cpp")) { + } else if (isFileClCompatible(filePath)) { xmlFilter << tag("ClCompile") << attrTag("Include", nativeFilePath) << attrTagS("Filter", filterName); -- cgit v1.2.3