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. Howto have a pre-build target generated by qmake

Howto have a pre-build target generated by qmake

Scheduled Pinned Locked Moved Qt Creator and other tools
5 Posts 2 Posters 7.0k 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.
  • M Offline
    M Offline
    moellney
    wrote on last edited by
    #1

    Hi Forum

    Gain:
    Let qmake gerenate a Makefile that calls a pre-build process.

    I would like to have a Makefile generated that contains a rule

    all: pre_build_process Makefile.Debug $(TARGET)

    pre_build_process could do something with files that $(TARGET) might depend upon, e.g. change a header file that contains the current subversion revision number.

    Would be glad to get an answer on this.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      "QMAKE_EXTRA_TARGETS":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#qmake-extra-targets or "QMAKE_EXTRA_COMPILERS":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#qmake-extra-compilers should help here. The following "blog":http://labs.qt.nokia.com/2008/04/16/the-power-of-qmake/ contains some more details on these variables.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        moellney
        wrote on last edited by
        #3

        [quote author="sigrid" date="1308209643"]"QMAKE_EXTRA_TARGETS":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#qmake-extra-targets or "QMAKE_EXTRA_COMPILERS":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#qmake-extra-compilers should help here. The following "blog":http://labs.qt.nokia.com/2008/04/16/the-power-of-qmake/ contains some more details on these variables.[/quote]

        Thanks for your answer, but my problem is, that every time I hit 'make' this pre-build-process should be started.

        With the examples in your links you get the extra compiler runs once, but not a second time, because the output files are there in the second run (as long as the input files don't change).

        But in my scenario the to be created (output) file might change from 'make' to 'make' with out a dependency on a file, but more on the outcome of svnversion which is used to create the output file.

        Any idea on this?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sigrid
          wrote on last edited by
          #4

          If you are using QMAKE_EXTRA_COMPILERS then you can use "depend_command":http://doc.qt.nokia.com/latest/qmake-environment-reference.html#customizing-makefile-output or depends to set an extra dependency on the compiler to force it to build again.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            moellney
            wrote on last edited by
            #5

            [quote author="sigrid" date="1308306646"]If you are using QMAKE_EXTRA_COMPILERS then you can use "depend_command":http://doc.qt.nokia.com/latest/qmake-environment-reference.html#customizing-makefile-output or depends to set an extra dependency on the compiler to force it to build again.[/quote]

            Thanks for this hint.

            However I ran into deep problem with the different makefile generators:

            • make (linux)
            • nmake
            • jom
            • msbuild

            It seems to be not possible to trigger an extra build for these for backends with one generic pro file.

            I finally ended up in:

            @

            Rules to update a header file: windows_version_revision.rc with the current svn revision.

            Have an qmake extra compiler called for each run of make to update windows_version_revision.rc,

            but only if needed, to prevent dependent compiles.

            A special script is used: update_svn_revision (for details look into the script)

            - replace placeholders in windows_version_revision.rc.SubWCRev with the current svn revision number

            - output a temporary file and if this is different to windows_version_revision.rc, then copy it over (updating the time stamp)

            It is importand to have the .variable_out set to HEADERS so that the Makefile rules recognize the dependency on the

            windows_version_revision.rc

            To trigger this conditional update of windows_version_revision.rc we need a dependency with an extra target that is never fullfilled.

            This forces make to call this target each time.

            .depends on extra target: preprocesssvnrev_check

            preprocesssvnrev_check.commands just echos

            However under windows everything is different:

            have special handling for MS IDE backend

            there we need an extra PRE_TAGETDEPS that must not be used under nmake

            nmake on the other side does not recognize that the conditional touched file was not touched in each nmake

            and fires a relink anyway, while jom does not .... clever jom :-)

            create the resource file from a template.

            PREPROCESS_FILES = windows_version_revision.rc.SubWCRev
            preprocesssvnrev.name = "Update svn revision number in windows_version_revision.rc (if needed)."
            preprocesssvnrev.input = PREPROCESS_FILES
            preprocesssvnrev.output = ${QMAKE_FILE_BASE}

            update revision from the current directory

            win32:preprocesssvnrev.commands = $${PWD}/update_svn_revision.bat $${PWD} $${PWD}/${QMAKE_FILE_IN} $${PWD}/${QMAKE_FILE_BASE}
            unix: preprocesssvnrev.commands = @sh $${PWD}/update_svn_revision.sh $${PWD} $${PWD}/${QMAKE_FILE_IN} $${PWD}/${QMAKE_FILE_BASE}

            trigger creation when outside MS IDE (part 1)

            contains(TEMPLATE,lib) {
            preprocesssvnrev.variable_out = HEADERS
            preprocesssvnrev.depends = preprocesssvnrev_check

            message (Creating extra dependencies for nmake/make)

            }

            QMAKE_EXTRA_COMPILERS += preprocesssvnrev

            trigger creation when inside MS IDE

            contains(TEMPLATE,vclib) {

            message (Creating extra dependencies for MS IDE)

            PRE_TARGETDEPS += compiler_preprocesssvnrev_make_all
            }

            trigger creation when outside MS IDE (part 2)

            contains(TEMPLATE,lib) {
            preprocesssvnrev_check.commands = @echo Trigger conditional svn revision update.
            preprocesssvnrev_check.CONFIG += recursive
            QMAKE_EXTRA_TARGETS += preprocesssvnrev_check

            message (Creating extra dependencies for nmake/make)

            }
            @

            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