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. Saving value from Custom Proccess Step (Build Steps)
Forum Update on Monday, May 27th 2025

Saving value from Custom Proccess Step (Build Steps)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 543 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
    MrShawn
    wrote on last edited by
    #1

    Hi guys,

    I am playing around with custom build steps. I have an executable which does some action for me that I want to happen when I build my program.

    I have tried using system() in the .pro file, the executable is called successfully from the .pro file but there are some issues.
    First is I noticed it is called 3 times (after some research I noticed its because there are more than one makefiles generated).
    Second is that the .pro file doesn't seem to be run(?) on every build. I have to run qmake manually to get it to run the executable.
    Due to those reasons I have decided to try calling it in a custom step. This step is run every time.
    The call is successful but what I cannot do now is save the cout value from the executable for use in my qt c++ project.

    I need to display the string from the .exe's cout in the compiled program. Is there a way I can either force qmake one time on a build everytime, OR save the cout value from the executable like i can from $$system() in the .pro file?

    Thanks,
    Shawn.

    aha_1980A 1 Reply Last reply
    0
    • M MrShawn

      Hi guys,

      I am playing around with custom build steps. I have an executable which does some action for me that I want to happen when I build my program.

      I have tried using system() in the .pro file, the executable is called successfully from the .pro file but there are some issues.
      First is I noticed it is called 3 times (after some research I noticed its because there are more than one makefiles generated).
      Second is that the .pro file doesn't seem to be run(?) on every build. I have to run qmake manually to get it to run the executable.
      Due to those reasons I have decided to try calling it in a custom step. This step is run every time.
      The call is successful but what I cannot do now is save the cout value from the executable for use in my qt c++ project.

      I need to display the string from the .exe's cout in the compiled program. Is there a way I can either force qmake one time on a build everytime, OR save the cout value from the executable like i can from $$system() in the .pro file?

      Thanks,
      Shawn.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @MrShawn said in Saving value from Custom Proccess Step (Build Steps):

      I need to display the string from the .exe's cout in the compiled program.

      So in principle the same question as this one: https://stackoverflow.com/questions/5946896/how-to-execute-shell-command-after-compile-finished-from-pro-in-qt ?

      Is there a way I can either force qmake one time on a build everytime,

      Yeah, by adding a qmake command that is executed on make rather than on qmake, see e.g. here: http://doc.qt.io/qt-5/qmake-advanced-usage.html#adding-custom-targets

      OR save the cout value from the executable like i can from $$system() in the .pro file?

      Where should the output be save?

      Personally, I think adding these steps in the .pro file is better, as it just works after cloning to another machine or building without Creator (e.g. in Jenkins).

      Regards

      Qt has to stay free or it will die.

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

        Okay @aha_1980,
        First, thanks for responding, I got busy friday with actual work so I didn't get to respond sooner. I am trying to take the .pro approach.

        I looked at the resources you linked and I am still pretty lost. Trying to make sense of it without much progress.
        I see things being added to my makefiles. But I do not see those portions being executed.

        I added to the .pro file (this is from your second link):

        mytarget.target = .buildfile
        mytarget.commands = touch $$mytarget.target
        mytarget.depends = mytarget2
        
        mytarget2.commands = @echo Building $$mytarget.target
        
        QMAKE_EXTRA_TARGETS += mytarget mytarget2
        

        I run qmake and build and do not see the output from the echo at all.

        What I am not seeing is how it gets called. Am I supposed to add another step to call the new targets? From both links, and a 3rd (https://stackoverflow.com/questions/29853832/adding-custom-commands-to-existing-targets-in-qmake) it looks straight forward but nothing seems to be happening.

        Thanks

        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