[Qt-interest] override variables with environment variables

Lorenzo Bettini bettini at dsi.unifi.it
Sun May 17 12:10:49 CEST 2009


Ferenc Stelcz wrote:
> Lorenzo Bettini wrote:
>> Hi
>>
>> is there a way to override variables (such as, e.g., INSTALL_DIR) in 
>> .pro files by using environment variables, e.g., something like this:
>>
>> INSTALL_DIR="/my/path" qmake
>>
>> ?
>>
> 
> According to the docs "qmake Advanced Usage" @ 
> http://doc.trolltech.com/4.5/qmake-advanced-usage.html#variables
> 
> To obtain the contents of an environment value when qmake is run, use the 
> $$(...) operator:
> 
> DESTDIR = $$(PWD)
> message(The project will be installed in $$DESTDIR)
> 
> In the above assignment, the value of the PWD environment variable is read 
> when the project file is processed.
> 
> To obtain the contents of an environment value at the time when the generated 
> Makefile is processed, use the $(...) operator:
> 
> DESTDIR = $$(PWD)
> message(The project will be installed in $$DESTDIR)
> 
> DESTDIR = $(PWD)
> message(The project will be installed in the value of PWD)
> message(when the Makefile is processed.)
> 
> In the above assignment, the value of PWD is read immediately when the project 
> file is processed, but $(PWD) is assigned to DESTDIR in the generated 
> Makefile. This makes the build process more flexible as long as the 
> environment variable is set correctly when the Makefile is processed.
> 

OK, but if I wanted a default value for DESTDIR, hardcoded in the .pro 
file, that the user can override with an environment variable?

By the way, isn't there a way to also store in the generated Makefile 
the command line used to run qmake?

For instance, say I run qmake as follows

CXX="ccache g++" PKG_CONFIG_PATH="/mylib/pkgconfig" qmake-qt4

the environment variable part is not store in the Makefile as the 
command to rerun qmake...

-- 
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net




More information about the Qt-interest-old mailing list