[SOLVED] How to specify different Debug/Release output directories in QMake .pro file


I have a Qt project and I would like to output compilation files outside the source tree.

I currently have the following directory structure:


Depending on the configuration (debug/release), I will like to output the resulting files inside the build directory under build/debug or build/release directories.

How can I do that using a .pro file?


The short answer is: you don’t.

You should run qmake followed by make in whatever build directory you want to build in. So, run it once in a debug directory, once in a release directory.

That’s how anyone building your project would expect it to work, and that’s how Qt itself is set up to build, that’s also how Qt Creator expects your .pro file to behave: it simply starts qmake and then make in the build folder for your target’s chosen configuration.

If you wish to create these folders and perform the two (or more) builds in them, you’ll need a top-level makefile, possibly created from a top-level project file via qmake.

It’s not uncommon to have more than two build configurations, so you’re unnecessarily committing yourself to only differentiating between a build and a release; you might have builds with different optimization levels, etc. The debug/release dichotomy is best left to rest in peace.

Answered By – Kuba hasn't forgotten Monica

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *