CMake Pre-Build command

You’ve mentioned a “shadow source tree” a couple of times. Perhaps you are making assumptions. I run my formatting in-place, so the build just sees a normal, modified target. Yes, editors need to know about reloading externally modified files, but most editors handle that pretty well.

FWIW, my homegrown “ecosystem” has a script that is run as a custom CMake target that runs the formatter only on the modified files, to avoid introducing unrelated formatting changes. Or, using the git-clang-format model, another option is to only format the modified lines. But, obviously my script isn’t cross-platform, and so this is perhaps where you object to the lack of support in CMake?

Perhaps it is shortcomings in our toolchain, or my ignorance of them or any of a number of other limitations that don’t bear detailing, but I can’t agree with your assertion that what I want is “best” done as a separate target. On that, we will have to agree to disagree.