Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to tell QMake to run a script after the build has finished?

Is there a way to tell QMake to run a script after the build has finished?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.5k 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.
  • C Offline
    C Offline
    Curtwagner1984
    wrote on last edited by
    #1

    Hello,

    I want to run a deployment script after the build has finished, if the build was set to the RELEASE setting.
    Is it possible to somehow tell QMake to run a script after it's done building?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/qmake-advanced-usage.html#adding-custom-targets

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Curtwagner1984
        wrote on last edited by
        #3

        Could you please elaborate? I don't quite understand what I should do.

        Let's say I have a python script called myscript.py in the $PWD of the project. What do I need to do to run it after the build is finished?

        I want to do something like

        ONCE_BUILDING_FINISHED_RUN_COMMAND ( $$system(python "$${PWD}/myscript.py" SOME_ARG)
        

        I admit that I don't quite understand how to do that from the link you provided.

        1 Reply Last reply
        0
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          https://stackoverflow.com/questions/49053544/how-do-i-run-a-python-script-every-time-in-a-cmake-build

          C 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            https://stackoverflow.com/questions/49053544/how-do-i-run-a-python-script-every-time-in-a-cmake-build

            C Offline
            C Offline
            Curtwagner1984
            wrote on last edited by
            #5

            @JoeCFD

            Thank you for the link. I still fail to understand what I have to do.

            add_custom_command(
                    OUTPUT
                        ${CMAKE_CURRENT_BINARY_DIR}/__header.h
                        ${CMAKE_CURRENT_BINARY_DIR}/header.h
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h
                    COMMAND python ${py_cmd}
            )
            

            As far as I understand, the relevant command here is COMMAND python ${py_cmd} and what tells it to run is the custom target? Also, I'm using QMake, is it the same?

            JoeCFDJ 2 Replies Last reply
            0
            • C Curtwagner1984

              @JoeCFD

              Thank you for the link. I still fail to understand what I have to do.

              add_custom_command(
                      OUTPUT
                          ${CMAKE_CURRENT_BINARY_DIR}/__header.h
                          ${CMAKE_CURRENT_BINARY_DIR}/header.h
                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h
                      COMMAND python ${py_cmd}
              )
              

              As far as I understand, the relevant command here is COMMAND python ${py_cmd} and what tells it to run is the custom target? Also, I'm using QMake, is it the same?

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by
              #6

              @Curtwagner1984 Sorry that is for cmake.

              C 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @Curtwagner1984 Sorry that is for cmake.

                C Offline
                C Offline
                Curtwagner1984
                wrote on last edited by
                #7

                @JoeCFD
                Maybe it's the same in QMake, the link @VRonin posted also has to do with adding a build target. Sadly I don't get exactly how to use it.

                1 Reply Last reply
                0
                • C Curtwagner1984

                  @JoeCFD

                  Thank you for the link. I still fail to understand what I have to do.

                  add_custom_command(
                          OUTPUT
                              ${CMAKE_CURRENT_BINARY_DIR}/__header.h
                              ${CMAKE_CURRENT_BINARY_DIR}/header.h
                          DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h
                          COMMAND python ${py_cmd}
                  )
                  

                  As far as I understand, the relevant command here is COMMAND python ${py_cmd} and what tells it to run is the custom target? Also, I'm using QMake, is it the same?

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #8

                  @Curtwagner1984 https://stackoverflow.com/questions/3612283/running-a-program-script-from-qmake

                  C 1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @Curtwagner1984 https://stackoverflow.com/questions/3612283/running-a-program-script-from-qmake

                    C Offline
                    C Offline
                    Curtwagner1984
                    wrote on last edited by
                    #9

                    @JoeCFD
                    From what I understand, QMAKE_POST_LINK will run a script after linking. but not after building. (IE, before the .exe file is generated).

                    The other solution there involves making an extra build target with a dummy cpp file like so:

                    TEMPLATE = lib
                    SOURCES = placeholder.cpp # <== dummy cpp
                    CONFIG += no_link staticlib
                    batch_runner.target   = placeholder.cpp
                    batch_runner.commands = my_batch_file.bat # <== script to be run
                    QMAKE_EXTRA_TARGETS   = batch_runner
                    

                    Is this the optimal solution?

                    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