I could potentially use that, but then I’d have to fully “copy” an existing target and probably add a post “build” command as well.
PC Lint Plus comes helper scripts to configure it either via this JSON file, or by running an “imposter” compiler, which basically logs all compiler invocations to a text file.
I didn’t go with the “imposter”, because that would require me to reconfigure the CMake project with a special option set to use that fake compiler and I already had the compile_commands.json from CMake.
Let’s say I have a target created with add_library or add_executable, is there an easy way to create a target that copies all the configuration for those targets (e.g. source files, compiler defines, etc.) to which I can then add an override for the <LANG>_COMPILER_LAUNCHER?
The thing I really want to avoid is having our developers need to reconfigure just to run the SCA tools.
Another option I was considering was simply calling ninja -t compdb <rule> from a CMake script to generate the compile_commands.json for a specific target.
The downside is that I’d have to replicate the name of the <rule> based on the CMake target name and configuration.
Final thing I came across thus far is <LANG>_CPPCHECK which I think keeps all (or at least most) of the needed compiler arguments in tact.
Only downside is that it seems to always be combined with compiling a target.
In our CI pipeline, we typically build (mostly cross-compile for ARM Cortex-M targets) first in one container and run the SCA in another container afterwards (without reusing the cache and such). It would be a waste to recompile just to be able to run the SCA tooling.