Search code examples
qtqt-creatorqmake

How can I pass a command line CONFIG parameter to qmake from QtCreator?


I have a script used for CI builds that adds a CONFIG variable to qmake when building via Linux. I need to do the same for Windows desktop devs from within QtCreator. This needs to be an optional (every now and then) thing, rather than the default. Hence why it is not in the .pro file permanently.

Is this possible? And if so, how do I do it?

Edit:

Example of my situation is:

base.pro

 SUBDIRS = common base

 DESKTOP {
  SUBDIRS += app
 }

 CI {
  SUBDIRS += app support_tools
 }

Build Script:

 #!/bin/bash
 qmake -makefile -r -Wall CONFIG+=CI
 make

So what I'd like to be able to do is to (occasionally) do the CI style build from within QtCreator. In other words, I just need to be able to pass the additional CONFIG entry to qmake.

Yes, the users could edit the pro file, but that's annoying and has the chance of getting mistakenly committed. It doesn't seem like much of an ask to be able to pass something to qmake from Creator, but I couldn't see where.


Solution

  • You do that in the build settings of the project. You just add CONFIG+=CI in the qmake build step (click the "Details" button to expand it). Once you're done with testing, just remove it again. Or you can create a dedicated CI build configuration that always adds CONFIG+=CI. Although in your case, you probably just want to temporarily add that, build, and then remove it again.