FPHSA: fix when requested or found version is exactly 0

Until now it was checked with "if(VAR)", which will be false in case "0" is the
content of the variable.
This commit is contained in:
Rolf Eike Beer 2014-10-07 22:46:11 +02:00
parent 4f9bf4468b
commit ba907f7dc2
5 changed files with 12 additions and 3 deletions

View File

@ -284,10 +284,11 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# version handling:
set(VERSION_MSG "")
set(VERSION_OK TRUE)
set(VERSION ${${FPHSA_VERSION_VAR}} )
if (${_NAME}_FIND_VERSION)
set(VERSION ${${FPHSA_VERSION_VAR}})
if(VERSION)
# check with DEFINED here as the requested or found version may be "0"
if (DEFINED ${_NAME}_FIND_VERSION)
if(DEFINED ${FPHSA_VERSION_VAR})
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
# count the dots in the version string

View File

@ -14,6 +14,7 @@ run_cmake(exact_1.2.3)
run_cmake(exact_1.2.3.4)
# now test every component with an invalid version
run_cmake(exact_0)
run_cmake(exact_2)
run_cmake(exact_1.1)
run_cmake(exact_1.3)
@ -21,3 +22,7 @@ run_cmake(exact_1.2.2)
run_cmake(exact_1.2.4)
run_cmake(exact_1.2.3.3)
run_cmake(exact_1.2.3.5)
# check if searching for a version 0 works
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0")
run_cmake(exact_0_matching)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
find_package(Pseudo 0 EXACT REQUIRED)

View File

@ -0,0 +1 @@
find_package(Pseudo 0 EXACT REQUIRED)