AutoMoc: AutogenInfo.json's MOC_INCLUDES lists should not include every transitive dependency's include directory by default
Hello,
My project uses Cmake's AUTOMOC and develops using Visual Studio Windows (multi-config solution file generation with Cmake). We have many Qt projects, and in many cases our dependency graphs are very large.
I have discovered that AUTOMOC is slowing down our build times by as much as 80% due to scanning unncessary include paths. It seems the default behavior is to scan every single directory marked as an include directory for each project, including the include directories of its linked dependency projects. For example, in the AutogenInfo.json
files generated by Cmake during solution generation, the MOC_INCLUDES_<CONFIG>
lists contain not only the include directories that belong to the project being compiled, but also every include directory transitively inherited that belong to its dependency projects.
In my opinion, this does not feel like acceptable default behavior. We have cases where this list contains over 100 folders. In reality, we only need a single folder in this list: The currently-compiling project's include directory (in my case, ${CMAKE_CURRENT_SOURCE_DIR}/include
). As an experiment, I have tested manually modifying every project's generated AutogenInfo.json file to only include this single folder, and everything compiles and runs successfully, and 80% faster, too.
Maybe I am misunderstanding something, but I don't know why AUTOMOC would need to run on sources that aren't part of the currently compiling project. In my case, all of the Qt files that need to be moc'd in the project's transitive include directory list have already been AUTOMOC'd before (we're building our tools as DLL, so all dependency projects build before the depender builds, if that matters?). So it is wasting massive amounts of time rescanning all of those every time, as Visual Studio builds up the dependency graph.
Is my thinking solid here? From what I can tell, it is not possible to modify the MOC_INCLUDES
list(s) with CMake.
If true, can this feature be added? Thanks for your time!