[CMake] support for -fsyntax-only (and generating Qt/KDE's auto-generated content)

René J. V. Bertin rjvbertin at gmail.com
Tue Oct 9 15:36:10 EDT 2018


Sylvain Joubert wrote:

> My use case is for static analysis builds. For example, my CI setup has
> multiple of them including cppcheck, clang-tidy and iwyu through the
> CMake integration. And since I'd like to keep separate builds for each
> of them this requires 3 full build whose results I don't really care.

Are you thinking of tools that are invoked instead of the compiler, like clazy-
standalone? I thought about mentioning a potential interest of my idea for using 
such tools (but forgot in the end).

Specific support for -fsyntax-only may not be relevant for those tools, but a 
build mode where the final step of each build product is not taken would probably 
be useful there, indeed. Such a mode might even create an empty file with the 
intended name, so that there's something to refer to later during a build.

I've been considering to write a little wrapper one could "inject" using 
CMAKE_<LANG>_COMPILER_LAUNCHER but there is no equivalent for the final product 
generation step (linker, librarian).

> 
> So if we can achieve a light build mode, that would be great. In my case
> I could completely deactivate the build part including the syntax
> checking since that's done by the static analysis tools anyway.

You'd get that by setting your analysis tool as the compiler.

> Anyhow, we can't deactivate all the build. As you said auto-generated
> content, custom targets,... would need to stay.

And besides, cmake's goal is to create files with which one can build projects. 
Generating something that doesn't attempt to build at all could well require a 
lot more implementation effort than pretending the linker/librarian step always 
succeeds.

FWIW, I notice that the link step now takes the form

cmake -E cmake_link_script CMakeFiles/<target>.dir/link.txt

IOW there are 2 levels where linker errors due to missing objects can be 
intercepted: in the link.txt script, and in cmake itself.

R.



More information about the CMake mailing list