I'm using Qt 5 and I put all my headers in separate include folders, and AUTOMOC is unable to find my headers.
src
|- sim
|- include
|- sim
|- client.h (contains Q_OBJECT)
|- client.cpp
My CMake Code:
set(CMAKE_AUTOMOC ON)
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
add_library(client client.cpp)
target_include_directories(client PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(client sim Qt5::Widgets)
This results in undefined references to my signals because the QObject MOC class in client is not being generated. I tried adding this to force it to search for client.h...
#include "moc_client.cpp"
However then I get the error
AutoMoc error
-------------
"/home/peter/projects/smartmouse/smartmouse-simulator/src/sim/client.cpp"
The file includes the moc file "moc_client.cpp", but the header "client.{h,hh,h++,hm,hpp,hxx,in,txx}" could not be found.
I get why this is, because the docs only say it searches the current folder so it's not going to look int the include/sim
folder. My question is how do I get AUTOMOC to find include/sim/client.h?
I also tried using qt5_wrap_cpp but it doesn't seem to actually call the moc compiler, it only sets up some information. I tried:
qt5_wrap_cpp(client include/sim/client.h)
But it did not generate any cmake targets as far as I can tell
EDIT:
I've also noticed in the AutogenInfo.cmake
file that no header is found: set(AM_HEADERS "")