Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to create multiple build configurations in .pro

    Tools
    3
    6
    235
    Loading More Posts
    • 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.
    • B
      bsdillon last edited by

      I am trying to create four different buid configurations and use my .pro to set up configuration differences between them. I put the full details in a stackoverflow question (https://stackoverflow.com/questions/63082818/how-to-create-multiple-build-configurations-in-qt).

      The problem is that I am not getting different builds. I have a debug and a release, but I cannot get it to create the non-GUI version of debug and release. This is what I expected to work.

      build_pass:CONFIG(Debug) {
      message("this is a debug build")
      TARGET = "Project_D"
      message($${TARGET})
      DESTDIR = $$HOME/debug
      }
      
      build_pass:CONFIG(DebugHeadless) {
      message("this is a debug build")
      TARGET = "Project_HEADLESS_D"
      message($${TARGET})
      DESTDIR = $$HOME/debug
      }
      
      build_pass:CONFIG(Release) {
      message("this is a release build")
      TARGET = "Project"
      message($${TARGET})
      DESTDIR = $$HOME/release
      }
      
      build_pass:CONFIG(ReleaseHeadless) {
      message("this is a release build")
      TARGET = "Project_HEADLESS"
      message($${TARGET})
      DESTDIR = $$HOME/release
      }
      

      But the messages indicate it is not working.

      Project MESSAGE: this is a release build
      Project MESSAGE: Project
      Project MESSAGE: this is a debug build
      Project MESSAGE: Project_D
      

      What is the right .pro syntax to create four distinct builds in different configurations?
      What is the right command line syntax to force of of the four builds (I think I'm already getting all)?

      J.Hilk 1 Reply Last reply Reply Quote 0
      • B
        bsdillon @J.Hilk last edited by

        @J-Hilk Okay. That at least got me in the right area. My inherited code used buildpass, but you were right that the CONFIG function was the key. You really should get the credit on stackoverflow.

        My final solution has CONFIG both to determine if it is build/release and to determine if it is GUI/NoGUI.

        CONFIG(GUI)}
          ... add GUI-related details
          CONFIG(release, debug|release){
            message("Project")
            ... add release details
          }
          CONFIG(debug, debug|release){
            message("ProjectD")
            ... add debug details
          }
        }
        
        CONFIG(NoGUI)}
          ... exclude GUI-related details
          CONFIG(release, debug|release){
            message("Project_HEADLESS")
            ... add release details
          }
          CONFIG(debug, debug|release){
            message("Project_HEADLESS_D")
            ... add debug details
          }
        }
        
        J.Hilk 1 Reply Last reply Reply Quote 1
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          Where is DebugHeadless coming from ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @bsdillon last edited by J.Hilk

            @bsdillon you're in luck, I've been fighting with qmake and *pro files for the last couple of days, and should be able do help here :D

            First of, you're supposed to check for debug or release build in this way:

            CONFIG(release, debug|release)  {
            #Release build
            }
            
            CONFIG(debug, debug|release) {
            #Debug build
            }
            

            and you can use the requires check, to check for your own CONFIG += DebugHeadless

            requires(DebugHeadless) {
             #Debug headless build
            }
            

            That's how I'm using it, and how its finally working for me :D

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            B 1 Reply Last reply Reply Quote 2
            • B
              bsdillon last edited by bsdillon

              @SGaist I defined two additional build configurations in the Project tab. DebugHeadless and Headless are the names of those configurations.

              @J-Hilk Okay, that makes a little more sense. I saw that in other documentation, but I believed you could select which build you wanted at that point. Alright. I'm away from my computer (at 12:48am local time), but I will try that as soon as I get back. If you have a stackoverflow account, you might as well get the credit for a good answer there.

              1 Reply Last reply Reply Quote 0
              • B
                bsdillon @J.Hilk last edited by

                @J-Hilk Okay. That at least got me in the right area. My inherited code used buildpass, but you were right that the CONFIG function was the key. You really should get the credit on stackoverflow.

                My final solution has CONFIG both to determine if it is build/release and to determine if it is GUI/NoGUI.

                CONFIG(GUI)}
                  ... add GUI-related details
                  CONFIG(release, debug|release){
                    message("Project")
                    ... add release details
                  }
                  CONFIG(debug, debug|release){
                    message("ProjectD")
                    ... add debug details
                  }
                }
                
                CONFIG(NoGUI)}
                  ... exclude GUI-related details
                  CONFIG(release, debug|release){
                    message("Project_HEADLESS")
                    ... add release details
                  }
                  CONFIG(debug, debug|release){
                    message("Project_HEADLESS_D")
                    ... add debug details
                  }
                }
                
                J.Hilk 1 Reply Last reply Reply Quote 1
                • J.Hilk
                  J.Hilk Moderators @bsdillon last edited by

                  @bsdillon Gerate, that you managed to make it work! (Correctly) Setting up a pro file is no easy task and often very frustrating.

                  Sometimes I wonder, if I shouldn't just make the change to cmake, eventually it's going to happen.

                  You really should get the credit on stackoverflow.

                  I do have a stackoverflow, account, I made it years ago to thank someone for a solution and to make an upvote. No idea if it's still valid :D

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post