Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QMAKE_EXTRA_COMPILERS and MOC
Forum Updated to NodeBB v4.3 + New Features

QMAKE_EXTRA_COMPILERS and MOC

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qmakeextracommake
2 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lexxmark
    wrote on 14 Feb 2016, 07:11 last edited by
    #1

    I have a problem using QMAKE_EXTRA_COMPILERS to generate source files for QObject derived classes.
    It seems like MOC compiler doesn't sees these generated files and project linking fails because of absent MOC generated functions for my classes.
    I have to re-run qmake to enforce MOC to generate *_moc.cpp files for my generated classes.

    Here is a little example of my source files generator.

    my_src_gen.name = My Source generator ${QMAKE_FILE_IN}
    my_src_gen.input = MY_SOURCES
    my_src_gen.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.my.cpp
    my_src_gen.commands = $$PWD/my_gen.bat ${QMAKE_FILE_IN} ${QMAKE_FILE_PATH}
    my_src_gen.CONFIG += target_predeps
    my_src_gen.variable_out = SOURCES
    silent:my_src_gen.commands = @echo my_src_gen ${QMAKE_FILE_IN} && $$my_src_gen.commands
    QMAKE_EXTRA_COMPILERS += my_src_gen
    

    There is a test example project QMAKE_EXTRA_COMPILERS_test (windows) where the problem is reproduced.

    How to avoid second qmake invocation there?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Emil
      wrote on 27 Sept 2017, 20:57 last edited by
      #2

      I had the same problem, solved it by making a new compiler that uses the generated header file as input and runs moc on it to generate the missing source file. From my .pro:

      dbc2cpp_canbus_h.name = Generating canbus.h from DBC file.
      dbc2cpp_canbus_h.CONFIG += combine
      dbc2cpp_canbus_h.input = "DBC_A_C"
      dbc2cpp_canbus_h.output = canbus.h
      dbc2cpp_canbus_h.commands = bash -c 'dbc2cpp --target CANBUS_H CLUSTER <($${DBC_A_GIT}) <($${DBC_C_GIT})'
      dbc2cpp_canbus_h.variable_out = HEADERS
      QMAKE_EXTRA_COMPILERS += dbc2cpp_canbus_h

      CANBUS_H = canbus.h
      new_moc.commands = moc $(DEFINES) $(INCPATH) canbus.h -o ${QMAKE_FILE_OUT}
      new_moc.input = "CANBUS_H"
      new_moc.output = moc_canbus.cpp
      new_moc.variable_out = SOURCES
      QMAKE_EXTRA_COMPILERS += new_moc

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved