I am trying to determine if the version of wxWidgets found by CMake is >= 2.9. I tried this:
find_package(wxWidgets 2.9 COMPONENTS core base REQUIRED)
if(wxWidgets_FOUND)
message("wxWidgets found successfully.")
include( ${wxWidgets_USE_FILE} )
else()
message(FATAL_ERROR "wxWidgets was not found!")
endif()
if(wxWidgets_VERSION LESS 2.9)
message(FATAL_ERROR "wxWidgets is not a high enough version!")
else()
message("wxWidgets Version ${wxWidgets_VERSION}")
message("wxWidgets Major version ${wxMAJOR_VERSION}")
message("release number ${wxRELEASE_NUMBER}")
message("check version ${wxCHECK_VERSION}")
message("wxWidgets version ${WX_WIDGETS_VERSION}")
message("wxWidgets major version ${WX_MAJOR_VERSION}")
message("wxWidgets version string ${WX_VERSION_STRING}")
endif()
(My system has wx2.8, so this should fail).
The if(wxWidgets_FOUND) returns TRUE, so so far so good. However, the if(wxWidgets_VERSION LESS 2.9) fails, but it is not because wxWidgets_VERSION is < 2.9. It is because wxWidgets_VERSION is empty. In fact, the whole output is:
wxWidgets Version
wxWidgets Major version
release number
check version
wxWidgets version
wxWidgets major version
wxWidgets version string
(i.e. all of the variables are empty)
Does anyone know the correct way to check for the wxWidgets version through CMake?
Thanks,
David
Someone suggested a project named wxArt2d that has a bit better wxWidgets cmake. It is unfortunate that these things are not easier/better maintained :(