 <p>You could use the automoc feature of CMake like this:</p> <pre><code>set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(Display MainWindow.cpp SpiderEditor.cpp OutputPane.cpp) qt5_use_modules(Display Widgets Core) </code></pre>