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 Answer 1

0

Solved. I was missing

TARGET ${PROJECT_NAME}

at the end of qt5_wrap_cpp macro.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.