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. How to create multiple build configurations in .pro

How to create multiple build configurations in .pro

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 3 Posters 643 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.
  • B Offline
    B Offline
    bsdillon
    wrote on last edited by
    #1

    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.HilkJ 1 Reply Last reply
    0
    • J.HilkJ 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

      B Offline
      B Offline
      bsdillon
      wrote on last edited by
      #5

      @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.HilkJ 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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
        0
        • B bsdillon

          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.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #3

          @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


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

          B 1 Reply Last reply
          2
          • B Offline
            B Offline
            bsdillon
            wrote on last edited by bsdillon
            #4

            @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
            0
            • J.HilkJ 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

              B Offline
              B Offline
              bsdillon
              wrote on last edited by
              #5

              @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.HilkJ 1 Reply Last reply
              1
              • B bsdillon

                @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.HilkJ Online
                J.HilkJ Online
                J.Hilk
                Moderators
                wrote on last edited by
                #6

                @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


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

                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