It is good to add:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
when using the AUTOMOC
feature. Furthermore, this
include_directories(
...
${QT_USE_FILE}
...
)
is a mistake. It should rather be:
include(${QT_USE_FILE})
Finally, you should only explicitly push sources to compilation, but not headers! As stated in the documentation:
If
Q_OBJECT
is in thefoo.h
(i.e.QObject
is declared in the header file), then in the correspondingfoo.cpp
don't forget to add#include "moc_foo.cpp"
, preferably at the end of the file;If
Q_OBJECT
is in thefoo.cpp
(i.e.QObject
is declared in the source file), then, again, in thefoo.cpp
itself don't forget to add#include "foo.moc"
, preferably at the end of the file.
Therefore, follow these recommendations and change
file(GLOB_RECURSE COMMON_SOURCE "*.hpp" "*.cpp")
to
file(GLOB_RECURSE COMMON_SOURCE "*.cpp")
You could also find my other answer helpful. Your question is very similar, so I'd recommend to search better before posting next time.
Good luck.