Search code examples
qtqmake

How to make use of the INSTALL_ROOT that resides in generated Makefiles?


qmake generates the following (among the others) rule for installing a target:

-$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(TARGET)"

I cannot set INSTALL_ROOT with something like this in a *.pro file

isEmpty(INSTALL_ROOT) {
    INSTALL_ROOT=/usr
}

because INSTALL_ROOT is somehow local to generated Makefiles. According to what I've found out so far INSTALL_ROOT is empty by default. It could be used like

INSTALL_ROOT=$HOME make install

when invoking make, which is fine. However I want to be able to specify default installation root, say /usr. I can do it introducing a new variable PREFIX as suggested here. Then generated rule will look like (if PREFIX was set to /usr)

-$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/usr/$(TARGET)"

however

INSTALL_ROOT=$HOME make install

installs target to /home/<user_name>/usr/$(TARGET) which is not that one would expect.

So setting INSTALL_ROOT to some default value will produce consistent behavior, which is superior to adding PREFIX, but how to set INSTALL_ROOT in a *.pro file?

What is the purpose of INSTALL_ROOT is it supposed to be used at all?


Solution

  • I'm answering for Windows here. You appear to be using UNIX, Linux, or Mac OS X so you may have to make a few changes.

    INSTALL_ROOT is a poorly documented feature that appears to have been added so that those without root or admin access can install Qt in their local filesystem. It's actually a bit of a hack since, as you have already seen, it is not possible to specify an arbitrary target, but you can always move the files to the desired location afterwards.