diff options
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/exact_0-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/exact_0.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/exact_0_matching.cmake | 1 |
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) |