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: single command for multiple targets
QtWS25 Last Chance

QMAKE_EXTRA_COMPILERS: single command for multiple targets

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 3.1k 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.
  • I Offline
    I Offline
    ivan.ilin
    wrote on last edited by
    #1

    Hi. I'm trying to integrate Shiboken generator into make process. For example there is simple description for my extra compiler in .pro file:
    @GENERATED_SOURCES = wrappers/class1_wrapper.cpp
    wrappers/class2_wrapper.cpp

    SHIBOKEN_FILE = . # Need to give some bogus input
    SHIBOKEN.input = SHIBOKEN_FILE
    SHIBOKEN.output = $$GENERATED_SOURCES
    SHIBOKEN.commands = shiboken <bla-bla-bla>
    SHIBOKEN.variable_out = SOURCES

    QMAKE_EXTRA_COMPILERS += SHIBOKEN@

    QMake generates the following Makefile's fragment:
    @wrappers/class1_wrapper.cpp: .
    shiboken <bla-bla-bla>@

    But there is no rule for class2_wrappers.cpp! It took only the first item of GENERATED_SOURCES list.
    It works fine when compilation process has 1 job. But if I run it with several jobs (e.g. make -j4), it will fail with
    @
    make: *** No rule to make target wrappers/class2_wrapper.cpp', needed by debug/.obj/wrappers/class2_wrapper.o'. Stop.
    make: *** Waiting for unfinished jobs....
    @

    It happens because a free job tries to compile class2_wrappers.cpp before shiboken has finished. So if I try to run make -j4 again, it will compile successfully. Of course, files listed in GENERATED_SOURCES do not exist before shiboken invocation.
    Is there any feature to specify one command for multiple targets? I mean, it should work like moc but moc is called once for each target, and I want to run the command once for several targets. I found only "combine" feature:
    @SHIBOKEN.CONFIG += combine@

    but it's opposite to what I need.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ivan.ilin
      wrote on last edited by
      #2

      I solved it via Makefile target pattern. Also, there is a trick with the SOURCES variable. QMake doesn't like when some source files don't exist :-)
      I've put an empty %_wrapper.cpp next to Makefile as qmake includes it into SOURCES.
      Here is simple code:

      @
      GENERATED_SOURCES = wrappers/class1_wrapper.cpp
      wrappers/class2_wrapper.cpp

      defineReplace(shibokenWorkaround) {
      SOURCES += $$GENERATED_SOURCES
      return("%_wrapper.cpp")
      }

      SHIBOKEN_FILE = . # Need to give some bogus input
      SHIBOKEN.input = SHIBOKEN_FILE
      SHIBOKEN.output_function = shibokenWorkaround
      SHIBOKEN.commands = shiboken <bla-bla-bla>
      SHIBOKEN.CONFIG = no_link # don't add the .cpp target file to OBJECTS
      SHIBOKEN.clean = dummy # don't remove the %_wrapper.cpp file by "make clean"

      QMAKE_EXTRA_COMPILERS += SHIBOKEN
      @

      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