I've been working on a program called RoboJournal for some time now and I'm trying to simplify the creation of source packages for Debian. When a user builds the program on Linux, qmake sets the install path to /usr/local/bin (which is as it should be for user-compiled programs) However, this causes problems when I create the Debian source package since all packaged executables are supposed to install to /usr/bin.
The easiest way to fix this problem is to edit the install path manually before making the source package but I would prefer to keep the codebase the same (having multiple variants of the codebase with the same version number always causes problems eventually).
It would be great if the package maintainer could just run something like qmake --package robojournal.pro
to create a makefile with the correct install path for packaging purposes. Meanwhile, omitting the --package
argument would still allow users to create a regular build.
Can this (or something similar) be done? I've checked the qmake documentation but I’ve found nothing on configuring a project file to allow qmake to accept custom Unix-style arguments.
You can achieve what you need by using the CONFIG variable. Anything can be added to the CONFIG variable and each of the options specified in the CONFIG variable can be used as a scope condition:
package {
message(Creating a makefile with the correct install path for packaging purposes...)
} else {
message(Creating a regular build...)
}
This provides you with a convenient way to customize project files and fine-tune the generated Makefiles. See Configuration and Scopes.
The list of values held by CONFIG can be extended on the command line. You can run qmake with or without "CONFIG+=package":
qmake "CONFIG+=package" robojournal.pro
qmake robojournal.pro