PDA

View Full Version : qmake - how to extract number from variable



Vanir
12th January 2009, 16:23
Hi All,

In a pro file:
############
VERSION = 1.8.0

# This should be extracted from VERSION (but how?)
VERSION_MAJ = $$find(VERSION, regular expression?)
message($$VERSION_MAJ)
###########

Require VERSION_MAJ to be 1 via the $$find function.

What is the form of the regular expression to achieve required result?

Thanks

Vanir

jpn
12th January 2009, 18:12
VERSIONS = $$split(VERSION, ".")
VERSION_MAJ = $$member(VERSIONS, 0)
VERSION_MIN = $$member(VERSIONS, 1)

lessThan(VERSION_MAJ, 1) | lessThan(VERSION_MIN, 8) {
error(Project requires version 1.8 or newer but $$VERSION was detected.)
}