[Qt-interest] setting makfile variable from .pro file
andrew.m.goth at l-3com.com
andrew.m.goth at l-3com.com
Wed Feb 4 20:20:05 CET 2009
Pete Black wrote:
> Anyone know a good way to set an environment variable used in
> the qmake generated makefile from the .pro file?
If you want to override the definition of one the variables in the
Makefile, you can try prefixing its name with "QMAKE_". For example,
here's how I link to the NSPR library:
QMAKE_CXXFLAGS += $(shell nspr-config --cflags nspr)
QMAKE_LFLAGS += $(shell nspr-config --libs nspr)
I use += instead of = or := because I want to augment CXXFLAGS and
LFLAGS, not replace them outright.
By the way, make variables are not environment variables, but they can
be overridden from the environment or from arguments to make, as in each
of the following examples:
$ export INSTALL_ROOT=/usr/local; make
$ env INSTALL_ROOT=/usr/local make
$ INSTALL_ROOT=/usr/local make
$ make INSTALL_ROOT=/usr/local
$ make INSTALL_ROOT:=/usr/local
$ make INSTALL_ROOT+=/usr/local
If the variable was not an environment variable to begin with, it will
not be exported to make's child process environments. But if it was an
environment variable or was overridden by one of the arguments to make,
it will be exported. Precedence rules apply; see below for examples:
$ cat Makefile
TEST:=1
all:
@echo TEST=$$TEST
$ make
TEST=
$ TEST=2 make
TEST=1
$ make TEST=2
TEST=2
$ TEST=0 make TEST=2
TEST=2
$ TEST=0 make TEST+=2
TEST=0 2
Adding a "QMAKE_" prefix does not work for variables that aren't in the
qmake-generated Makefile to begin with, such as INSTALL_ROOT. Perhaps
you were thinking of INSTALL_DIR? That can be set directly from the PRO
file.
So please tell us, what would this environment variable do? What are
you really trying to accomplish?
--
Andy Goth
<amgoth at link.com>
More information about the Qt-interest-old
mailing list