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. Qt Creator: Enforce a release-only build in the qmake .pro file?
Forum Updated to NodeBB v4.3 + New Features

Qt Creator: Enforce a release-only build in the qmake .pro file?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
2 Posts 1 Posters 57 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote last edited by Robert Hairgrove
    #1

    Using Qt Creator 17.0.2 on Linux Ubuntu with different Qt versions (5.15.13 and 6.4.x and greater, up to 6.9.3):

    I have a SUBDIRS project to build some static libraries for which I would like to only allow release builds.
    I have added these lines in the .pro files that are referenced by the SUBDIRS project:

    CONFIG -= debug debug_and_release
    CONFIG += release
    

    Then I check this:

    CONFIG(debug,debug|release):error("Only release builds of this library are allowed!")
    

    My default build directory template in "Preferences->Build & Run->Default Build Properties" looks like this:

    ../build/%{Project:Name}/Qt-%{Qt:Version}/%{BuildConfig:Name}
    

    So even though I check the build configuration in the .pro file, I get both Debug and Release versions of the libraries if I made the mistake of clicking the wrong box when I configure the project (i.e. the first time it is opened in Qt Creator when you are prompted to select your kit(s)). It also looks as if the actual libraries are not the same size, so probably not interchangeable.

    I can set this up for my own development environment, but there are other developers in this project who might have trouble getting this right. That is why I'd like to have the .pro file take care of this.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Robert Hairgrove
      wrote last edited by
      #2

      I found a usable workaround, but am open to other suggestions!

      The project file Libs.pro builds the three subprojects, one per library. I just wrapped everything in a test for debug:

      CONFIG(release,debug|release) {
      TEMPLATE = subdirs
      
      PROJECT_DIR = $$clean_path($${top_srcdir}/../)
      THIRD_DIR   = $${PROJECT_DIR}/3rd_party
      
      SUBDIRS = \
          $${THIRD_DIR}/A/A_lib.pro \
          $${THIRD_DIR}/B/B_lib.pro \
          $${THIRD_DIR}/C/C_lib.pro
      } else {
        error("Only release builds are allowed for these libraries! Please close Qt Creator, delete the 'Libs.pro.user' file and check your kit selection carefully.")
      }
      

      Works for me.

      1 Reply Last reply
      0
      • R Robert Hairgrove has marked this topic as solved

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved