[Interest] qmake: Test if environment variable is set.
Thiago Macieira
thiago.macieira at intel.com
Wed May 27 09:19:36 CEST 2015
On Wednesday 27 May 2015 00:10:19 Thiago Macieira wrote:
> On Wednesday 27 May 2015 09:03:24 Carel Combrink wrote:
> > Am I doing something wrong?
>
> Yes, you're expecting qmake to observe environment variables. It does not.
> Make honours and processes them, but that's run after qmake has finished
> running and has written the Makefile. Two separate and independent steps.
Actually, I was partially right, but the explanation is wrong.
When you write:
SOURCES = $(FOO)
Then qmake will write to the Makefile:
SOURCES = $(FOO)
and like I said in the email above, Make will expand and do its job.
When you write:
isEmpty(SOURCES)
then qmake looks at SOURCES and sees it's *not* empty. It contains one item:
$(FOO) (literally).
When you write:
message("Abc $$SOURCES def")
Then qmake will do the replacement and get the string "Abc $(FOO) def". At
that point, it notices the environment expansion and expands that, at that
time. If you run with debugging enabled, you'll see it saying:
DEBUG 2: literal "Abc $(FOO) def"
DEBUG 2: evaluated expression => "Abc $(FOO) def"
DEBUG 1: /dev/stdin:1: calling built-in message("Abc $(FOO) def")
Project MESSAGE: Abc def
So TEST_3 isn't empty. Only the output from message was empty because it
performed an extra expansion.
The rest of the email was right:
> > Is this intended behaviour?
>
> Yes.
>
> > How can I proceed to get the correct result?
>
> You cannot with qmake. You need to either make the variable a pure qmake one
> by passing it on the qmake command-line instead of the environment, or you
> skip doing the qmake checks and rely on Make rules only.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list