sil2100//vx developer log

Welcome to my personal web page

Empty

QMake. Forcing no install target AKA target flags

I had an annoying problem today to which I finally found a workaround for. Let's assume we're using qmake and the 'testcase' CONFIG for a given target. Strangely, whenever the testcase configuration is used for a given project, all test targets are generated with their 'make install' targets in the Makefile (if the Makefile generator is used, of course). Even when we're not adding the target to INSTALLS. But what if we don't want to install the given testcase anywhere? Qt4 ant Qt5 docs say nothing. But the qmake source code says all.

2013-07-10 19:13

Normally if you have a qmake project and don't want the install routine to be generated for a given target, you simply do not add it to the INSTALLS variable. But the CONFIG += testcase option forces the install routines on you, don't know why excatly. It's annoying, because the default install path for those is like /usr/tests, which is a non-standard directory. Besides, when building Debian packages, you only need to run unit tests during the build process - there is no need for them to be lying around a user's filesystem later.
So, how to force "I do not want to install this target" in qmake? Let's see the example:


 CONFIG += testcase
 TARGET = foo

 SOURCES = foo.c

 # Now, the solution:
 # Let's inform qmake that we don't want a default install target AT ALL,
 # even if we somehow said otherwise before
 target.CONFIG += no_default_install

All we need to do is set the target CONFIG flag no_default_install. This forces qmake not to create an install target at all.

There are other interesting target flags I found as well, such as: dummy_install, no_path or no_check_exist. Too bad there seems to be no documentation for those. I hate when there is functionality that is used but not explicitly visible otherwise. To solve my problem, I actually had to get into the source code and check for the feature I need inside, which usually means the documentation is lacking.