vs_link_exe interferes with RULE_LAUNCH_LINK on Windows
I am trying to integrate a static analysis tool into my team's build. The tool works similarly to ccache by wrapping and instrumenting compiler and linker invocations:
myanalyzer <analysis args> cl.exe file.cpp ...
myanalyzer <analysis args> link.exe ...
The RULE_LAUNCH_COMPILE
and RULE_LAUNCH_LINK
properties seem a perfect fit for this scenario, and indeed adding my analysis command to RULE_LAUNCH_COMPILE
works perfectly and allows me to instrument and analyze all the compiler invocations in my build.
However, instrumenting linker calls is proving to be quite difficult. The issue is that, on Windows, CMake generates calls to an internal wrapper command rather than to link.exe
itself. So when I specify a launcher command using RULE_LAUNCH_LINK
, the build system ends up running this command:
myanalyzer <analysis args> cmake.exe -E vs_link_exe <wrapper args> -- link.exe ...
This causes myanlayzer
to fail because it cannot interpret the linker command line. Intuitively, I would have expected my launcher command to be placed after the --
but before link.exe
:
cmake.exe -E vs_link_exe <wrapper args> -- myanalyzer <analysis args> link.exe ...
Is there some easy way to achieve this? Or some way to bypass the vs_link_exe
wrapper altogether?
(For what it's worth, I'm using the Ninja generator.)