5

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: qt5_wrap_cpp

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: AUTOMOC YES

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.

Teivaz
  • 5,462
  • 4
  • 37
  • 75
  • Did you already tried to use `set(CMAKE_AUTOMOC TRUE) set(CMAKE_AUTOUIC TRUE) set(CMAKE_AUTORCC TRUE)` and adding the forms, headers and resources to the target, e.g. `add_executable(target ${SOURCES} ${HEADERS} ${FORMS} ${RESOURCES})` instead of manually calling `cmake.exe -E cmake_autogen ...` for every single file? – vre Feb 12 '18 at 12:54
  • @vre That is exactly what I'm doing in the second case. I am not calling cmake for each file individually - I only call it separately to measure time it takes. `AUTOUIC` and `AUTORCC` have no effect here. Also forms are added automatically with `AUTOUIC` enabled. – Teivaz Feb 12 '18 at 13:01
  • Ah, now I see. I was misreading your post. – vre Feb 12 '18 at 13:17
  • You may post your thorough analysis to the CMake mailing list and ask there for help. Reading the release notes of CMake 3.11.0-rc1 it looks like it starts multiple MOC/UIC processes now for projects using AUTOMOC and AUTOUIC. – vre Feb 16 '18 at 08:11

0 Answers0