Setting default make options for Qt Creator?
Asked Answered
G

4

20

How can i override default make parameters , which is:

make -w

Each time i create a project , i had to modify project settings , adding -j4 to make parameters.

Can i set make -w -j4 by default ?

EDIT

The best way to do this is setting MAKEFLAGS environment variable , i'm picking the only answer as the best only to shut this thread down.

To set this for UNIX, modify the *.desktop file of Qt Creator , prefix the line entitled Exec= with env MAKEFLAGS=-j4 , but be aware that you won't be able to cease building in QtCreator immediately after setting to multithread.

Goggleeyed answered 14/1, 2012 at 6:59 Comment(2)
Hint: you can simply write -j, it chooses the number of threads automatically, which you typically want (maybe not always).Henryk
@Henryk this is often dangerous, for with complex cmake-generated projects this turns into a fork bomb and crashes my PC.Degenerate
B
23

In the qtcreator go to the "Projects tab" and set "Make arguments" as you like: enter image description here

Bharat answered 16/1, 2012 at 10:1 Comment(5)
And also for further reference: Qt Creator Build SetupBharat
As per the question EDIT, this should not be the correct answer.Filibeg
This is the best answer, but that field isn't there on recent versions (e.g. v4.7).Niggling
@Niggling I disagree. In v4.7.0 and v4.7.1 it is there, once I click the Details button.Panpipe
is it possible to put this setting in the .pro file of MyQtApp somehow?Karolyn
I
26

To make it global and permanent go to

Tools > Options > Build & Run > Kits > (pick your toolchain) 

and fill your predefined env settings: MAKEFLAGS=-j4

Screenshot what to click exactly

Ignacia answered 17/3, 2016 at 11:28 Comment(1)
This is now at: Tools > Options > Kits > (pick your toolchain) > EnvironmentPauperize
B
23

In the qtcreator go to the "Projects tab" and set "Make arguments" as you like: enter image description here

Bharat answered 16/1, 2012 at 10:1 Comment(5)
And also for further reference: Qt Creator Build SetupBharat
As per the question EDIT, this should not be the correct answer.Filibeg
This is the best answer, but that field isn't there on recent versions (e.g. v4.7).Niggling
@Niggling I disagree. In v4.7.0 and v4.7.1 it is there, once I click the Details button.Panpipe
is it possible to put this setting in the .pro file of MyQtApp somehow?Karolyn
M
12

If you want -jx parameter to be default each time you create a new or open some project, you must add enviroment variable MAKEFLAGS to your system with value -jx.

For example, at ubuntu for 8 - threding compilation this options can be realized by adding

MAKEFLAGS="-j8"

to /etc/enviroments

Result will be: enter image description here

Melesa answered 9/1, 2013 at 16:30 Comment(2)
Hint: you can simply write -j, it chooses the number of threads automatically, which you typically want (maybe not always).Henryk
I tried "-j". It doesn't work. It says: "no process count specified for option -j"Girand
K
2

After attempting implement the fix described in the question I eventually found the following (clearly this in only a solution to linux's that use the freedesktop concept of .desktop files):

The line in "/usr/local/share/applications/Nokia-QtCreator.desktop" was:

Exec=/opt/qtcreator-2.5.2/bin/qtcreator.sh %F

I changed it to:

Exec=env MAKEFLAGS=-j16 /opt/qtcreator-2.5.2/bin/qtcreator.sh %F

And got the functionality requested in the question.

Ok, I have no idea why following the instructions in the question I didn't get there but I didn't. I hope this explanation will help someone.

Kaylenekayley answered 10/12, 2012 at 4:14 Comment(2)
Hint: you can simply write -j, it chooses the number of threads automatically, which you typically want (maybe not always).Henryk
I find that -j selects a number slightly too low for optimal compile speed. -j is close enough, but I like as fast as possible.Kaylenekayley

© 2022 - 2024 — McMap. All rights reserved.