I compile C++ code with msbuild
and I specify cl
options inside ClCompile
item. Something like...
<ItemGroup>
<ClCompile Include="something.cpp">
<FloatingPointModel>Precise</FloatingPointModel>
<WarningLevel>Level2</WarningLevel>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
The above is just an example. Now I want to print all options used for cl
invocation. The question is: How do I do that? My first attempt was to use something like the following:
<Target Name="WriteToFile" AfterTargets="ClCompile" >
<WriteLinesToFile File="$(OutDir)\log.txt" Lines="@(ClCompile)" Overwrite="true" />
</Target>
Sadly, this logs only filename (something.cpp
) and not the options.
Note that I'm aware that the compiler options are stored by Tracker.exe
in CL.command.*.tlog
file, but first, I don't want to rely on that as it's subject to change and second, I will most likely need to do some transformations later on. I also know that I could access individual options (like %(ClCompile.FloatingPointModel)
), but I don't want handle each option separately either.
Is there a better way to do this?