Reputation: 4677
I have defined a custom build step in a Visual Studio 2019 C++ project file (.vcxproj) that generates .h and .cc files. There is a Custom Build Tool option entitled "Add Outputs to Item Type", where I can select one of "C/C++ header" or "C/C++ compiler". Is there some way to edit the resulting project file such that the .cc files are added as "C/C++ compiler" and the .h files are added as "C/C++ header"?
My intended work-around is to simply remove the generated .h files from the list of Custom Build Tool outputs. That work-around has the disadvantage that the build will fail if one of the .h files is missing or stale. I'm hoping for a solution that resolves this deficiency.
The following illustrates what I have attempted within the .vcxproj file:
<OutputItemType Condition="'%(Extension)'=='.cc'">ClCompile</OutputItemType>
Upvotes: 0
Views: 711
Reputation: 28086
Not sure about how you define the Custom Build Step
. But custom build step is not the only way.
For C++ projects, msbuild provides Custom Build Tool, Custom Build Step, Build events and custom targets. You can achieve same requirements by this script:
<Target Name="CustomTarget" BeforeTargets="PrepareForBuild">
<Exec Command="xx.exe ..."/> <!--Call the tool.exe to generate files somewhere. We can save them in temp folder.-->
<Copy SourceFiles="xxx" DestinationFolder="xxx"/> <!--Use copy task to copy the generated files to project folder-->
<ItemGroup>
<ClCompile Include="Path of Temp folder\*.cc" />
</ItemGroup>
</Target>
And see this, I checked some related documents and confirm OutputItemType
is something about ProjectReference
. I'm not sure if this syntax supports other Items.
Upvotes: 1