[Interest] Qmake "requires" function

Thiago Macieira thiago.macieira at intel.com
Tue Feb 23 07:09:32 CET 2016


On terça-feira, 23 de fevereiro de 2016 07:51:13 PST Carel Combrink wrote:
> I had the following code in my pro file:
> 
> requires(true)
> requires(false)
> 
> To force it to fail, to test the requires() function.

As I said, the requires(false) predicate does work: it produces a Makefile that 
prints a warning and does nothing else. As documented, like you pasted.

> 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? *

The above should work. If you were having problems, say what they were.

> 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.

requires() with a false predicate does not interrupt execution. It creates a 
Makefile that doesn't do anything.

error() interrupts execution.

> So what is failing:
> in my pro file:
> 
> requires(false)
> 
> error("Should not get here")

Wrong expectation. It will get here.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list