I have a QT project with that is built with CMake. One of the targets have 142 files that need to have moc
. When I use qt5_wrap_cpp
on source files and build it the process gets finished in around 15 seconds:
set(CMAKE_AUTOMOC NO)
qt5_wrap_cpp(moc_files ${source_files})
list(APPEND source_files ${moc_files})
target_sources("${target}" PRIVATE "${source_files}")
Here each task is invocation of moc
tool for every file.
However when I use AUTOMOC
feature generation time is increased to 6 minutes:
set(CMAKE_AUTOMOC YES)
target_sources("${target}" PRIVATE "${source_files}")
Here the cmake
task is roughly following:
cmake.exe -E cmake_autogen <my_project_path>/<my_project>_autogen.dir Debug
I've ran the command again and where there's nothing to generate it takes 0.3 seconds to run. However when I delete one moc-file the command takes 2 seconds to run. When it needs to generate 5 is:
TotalSeconds : 11.3493687
over 11 seconds. When I remove all the 142 moc files the execution time of cmake_autogen
is:
TotalSeconds : 354.5894649
I didn't manage to find anything regarding this in documentation and CMake issues. Is there anything I can do to run AUTOMOC
as efficient as individual file processing?
CMake version 3.10.2
Qt version 5.9.3
UPD 1.
After profiling CMake I've noticed that calling moc
is the most time consuming operation. It appeared that command line has 247 include paths which is not the case for qt5_wrap_cpp
.