0

I would wish to use qt5_wrap_cpp (much faster) than CMake's AUTOMOC feature, but I have a problem. In one of the libraries (other compile fine) some of generated moc files with qt5_wrap_cpp are missing declarations. For instance one of include header generated with AUTOMOC is nearly 7kb long, while moc generated for the same file with qt5_cpp_wrap is only 3kb in size. Because of that my compillation fails with

Sequences/CMakeFiles/Sequences.dir/Events/SequenceEventFactory.cpp.obj: In function `ZN13SequenceEvent7setNameERK7QString':
C:/Projects/p2/Sequences/Events/SequenceEvent.h:20: undefined reference to `SequenceEvent::nameChanged(QString)'

This happends only under Windows, while compilling with MinGW. Under Linux CMake and compillation using qt5_wrap_cpp works fine.

This is the code that des problems:

#include "../Containers/XmlObject.h"
#include "../sequences_global.h"
#include <QUuid>
class SequenceEvent;
typedef SequenceEvent* ( *CreateSequenceEvent )();
class SEQUENCESSHARED_EXPORT SequenceEvent : public XmlObject
{
    Q_OBJECT
    PRIVATE_PROPERTY( QUuid, id, id, setId, idChanged )
    PROPERTY( QString, name, name, setName, nameChanged )
protected:
    explicit SequenceEvent( QObject* parent = nullptr );
};

I'm using custom macro for PROPERTY:

#define PROPERTY( type, name, read, write, notify )                \
    Q_PROPERTY( type _##name READ read WRITE write NOTIFY notify ) \
private:                                                           \
    type _##name;                                                  \
                                                                   \
public:                                                            \
    type read() const                                              \
    {                                                              \
        return _##name;                                            \
    }                                                              \
Q_SIGNALS:                                                         \
    void notify( type name );                                      \
public slots:                                                      \
    void write( const type& val )                                  \
    {                                                              \
        if ( _##name != val )                                      \
        {                                                          \
            _##name = val;                                         \
            emit notify( val );                                    \
        }                                                          \
    }

Anyone could help me solve this puzzle? Thanks in advance.

1 Answers1

0

Solved. I was missing

TARGET ${PROJECT_NAME}

at the end of qt5_wrap_cpp macro.