aboutsummaryrefslogtreecommitdiffstats
path: root/src/qtprojectlib/MsBuildProject.cs
diff options
context:
space:
mode:
authorMiguel Costa <miguel.costa@qt.io>2018-03-15 15:02:31 +0100
committerMiguel Costa <miguel.costa@qt.io>2018-03-23 09:54:00 +0000
commit41966c712db87b252d83593c391951453cc45987 (patch)
tree81e2d1213c72e122227973d00b438b88ea346b6f /src/qtprojectlib/MsBuildProject.cs
parentf69211db53eee06ec3c6ed8d38a134e77499445d (diff)
Disable dynamic C++ source if already included
When converting from custom build to Qt/MSBuild, if a moc header does not have a corresponding generated file, disable the dynamic C++ source for that moc header. This is needed for the case when the moc output is #include'd in the associated source file instead of being compiled on its own. Task-number: QTVSADDINBUG-530 Change-Id: Iae136ff6a14c867ed3250aa255b0681b77bcc29e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/qtprojectlib/MsBuildProject.cs')
-rw-r--r--src/qtprojectlib/MsBuildProject.cs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/qtprojectlib/MsBuildProject.cs b/src/qtprojectlib/MsBuildProject.cs
index 76faae2a..aca3f4a8 100644
--- a/src/qtprojectlib/MsBuildProject.cs
+++ b/src/qtprojectlib/MsBuildProject.cs
@@ -374,7 +374,7 @@ namespace QtProjectLib
return ouputFile;
}
- void RemoveGeneratedFiles(
+ bool RemoveGeneratedFiles(
List<CustomBuildEval> cbEvals,
string configName,
string itemName,
@@ -382,6 +382,7 @@ namespace QtProjectLib
IEnumerable<XElement> filterItems)
{
//remove items with generated files
+ bool hasGeneratedFiles = false;
var cbEval = cbEvals
.Where(x => x.ProjectConfig == configName && x.Identity == itemName)
.FirstOrDefault();
@@ -396,11 +397,13 @@ namespace QtProjectLib
outputItems.AddRange(filterItems
.Where(x => HelperFunctions.PathEquals(
outputFile, (string)x.Attribute("Include"))));
+ hasGeneratedFiles |= outputItems.Any();
foreach (var item in outputItems)
item.Remove();
}
}
}
+ return hasGeneratedFiles;
}
public bool ConvertCustomBuildToQtMsBuild()
@@ -508,12 +511,14 @@ namespace QtProjectLib
Path.GetDirectoryName(this[Files.Project].filePath))) {
return false;
}
+ List<XElement> mocDisableDynamicSource = new List<XElement>();
foreach (var qtMoc in mocCustomBuilds.Elements(ns + QtMoc.ItemTypeName)) {
var itemName = (string)qtMoc.Attribute("Include");
var configName = (string)qtMoc.Attribute("ConfigName");
//remove items with generated files
- RemoveGeneratedFiles(cbEvals, configName, itemName, projectItems, filterItems);
+ var hasGeneratedFiles = RemoveGeneratedFiles(
+ cbEvals, configName, itemName, projectItems, filterItems);
//set properties
qtMsBuild.SetItemProperty(qtMoc,
@@ -526,6 +531,8 @@ namespace QtProjectLib
QtVSIPSettings.GetMocDirectory()));
qtMsBuild.SetItemProperty(qtMoc,
QtMoc.Property.DynamicSource, "output");
+ if (!hasGeneratedFiles)
+ mocDisableDynamicSource.Add(qtMoc);
} else {
qtMsBuild.SetItemProperty(qtMoc,
QtMoc.Property.OutputFile, string.Format(@"{0}\%(Filename).moc",
@@ -589,6 +596,13 @@ namespace QtProjectLib
qtMsBuild.EndSetItemProperties();
+ //disable dynamic C++ source for moc headers without generated files
+ //(needed for the case of #include "moc_foo.cpp" in source file)
+ foreach (var qtMoc in mocDisableDynamicSource) {
+ qtMsBuild.SetItemProperty(qtMoc,
+ QtMoc.Property.DynamicSource, "false");
+ }
+
FinalizeProjectChanges(mocCustomBuilds.ToList(), QtMoc.ItemTypeName);
FinalizeProjectChanges(rccCustomBuilds.ToList(), QtRcc.ItemTypeName);
FinalizeProjectChanges(uicCustomBuilds.ToList(), QtUic.ItemTypeName);