Hi Bernhard,

I use plain .pro and .pri files with qmake to Visual Studio projects.  Moc has a feature that prevents the output files being treated as separate compiles - if it finds the include in the relevant module .cpp.  It works really well for us with thousands of modules.  I not sure how that work flow translates to Qt Creator.

If you add

#include <moc_spinbox.cpp>

as the second line in spinbox.cpp, and then run qmake or whatever the Creator equivalent is.  After that, the moc steps will run as normal, and then the compile of spinbox.cpp without a separate compile for moc_spinbox.cpp.

Hope that helps,

Tony


On 27/08/2020 5:40 am, Bernhard Lindner wrote:
Hi!

Currently I am facing a problem with a Qt Creator managed Qt 5 project.

The projects consists of a lot of modules and implements a special but useful 
file
concept. Each module has 3 files:
    module.hpp - Public types, macros and declarations
    module.inl - Template function definitions, constexpr and inline function 
definitions
    module.cpp - All other definitions
module.cpp includes module.inl and module.inl includes module.hpp.

I added all .hpp file names to the .pro file using Qt Creator. All moc relevant 
.hpp files
are parsed fine by moc and a moc_module.cpp file is generated for each module 
as usual.
Unfortunately the moc_module.cpp files includes module.hpp only, since 
module.inl are
unknown to moc.
So all function definitions from moc_module.inl are unknown during compilation 
of
moc_module.cpp and I get undefined reference linker errors (e.g. for property 
related
setters called in the moc_module.cpp code).

Maybe I could use a lot of Q_MOC_RUN preprocessor conditions to work around but 
that would
pollute the code awfully.

How can I solve this problem on the moc side? Is there a way to tell moc via 
the .pro
project on a per-module basis to include module.inl instead of (or along with) 
module.inl
in moc_module.cpp?

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to