Using CMake you most likely use AUTOMOC. This takes care of running moc on the files which need this.
It does, however, come with one drawback, namely that all moc files are compile together, which means that touching any header with a Q_OBJECT in it results in lots and lots of code being recompiled.
By including the moc files in the .cpp files I went from 22 seconds to 5 seconds when recompiling after touching a simple header file.
This episode comes with a script to automate this plus a git hook to ensure you always remember to include the moc files.
Links:
* The source code: https://github.com/KDAB/KDToolBox/tre...
* CMake's AUTOMOC https://cmake.org/cmake/help/v3.9/pro...
* My episodes on git hooks: • My Git Hooks for C++/Qt Projects
0:00 Intro
0:18 What does moc do?
0:51 Details of all the steps when compiling using QMake
2:12 The core of the problem with QMake
2:49 Details for compiling using CMake
5:29 So why does CMake need to recompile the moc files?
6:11 What is the solution?
8:30 But I am already including moc_filename.cpp files....
9:59 The script to help you
10:43 Running the script
13:30 Outro
All QML tips and tricks videos : • QML Tips and Tricks
All Qt Widgets and more videos:
• Qt Widgets and more
About the host:
The video is presented by Jesper Pedersen, who started with Qt back when Qt was widgets only and the version was 1.44, which gives him 21 years of experience with Qt. Since 2000 he has taught almost 100 Qt classes, ranging from Qt Widgets to QML. Heck, Jesper even taught a few classes on QTopia Core — Trolltech's initial attempt at creating a phone stack. Today Jesper holds a fancy business title, but that doesn't prevent him from coding both in his job and in his spare time.
Every month our newsletter is featuring technical blogs on Qt, C++ and 3D topics: https://www.kdab.com/development-reso...
About KDAB:
KDAB offers experienced software experts to help you deliver functional, high-performing and innovative software across embedded, mobile and desktop platforms for projects using C++, Qt, QML/Qt Quick, OpenGL, Qt 3D and more. https://www.kdab.com/software-services
KDAB experts regularly take time out to deliver KDAB’s world class training, in-house or at open enrolment courses around the world. We are the market leaders for training in Qt, OpenGL and C++.
Contact us to find out more at [email protected] or visit our website: https://www.kdab.com/software-service...
We are about 90 people, located all around the world. Our Head Office is in Sweden and we have other offices in Germany, France, the UK and the USA. https://www.kdab.com/about/contact/