16

I used below commands to install some stuff.

qmake PREFIX=/path/to/my/dir
make
make install

However the path I gave was wrong, how do I update PREFIX to the right location and remove the old install, then install again?

I tried:

rm -rf /path/to/my/dir/bin    # this is where the program being installed
qmake PREFIX=/path/to/correct/dir
make
make install

But it's still being installed to the old path.

rakslice
  • 8,742
  • 4
  • 53
  • 57
Stan
  • 37,207
  • 50
  • 124
  • 185
  • 1
    Try removing the `qmake`-generated **Makefile** files, and then run `qmake` again with the corrected path. – radical7 Feb 01 '13 at 05:39

2 Answers2

13

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

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

tenfishsticks
  • 452
  • 5
  • 13
  • That's already been answered: `rm -rf /path/to/my/dir/bin # this is where the program being installed` – tenfishsticks Feb 10 '16 at 16:00
  • It's might be important, this command must be issued with out any other command parameters as suggested here: https://forum.qt.io/topic/4479/how-to-use-set-option-in-qmake – Andry Nov 22 '18 at 21:14
10

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.

rakslice
  • 8,742
  • 4
  • 53
  • 57
  • 1
    What if it is set in square brackets like `$$[PREFIX]`? Do you then use `qmake -set PREFIX VALUE` to set the value? – pooya13 Oct 10 '20 at 20:52
  • 1
    @pooya13 I added a section for that case, and yeah, that's a qmake property, so you can set it from the command line like that. – rakslice Oct 10 '20 at 22:51