Nominate our 2022 Qt Champions!

Run a task before resources compilation in Qt Creator

  • Hi all
    I need to run a task before resources compilation start (that is the first compilation starting). Create a new target and assign to PRE_TARGETDEPS and QMAKE_EXTRA_TARGETS doesn't work since RESOURCES compilation always start before, then execute my additoonal target task and after start normal sources compilation. I still din't find a way to have some task runned as first on compilation. Someone can help me?
    Thank you

  • Moderators

    Not sure, but maybe hacking around it with a custom compiler could help:

  • Interesting approach but doesn't work. Just tested and RESOURCES compilation always start before all...

  • Moderators

    OK, another idea :-)

    Add 2 new .pro files, like so:

    Then in main put this:

    CONFIG += ordered
    TEMPLATE = subdirs
    SUBDIRS = before yourCode

    And in handle all things you have to execute before kicks in. CONFIG+=ordered ensures that the .pro files will be executed in the same order they are specified.

    If that does not work, I'd say the only thing left is to create a shell script and run it manually before build (or maybe switch to cmake if it supports such use case).

  • At first thank you for your help sierdzio. ^_^

    Split project files in different part didn't like so much than, unfortunately, it seem the only way available is to execute manually my task before compilation phase as you suggested...

Log in to reply