Pietro
Pietro

Reputation: 13150

How to change build directory in QtCreator?

I have a cmake based C++ project done with QtCreator. I wrote the CMakeLists.txt files manually. When building either from the command line of from QtCreator, I get this directory structure, as expected:

MyProj/            - source code
MyProj_build/      - object files and executable; I launch cmake from here

Now I would like the build directory to be on a different disk (a ram disk):

/PathToRamDisk/MyProj_build/

When building from the command line, I launch cmake/make from the new build directory, and all the generated files are located in that directory. Fine.

From QtCreator, even if I change the build path to the new one (Options/Build & Run/General/Default build directory), the build is still done in the old directory. Is there another path to change? Where?

Platform: QtCreator 3.3.0, Mac OSX

Upvotes: 16

Views: 29968

Answers (4)

Mr. Developerdude
Mr. Developerdude

Reputation: 9648

In QtCreator preferences ("Edit" --> "Preferences...") search for "build directory" and you will find this setting:

Change default build directory template for new projects in QtCreator

Upvotes: 0

Goddard
Goddard

Reputation: 3059

Excellent answer, I just wanted to add to it a bit. If you are using Qt Creator and want to setup your own project folder as the build directory you can use something like this.

%{CurrentProject:NativePath}/build/

I prefer this personally as it keeps everything contained in the project directory. Other variables exist as well.

Also recently, newer versions of Qt have another little button on the right hand side of the "build directory" input field. It is has like a blue arrow on mine. Click it and you can view all the global build variables.

Upvotes: 9

Garcia Sylvain
Garcia Sylvain

Reputation: 396

You can change default build directory template By changing the Default build directory setting in Options->Build & Run.

Or directly in ~/.config/QtProject/QtCreator.ini:

[...]

[Directories]
BuildDirectory.Template=.../%{JS: Util.asciify("build/%{CurrentProject:Name}/%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}")}

[...]

Upvotes: 9

Cui Heng
Cui Heng

Reputation: 1285

You can click the Project button on the left side of QtCreator, then you can specify the output directory. Notice, the default is for debug version, you need to specify the release version folder either. output folder

Once you set a different folder, you will see that you need to rerun the cmake command to generate these files. This should work, I also use it on Mac.

Upvotes: 24

Related Questions