How to change qmake PREFIX location

11,843

Solution 1

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

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

Solution 2

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.

Share:
11,843

Related videos on Youtube

Stan
Author by

Stan

Updated on September 25, 2022

Comments

  • Stan
    Stan over 1 year

    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.

    • radical7
      radical7 over 11 years
      Try removing the qmake-generated Makefile files, and then run qmake again with the corrected path.
  • tenfishsticks
    tenfishsticks about 8 years
    That's already been answered: rm -rf /path/to/my/dir/bin # this is where the program being installed
  • Andry
    Andry over 5 years
    It's might be important, this command must be issued with out any other command parameters as suggested here: forum.qt.io/topic/4479/how-to-use-set-option-in-qmake
  • pooya13
    pooya13 over 3 years
    What if it is set in square brackets like $$[PREFIX]? Do you then use qmake -set PREFIX VALUE to set the value?
  • rakslice
    rakslice over 3 years
    @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.