CMake AutoMoc Usage

Hellow everyone,

I have a question about qt signals in header file.

In documentaion to cmake i read which file will be proccessed by auo-moc:

"For all C++ source files <source_base>.<source_extension> in the target’s sources, CMake searches for

  • a regular header with the same base name (<source_base>.<header_extention>)"

Am I correct that two files, source and header must be in same directory?

What should I do if the sources and headers in different directory?

Best Regards, thx a lot !

I guess autogen wouldn’t support that based on the docs. Does it work if you list the headers explicitly?

Yes, it works if I list the headers explicitly for the target with the command “add_libraray”/“qt5_wrap_cpp”.
​ What I want to do is separate the interface files from the implementation files, the interface files will not appear in the IDE project list. CMake organizes interface files paths for implementation files references.
​But the interface files contain Q_OBJECT, and AutoMoc does not recognize the Q_OBJECT of the interface files while listing in the Project’s CMakeLists, so the link error occurs.

I meant if you listed the headers explicitly in the source list without any qt5_wrap_cpp usage. If not, it sounds like something that autogen would need a new feature in order to support.