Search code examples
cmakefltk

testing for a package version set using custom cmake version variable


I'm linking to FLTK in my project using CMake and want to make sure that if anyone else tries to do so on their machine that they have the latest version (1.3.7).

The normal way in CMake to do this is

find_package(FLTK 1.3.7 REQUIRED)

However this requires variables like PACKAGE_FIND_VERSION_MAJOR etc. to be set in the relevant FLTKConfig.cmake file. Unfortunately, these are not set in this package, but what has been set is set (FLTK_VERSION 1.3.7)

How can I test that this variable (it might be set to 1.3.6 or 1.4.0 or whatever) is greater or equal to 1.3.7 in my CMakeLists.txt file?


Solution

  • The if command supports VERSION keyword to perform version numbers comparison:

    if(${FLTK_VERSION} VERSION_GREATER_EQUAL 1.3.7)