[CMake] Re-running automoc all the time after #13494

Jan Kundrát jkt at flaska.net
Wed Jul 31 05:43:48 EDT 2013


Hi folks,
I am using out-of-tree builds with Trojita [1], a Qt application. My cmake version is 2.8.10.2 on Gentoo Linux using the default Makefile generator and GNU make.

Some of my .cpp files #include "ui_something.h", which are generated by moc. Other files are imported from 3rd party projects and directly include moc_*.cpp. In order to make this work, my code calls:

  include_directories(${CMAKE_CURRENT_BINARY_DIR})
  set(CMAKE_AUTOMOC True)

However, it looks that due to a fix for #13494 [2], moc gets re-run whenever I run `make`. The build system is apparently smart enough to not re-link everything, but it nonetheless takes at least 3.5 seconds of real time when using non-parallel builds (and 1.7 seconds when building with -j6, which I sometimes cannot use because I have "only" 4GB of RAM on this machine, Thinkpad T420s with i5-2520M and an Intel SSD).

I guess what I'm looking for is a way of telling cmake to add -I${CMAKE_CURRENT_BINARY_DIR} only when calling the actual compiler, not moc. Is that possible? Or shall I do it some other way?

I guess that I could probably split the static library I'm building into two units, one for the generated files and the other for actual sources, and set the include directory only when building the second library (via target-specific properties). I'm not sure how easy it is to persuade automoc to work in such a setup, though.

Another annoyance is that I want to support cmake 2.8.7 as well (that's what gets shipped with Ubuntu 12.04 LTS) which does not support target-specific includes. My cmake setup is annoyingly complicated due to this requirement already, and I'd like to keep it in a maintaineable state :). General comments on the readability of the existing cmake setup are much appreciated as well -- perhaps I'm doing something in a completely wrong way, after all.

With kind regards,
Jan

[1] http://quickgit.kde.org/?p=trojita.git&a=blob&h=4ac8397d028bec11e636affc72c2c014e8b8e756&hb=b870be05017674781bc52c48934c9800a6329493&f=CMakeLists.txt
[2] http://public.kitware.com/Bug/view.php?id=13494

-- 
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/


More information about the CMake mailing list