qmake set arbitrary makefile variable from qmake
Hi.
I want to set some arbitrary variable in the makefile generated by qmake. How can I do this? I can't imaging this can't be done but can't find mention of it anywhere.
Use case; I want to generate a makefile compatible with the GNU stds, which entails defining vars in the make file such as "prefix" that can be overridden when running the make file. So for example my .pro would look like:
Code:
TEMPLATE = app
TARGET = foo
CONFIG += ...
CCFLAGS += -g
prefix=/usr/local/
exec_prefix=$(prefix)
bindir=$(exec_prefix)/bin
datarootdir=$(prefix)/share
datadir=$(datarootdir)
libdir=$(exec_prefix)/lib
...
But I need most of those variables exported to the Makefile.
Thanks.
Re: qmake set arbitrary makefile variable from qmake
Hmm, since your example is prefix, that is usually passed to qmake.
qmake, like e.g. configure, preforms the build configuration step, which generates a Makefile that is then "executed" by make.
Cheers,
_
Re: qmake set arbitrary makefile variable from qmake
Thx for the reply.
So your saying I should use qmake like configure and do something like `qmake "prefix=/usr/local"`. The particular reason I wanted to set in the make file is that its going to be more compatible with trying to build a debian package from the source with `dh`, rather than the dh seeing hardcoded /usr/local/ prefixes, it can set the prefix(s) itself. I think these issues can be worked around by dh anyway, and I'm finding the way to go about packaging Qt apps with dh is to make dh work with qmake not qmake work for dh.
Still, I would like to know if its possible to set variables in the qmake generated Makefile directly.
Re: qmake set arbitrary makefile variable from qmake
Quote:
Originally Posted by
33333
So your saying I should use qmake like configure and do something like `qmake "prefix=/usr/local"`.
yes, qmake PREFIX=/somepath actually, if I remember qmake's built-in variables correctly.
Quote:
Originally Posted by
33333
The particular reason I wanted to set in the make file is that its going to be more compatible with trying to build a debian package from the source with `dh`
Ah, but wouldn't that also point to using the configure stage?
Usually make is only invoked with make arguments, no?
Quote:
Originally Posted by
33333
I think these issues can be worked around by dh anyway, and I'm finding the way to go about packaging Qt apps with dh is to make dh work with qmake not qmake work for dh.
There are plenty of Qt applications in the Debian repository, so that must be a solved problem :)
Quote:
Originally Posted by
33333
Still, I would like to know if its possible to set variables in the qmake generated Makefile directly.
More precisely you want qmake to generate variables and you want to set them through make.
Since it is not very common to set variables at make (usually done during configure), I am not sure if qmake's generator can do that.
You can add custom targets though: http://qt-project.org/doc/qt-5/qmake...ced-usage.html
Cheers,
_
Re: qmake set arbitrary makefile variable from qmake
anda_skao, you are right it is a solved problem. I sort of waded into it without thinking too much and then discovered this inability to pass variables on to make files. You are also right in that "PREFIX" seems to be the convention for passing the "prefix" onto qmake, and that you can't pass variables on to make (I don't think!! Still don't no for sure).
Just to cover off on the debian packages: I have found `dh` already has automatic handling for qmake project files! `dh_auto_build` does this in the configure stage by default:
Code:
qmake -makefile -nocache QMAKE_STRIP=: PREFIX=$prefix
So qmake projects with an INSTALL rule will build with `dh` automatically in most cases. In my case I also needed configure, so I'm calling qmake as shown but from a configure script.
Thanks for the help.