How to change qmake PREFIX location

For ~ QT 5:

In qmake the installation directory for the standard installation rules comes from the qmake variable target.path.

In general, qmake does not use a setting called PREFIX, although because this is the traditional term in Unix for the target installation directory, it is a popular enough convention for particular projects to create their own PREFIX variable for use within their project files (*.pro).

Take a look through the .pro files of the project and find out where target.path is set. If it is set from an environment variable, i.e.

target.path = $$(PREFIX)  # note the regular parentheses

then you can pass the value in the environment you run qmake in:

$ PREFIX=/path/to/my/dir qmake 

If it is set from a qmake property, i.e.

target.path = $$[PREFIX]  # note the square brackets

then you can set the property persistently for future qmake runs on the command line:

$ qmake -set PREFIX /path/to/my/dir

If it is set from an internal variable, it will look like

target.path = $$PREFIX

or

target.path = $${PREFIX}  # note the curly braces

There's no way to override the value of an internal variable from the qmake command line; you need to figure out where in the .pro file the internal variable is being set and make appropriate changes, perhaps by just editing the .pro file, or if there is some kind of logic there, figuring out how to have it choose a different value.


According to "qmake -h", this would set it globally:

qmake -set prefix /path/to/correct/dir