Tests: Relax restrictions on version variable contents

Our only expectation of version number variables should be that
they begin with a decimal digit for VERSION_LESS, VERSION_EQUAL
and VERSION_GREATER comparison purposes. If people put extra
blah blah after a version number like "1.2.3 (this is some super
special extra information about our funky proprietary build of
the official 1.2.3 release)" then we should be ok with that.

So: now we have the following expectations for version number
variable content for the purposes of the AllFindModules test:

 - it should start with a decimal digit (match "^[0-9]")
 - it should not be empty
 - it should not be VERSION_EQUAL 0
 - it should not be NOT VERSION_GREATER 0
This commit is contained in:
David Cole 2012-03-20 16:18:02 -04:00
parent d69c2c5825
commit a5ee628519
1 changed files with 13 additions and 3 deletions

View File

@ -48,11 +48,21 @@ endif (NOT QT4_FOUND)
macro(check_version_string MODULE_NAME VERSION_VAR)
if (${MODULE_NAME}_FOUND)
if (DEFINED ${VERSION_VAR})
if (NOT ${VERSION_VAR} MATCHES "^[0-9][0-9\\.]*[-A-Za-z_\\+]*[0-9\\.]*$")
message(SEND_ERROR "${VERSION_VAR} has unexpected content ${${VERSION_VAR}}")
message(STATUS "${VERSION_VAR}='${${VERSION_VAR}}'")
if (NOT ${VERSION_VAR} MATCHES "^[0-9]")
message(SEND_ERROR "unexpected: ${VERSION_VAR} does not begin with a decimal digit")
endif()
if ("${${VERSION_VAR}}" STREQUAL "")
message(SEND_ERROR "unexpected: ${VERSION_VAR} is empty")
endif()
if (${VERSION_VAR} VERSION_EQUAL 0)
message(SEND_ERROR "unexpected: ${VERSION_VAR} is VERSION_EQUAL 0")
endif()
if (NOT ${VERSION_VAR} VERSION_GREATER 0)
message(SEND_ERROR "unexpected: ${VERSION_VAR} is NOT VERSION_GREATER 0")
endif()
else()
message(SEND_ERROR "${MODULE_NAME}_FOUND is set but no version number is defined")
message(SEND_ERROR "${MODULE_NAME}_FOUND is set but version number variable ${VERSION_VAR} is NOT DEFINED")
endif()
endif ()
endmacro(check_version_string)