How to use CMake to build a Qt Plugin ?



  • Hello guys !

    I would like to use CMake instead of QMake in order to build a Qt Plugin. The plugin is correctly built when I use QMake. However, when using CMake, I get the following error :

    .../src/PluginName.hpp:16: Parse error at "IID"
    

    Where this line is the following:

    Q_PLUGIN_METADATA(IID "ID OF THE INTERFACE")
    

    My header declares those three lines:

    Q_OBJECT
    Q_PLUGIN_METADATA(IID "ID OF THE INTERFACE")
    Q_INTERFACES(NameOfTheInterface)
    

    It seems that moc doesn't parse correctly the header. I think I don't pass the correct options to moc in my CMakeLists.txt.

    In CMakeLists.txt, I already tried:

    1. To use qt5_wrap_cpp with the headers declaring the macro Q_OBJECT
    2. To set CMAKE_AUTOMOC to ON
    3. To set AUTOMOC to ON

    All of these always end with the same error (Parse error at IID).

    Thank you for your time!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.