C++ static code analysis tools

Hi!

what’s the best way to include static code analysis into an c++ based project? Some tools can be called instead of the c++ compiler (but without a clean build not all c-files will be send to the analyzer) and some need only the cpp file names the project consist of…
does chaning the compiler executable for a specific toolchain trigger a rebuild? should I add logic as a function to get all source files and send them through an analyzer? (but then I don’t get all defines right if they are dynamically set during the build pre processing)