cmake and auto-generated sources

René J.V. Bertin rjvbertin at gmail.com
Tue Oct 9 11:23:48 BST 2018


[re-sending amended version to the intended destination, apologies to Friedrich]

So, I have had some feedback on Qt's Interest ML, which only confirms what we already know: with cmake all automatic content is only generated during a full make. Idem with qmake, with some subtle differences.

Still waiting to hear if it would be *possible* to change this, but in the meantime we have one possible workaround, using a compiler option I used to use before I started using IDEs with syntax parsing: -fsyntax-only . A quick test shows that this argument is still supported by clang 6 and gcc 8. Simply adding it to the existing compiler command causes processing to stop after the syntax checking stage.

My old experience tells me that this can be a few orders of magnitude faster than doing a full code generation, and of course it doesn't actually generate any output in the build.dir. There's no reason that would have changed; I guess a full "build" with -fsyntax-only will be somewhat faster than a full no-change re-build using ccache.

I'll be checking this with a copy of KDevelop's sources, adding the option to CMAKE_C{,XX}_FLAGS . It will probably be necessary to run the build step with make -k because something is bound to complain about the missing object files. Even then I'm not certain the build will continue after encountering the first missing library target dependency.

After trying I'm certain: the 1st build (with -j4 -k) went to about 16% in 6'15" minutes (through KDevelop). That's slower than I hoped, even on a not-exactly-fast Intel N3150. A second run *outside* of KDevelop took that down to 5'38" minutes (and of course went just as far). The few sub-targets I tried to "build" this way also failed because of missing dependencies before they got to generating their own automatic content (ex. the KDevPlatformProject plugin).

This could probably go further if cmake had some kind of support for -fsyntax-only, where linker errors (due to missing files) are ignored. That could be a more generically useful option to propose to Kitware than some kind of solution to do all auto-generation through a dedicated build target, which they might (justifiably) consider as something to be handled at the Qt (and KDE?) level.

R.



More information about the KDevelop mailing list