Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake add target for invoking clang analyzer

I'd basically like to achieve the same as http://blog.alexrp.com/2013/09/26/clangs-static-analyzer-and-automake, but with CMake.

analyze_srcs = foo.c analyze_plists = $(analyze_srcs:%.c=%.plist) CLEANFILES = $(analyze_plists)  $(analyze_plists): %.plist: %.c   @echo "  CCSA  " $@   @$(COMPILE) --analyze $< -o $@  analyze: $(analyze_plists) .PHONY: analyze 

So you can run

make analyze make clean 

I guess I need to use add_custom_command/add_custom_target and somehow change the "object file" extension just for that target.

Afterwards get a list of the generated files to perhaps pass them to a script for combining them into 1 output file.

Can anyone point me in the right direction?

like image 501
Trass3r Avatar asked Sep 27 '13 12:09

Trass3r


1 Answers

You can use scan-build when running cmake.

scan-build cmake /path/to/source scan-build make 

scan-build sets the CC and CXX environment variables which are picked up by cmake.

like image 114
larsch Avatar answered Sep 18 '22 12:09

larsch