testing 3rd party package major version from full versoin

Hi,

I’ve got a 3rd party package (namely gdal) that only report its full version.x.y.z in _VERSION variable but it does not define _VERSION_MAJOR (for instance)

Is there a way to test only the x part?
(I want to set some things with respect to the major version, not to enforce a minimum version).

Thanks
A.
PS so far I do

find_package(PACKAGE 2 QUIET)
IF (PACKAGE_FOUND)
	MESSAGE("found PACKAGE 2+")
ELSEIF()
find_package(PACKAGE 1 QUIET)
IF (PACKAGE_FOUND)
	MESSAGE("found PACKAGE 1+")
ENDIF()
ENDIF

which seems a gross overkill…

Usually this means using a regex to split the reported version apart. You can use this though:

if (pkg_VERSION VERSION_LESS 1)` # major == 0
elseif (pkg_VERSION VERSION_LESS 2)` # major == 1
elseif (pkg_VERSION VERSION_LESS 3)` # major == 2
endif ()

Perfect (I missed it in the doc)

regards
A.