In order to use flymake http://www.emacswiki.org/cgi-bin/wiki/FlyMake Makefile need target check-syntax as the following -------- .PHONY: check-syntax check-syntax: gcc -Wall -fsyntax-only $(CHK_SOURCES) -------- How to automatically generate this target in cmake?