How to use INSTALL_ROOT which is in the generated Makefiles?

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

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

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

 isEmpty(INSTALL_ROOT) { INSTALL_ROOT=/usr } 

because INSTALL_ROOT is somehow locally generated by Makefiles. According to what I have found so far, INSTALL_ROOT is empty by default. It can be used as

 INSTALL_ROOT=$HOME make install 

when calling make, which is great. However, I want to specify the default installation root, say /usr . I can do this by introducing a new PREFIX variable, as suggested here . Then the generated rule will look (if PREFIX was installed on /usr )

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

but

 INSTALL_ROOT=$HOME make install 

sets the target to /home/<user_name>/usr/$(TARGET) , which should not be expected.

Thus, setting INSTALL_ROOT for some default value will result in consistent behavior that 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?

+4
source share
2 answers

I am responsible for Windows here. You seem to be using UNIX, Linux, or Mac OS X, so you might need to make a few changes.

INSTALL_ROOT is a poorly documented function that appears to be added so that those without root or admin access can install Qt on their local file system. This is actually a bit of a hack, since, as you have already seen, it is impossible to specify an arbitrary target, but you can always move the files to the right place.

+3
source

INSTALL_ROOT is intended for use with package building systems such as NSIS, debian, or in any other way for batch processing of firmware and its delivery.

For this you want to get the result

 INSTALL_ROOT=$PWD/package_root make install 

to create a tree under $ PWD / package_root that accurately mimics this on your target system that you plan to deliver. Note that you need INSTALL_ROOT to be a full path (hence $ PWD), not a relative path.

When creating a package, you can compress this tree into an archive, and then the installation process simply decompresses the same tree into the target file system.

 $PWD/package_root/usr/bin/my_binary 

will be set to

 /usr/bin/my_binary 

for the purpose.

So, this is the answer to the question what is INSTALL_ROOT intended for. To answer how to specify a "default installation root", additional information is needed on what you want to achieve.

Take a look at the qmake -query result:

 sez@ubuntu-11.10 :~$ qmake -query QT_INSTALL_PREFIX:/usr QT_INSTALL_DATA:/usr/share/qt4 QT_INSTALL_DOCS:/usr/share/qt4/doc QT_INSTALL_HEADERS:/usr/include/qt4 QT_INSTALL_LIBS:/usr/lib/i386-linux-gnu QT_INSTALL_BINS:/usr/bin <snipped> QT_VERSION:4.7.4 

and using the INSTALLS variable in qmake: http://doc.qt.digia.com/qt/qmake-environment-reference.html#installs - and How to do I specify the input of the QMake INSTALLS variable?

By default, if you just do

 target.path = $$[QT_INSTALL_BINS] INSTALLS += target 

Then your binary will be installed anywhere qt considers the desired location, QT_INSTALL_BINS. You can, of course, change these defaults by setting target.path to something else. Qt supplies these paths, but it is up to you to use them or not.

You could do

 MY_DEFAULT_INSTALL=/opt/myproj somedocs.files = docs/index.html somedocs.path = $$MY_DEFAULT_INSTALL/docs target.path = $$MY_DEFAULT_INSTALL/bin INSTALLS += somedocs target 

for example, where MY_DEFAULT_INSTALL is one place in your .pro file that defines the default value for installations.

+5
source

Source: https://habr.com/ru/post/1384376/


All Articles