From 28955625a024d212758ca992c250ecf8f18462f3 Mon Sep 17 00:00:00 2001 From: Miguel Costa Date: Tue, 19 Dec 2017 15:15:49 +0100 Subject: Fix bugs in handling of .cpp moc source Reworked the property definition strategy for Qt/MSBuild properties (i.e. deciding when to set properties at project or item level). The previous approach did not handle correctly the case of .cpp moc files. Also fixed a bug in RefreshMocStep that was causing build failure with .cpp moc files when the moc output path was modified in the Qt Project Settings dialog. Change-Id: Icae4ffa7aa42e679a4cfcb87ee866dc8f7f01cf6 Reviewed-by: Oliver Wolff --- src/qtprojectlib/QtProject.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/qtprojectlib/QtProject.cs') diff --git a/src/qtprojectlib/QtProject.cs b/src/qtprojectlib/QtProject.cs index 69d18b9a..54aef57b 100644 --- a/src/qtprojectlib/QtProject.cs +++ b/src/qtprojectlib/QtProject.cs @@ -2575,7 +2575,7 @@ namespace QtProjectLib VCCustomBuildTool tool = null; VCFile mocable = null; var customBuildConfig = config; - if (isHeaderFile) { + if (isHeaderFile || vcfile.ItemType == QtMoc.ItemTypeName) { mocable = vcfile; if (vcfile.ItemType == "CustomBuild") tool = HelperFunctions.GetCustomBuildTool(config); @@ -2619,12 +2619,22 @@ namespace QtProjectLib StringComparison.OrdinalIgnoreCase) == -1) continue; - var srcMocFile = GetSourceFileForMocStep(mocable); - var cppFile = GetCppFileForMocStep(mocable); + VCFile srcMocFile, cppFile; + if (vcfile.ItemType == QtMoc.ItemTypeName + && HelperFunctions.IsSourceFile(vcfile.ItemName)) { + srcMocFile = cppFile = vcfile; + } else { + srcMocFile = GetSourceFileForMocStep(mocable); + cppFile = GetCppFileForMocStep(mocable); + } if (srcMocFile == null) continue; var mocableIsCPP = (srcMocFile == cppFile); + var cppItemType = (cppFile != null) ? cppFile.ItemType : ""; + if (cppFile != null && cppItemType != "ClCompile") + cppFile.ItemType = "ClCompile"; + string pchParameters = null; VCFileConfiguration defineIncludeConfig = null; CompilerToolWrapper compiler = null; @@ -2658,6 +2668,9 @@ namespace QtProjectLib pchParameters, outputFileName); + if (cppFile != null && cppItemType != "ClCompile") + cppFile.ItemType = cppItemType; + // The tool's command line automatically gets a trailing "\r\n". // We have to remove it to make the check below work. var origCommandLine = commandLine; -- cgit v1.2.3