[Interest] Qmake "requires" function
Carel Combrink
carel.combrink at gmail.com
Tue Feb 23 06:51:13 CET 2016
Morning Thiago,
> Please give a concrete usecase.
>
I have developed a framework that contains a set of libraries using subdirs
template.
One library needs specific tools to be installed before it can be built. My
initial implementation was to pass a argument to qmake to enable this
library if you have the correct tools installed into the correct locations.
This was working but looking through the qmake docs I came across the
"requires" test. So I started playing with the idea to check for an
environmental variable and if set, enable the specific library. That is
when I started getting stuck.
> > requires(true)
> >
> > requires(false)
>
> In your .pro file.
>
> Please also explain what you mean by "a positive result".
I had the following code in my pro file:
requires(true)
requires(false)
To force it to fail, to test the requires() function.
So the issue that I have:
Before starting to test the requires() function I had the following in my
code to test for the env var:
MY_ENV_VAR_TEST=$$(MY_ENV_VAR)
isEmpty(MY_ENV_VAR_TEST) {
error("The env var MY_ENV_VAR must be set when enabling this library")
}
*PS: Is there a better way to check if an environmental variable is set
using qmake that is cross platform for Linux, Windows and Mac? *
Even with the forced fail (as above) qmake was interrupted with the error
above. I was hoping/expecting that it would break out at the
forced requires(false) before interrupting the whole qmake process due to
the error message.
> I've just tested a
> .pro file containing "requires(false)" and it produced a Makefile that just
> does:
>
> @echo "Some of the required modules (false) are not available."
> @echo "Skipped."
>
If I remove the error("...") as mentioned above, I get the same behaviour
that you get.
So what is failing:
in my pro file:
requires(false)
error("Should not get here")
My conclusion: It does seem like qmake will evaluate the whole pro file
even past the "requires(false)" and fail completely on error messages.
For now I removed the error message and it seems like it behaves as
expected.
Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160223/ba3ed2a6/attachment.html>
More information about the Interest
mailing list