summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2014-10-07 20:46:11 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2014-10-07 21:14:46 (GMT)
commitba907f7dc21163df29872a221dfeae18379319c6 (patch)
tree6c37e933157d3112107f2b2887c57973dc669588
parent4f9bf4468bd5bcd48be080fa0bc736ebb9df4769 (diff)
downloadCMake-ba907f7dc21163df29872a221dfeae18379319c6.zip
CMake-ba907f7dc21163df29872a221dfeae18379319c6.tar.gz
CMake-ba907f7dc21163df29872a221dfeae18379319c6.tar.bz2
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.
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake7
-rw-r--r--Tests/RunCMake/FPHSA/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/FPHSA/exact_0-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/exact_0.cmake1
-rw-r--r--Tests/RunCMake/FPHSA/exact_0_matching.cmake1
5 files changed, 12 insertions, 3 deletions
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
index f6e536b..23f3f05 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -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
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
index 37c18d0..bb7743c 100644
--- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/FPHSA/exact_0-result.txt b/Tests/RunCMake/FPHSA/exact_0-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/exact_0-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/exact_0.cmake b/Tests/RunCMake/FPHSA/exact_0.cmake
new file mode 100644
index 0000000..432887b
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/exact_0.cmake
@@ -0,0 +1 @@
+find_package(Pseudo 0 EXACT REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/exact_0_matching.cmake b/Tests/RunCMake/FPHSA/exact_0_matching.cmake
new file mode 100644
index 0000000..432887b
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/exact_0_matching.cmake
@@ -0,0 +1 @@
+find_package(Pseudo 0 EXACT REQUIRED)