Skip to content

Instantly share code, notes, and snippets.

@Tvangeste
Last active June 12, 2022 02:38
Show Gist options
  • Save Tvangeste/6249841 to your computer and use it in GitHub Desktop.
Save Tvangeste/6249841 to your computer and use it in GitHub Desktop.
Dependencies for qrc files.
<AdditionalDependencies Condition="'%(QtRCCCompile.AdditionalDependencies)' == ''">$(QTDIR)\bin\rcc.exe;$(MSBuildProjectFile)</AdditionalDependencies>
<Target Name="CalculateQtRCCDeps"
DependsOnTargets="SelectQtRCCCompile"
Outputs="%(QtRCCCompile.Identity)">
<Message Text="Calculating dependencies for %(QtRCCCompile.Identity)" />
<!-- Look into the qrc file and fetch all the referenced files -->
<XmlPeek XmlInputPath="%(QtRCCCompile.FullPath)"
Query="//file/text()">
<Output TaskParameter="Result" ItemName="QtRCCDeps" />
</XmlPeek>
<!-- Add the calculated dependencies to the AdditionalDependencies -->
<ItemGroup>
<QtRCCCompile>
<AdditionalDependencies>@(QtRCCDeps);%(QtRCCCompile.AdditionalDependencies)</AdditionalDependencies>
</QtRCCCompile>
</ItemGroup>
<Message Text="Actual Dependencies: @(QtRCCCompile->'%(AdditionalDependencies)')" />
</Target>
<Target
Name="QtRCCCompile"
Condition="'@(QtRCCCompile)' != ''"
DependsOnTargets="SelectQtRCCCompile;CalculateQtRCCDeps"
Inputs="@(QtRCCCompile);%(QtRCCCompile.AdditionalDependencies);"
Outputs="%(OutputFile)"
>
<StringListProperty
Name="AdditionalDependencies"
Subtype="file"
DisplayName="Additional Dependencies"
Description="Provide additional dependencies that affect the end result. Note: files, listed inside the QRC are determined automatically and should not be added manually."
IncludeInCommandLine="False"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment