diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-09-30 12:22:37 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-09-30 08:22:49 -0400 |
commit | f002c1cfc7f66edb9c9821524671574c23f92cd2 (patch) | |
tree | 35244a9e4a630d12df182842b66a5daa536b0ca7 /Tests | |
parent | 1c3244ca30d3139c61f7c8d99481d5c00295e97c (diff) | |
parent | 212b0afb66d293bb88261710a3365f95b8104898 (diff) | |
download | cmake-f002c1cfc7f66edb9c9821524671574c23f92cd2.tar.gz |
Merge topic 'find-package-check-empty-version-range'
212b0afb66 find_package: raise error on empty version range
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5294
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/range_empty-1-stderr.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/range_empty-1.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/range_empty-2-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/range_empty-2-stderr.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/range_empty-2.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/EmptyVersionRange-result.txt (renamed from Tests/RunCMake/FPHSA/range_empty-1-result.txt) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/EmptyVersionRange.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/FindVersionRange.cmake | 22 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/VersionRange.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/VersionRange2.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/VersionRange3.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/VersionRange4.cmake | 39 |
15 files changed, 80 insertions, 28 deletions
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index e4b8700b04..28b8570d0d 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -61,8 +61,6 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPse run_cmake(range_ignored) set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoRange_VERSION=2.0") run_cmake(range_no-range) -run_cmake(range_empty-1) -run_cmake(range_empty-2) run_cmake(range_1-3) run_cmake(range_1-2-include) run_cmake(range_1-2-exclude) diff --git a/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt b/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt deleted file mode 100644 index e1c741ad6c..0000000000 --- a/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): - Could NOT find PseudoRange: Found unsuitable version "2\.0", required range - is empty \("3\.0\.\.\.2\.0"\) \(found TRUE\) -Call Stack \(most recent call first\): - .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) - FindPseudoRange.cmake:[0-9]+ \(find_package_handle_standard_args\) diff --git a/Tests/RunCMake/FPHSA/range_empty-1.cmake b/Tests/RunCMake/FPHSA/range_empty-1.cmake deleted file mode 100644 index c510d7d9d0..0000000000 --- a/Tests/RunCMake/FPHSA/range_empty-1.cmake +++ /dev/null @@ -1 +0,0 @@ -find_package(PseudoRange 3.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_empty-2-result.txt b/Tests/RunCMake/FPHSA/range_empty-2-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/FPHSA/range_empty-2-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt b/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt deleted file mode 100644 index ee0e79ab51..0000000000 --- a/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMake Error at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): - Could NOT find PseudoRange: Found unsuitable version "2\.0", required range - is empty \("2\.0\.\.\.<2.0"\) \(found TRUE\) -Call Stack \(most recent call first\): - .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) - FindPseudoRange.cmake:[0-9]+ \(find_package_handle_standard_args\) diff --git a/Tests/RunCMake/FPHSA/range_empty-2.cmake b/Tests/RunCMake/FPHSA/range_empty-2.cmake deleted file mode 100644 index 3ce90e830b..0000000000 --- a/Tests/RunCMake/FPHSA/range_empty-2.cmake +++ /dev/null @@ -1 +0,0 @@ -find_package(PseudoRange 2.0...<2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_empty-1-result.txt b/Tests/RunCMake/find_package/EmptyVersionRange-result.txt index d00491fd7e..d00491fd7e 100644 --- a/Tests/RunCMake/FPHSA/range_empty-1-result.txt +++ b/Tests/RunCMake/find_package/EmptyVersionRange-result.txt diff --git a/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt b/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt new file mode 100644 index 0000000000..9c00b96871 --- /dev/null +++ b/Tests/RunCMake/find_package/EmptyVersionRange-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at EmptyVersionRange.cmake:[0-9]+ \(find_package\): + find_package specified version range is empty. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at EmptyVersionRange.cmake:[0-9]+ \(find_package\): + find_package specified version range is empty. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/EmptyVersionRange.cmake b/Tests/RunCMake/find_package/EmptyVersionRange.cmake new file mode 100644 index 0000000000..553e297a84 --- /dev/null +++ b/Tests/RunCMake/find_package/EmptyVersionRange.cmake @@ -0,0 +1,3 @@ +find_package(VersionRange 2.3...1.2) + +find_package(VersionRange 2.3...<2.3) diff --git a/Tests/RunCMake/find_package/FindVersionRange.cmake b/Tests/RunCMake/find_package/FindVersionRange.cmake index ff84e93091..27e5b90b35 100644 --- a/Tests/RunCMake/find_package/FindVersionRange.cmake +++ b/Tests/RunCMake/find_package/FindVersionRange.cmake @@ -3,19 +3,19 @@ if (NOT VersionRange_FIND_VERSION_COMPLETE STREQUAL VersionRange_SPECIFIED_VERSI message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_COMPLETE: ${VersionRange_FIND_VERSION_COMPLETE}") endif() -if (NOT VersionRange_FIND_VERSION VERSION_EQUAL "1.2.3.4") +if (NOT VersionRange_FIND_VERSION VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION: ${VersionRange_FIND_VERSION}") endif() -if (NOT VersionRange_FIND_VERSION_MAJOR VERSION_EQUAL "1") +if (NOT VersionRange_FIND_VERSION_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MAJOR) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAJOR: ${VersionRange_FIND_VERSION_MAJOR}") endif() -if (NOT VersionRange_FIND_VERSION_MINOR VERSION_EQUAL "2") +if (NOT VersionRange_FIND_VERSION_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MINOR) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MINOR: ${VersionRange_FIND_VERSION_MINOR}") endif() -if (NOT VersionRange_FIND_VERSION_PATCH VERSION_EQUAL "3") +if (NOT VersionRange_FIND_VERSION_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_PATCH) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_PATCH: ${VersionRange_FIND_VERSION_PATCH}") endif() -if (NOT VersionRange_FIND_VERSION_TWEAK VERSION_EQUAL "4") +if (NOT VersionRange_FIND_VERSION_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_TWEAK) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_TWEAK: ${VersionRange_FIND_VERSION_TWEAK}") endif() @@ -35,19 +35,19 @@ else() endif() endif() -if (NOT VersionRange_FIND_VERSION_MIN VERSION_EQUAL "1.2.3.4") - message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN: ${VersionRange_FIND_VERSION}") +if (NOT VersionRange_FIND_VERSION_MIN VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN: ${VersionRange_FIND_VERSION_MIN}") endif() -if (NOT VersionRange_FIND_VERSION_MIN_MAJOR VERSION_EQUAL "1") +if (NOT VersionRange_FIND_VERSION_MIN_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MAJOR) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MAJOR: ${VersionRange_FIND_VERSION_MIN_MAJOR}") endif() -if (NOT VersionRange_FIND_VERSION_MIN_MINOR VERSION_EQUAL "2") +if (NOT VersionRange_FIND_VERSION_MIN_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_MINOR) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MINOR: ${VersionRange_FIND_VERSION_MIN_MINOR}") endif() -if (NOT VersionRange_FIND_VERSION_MIN_PATCH VERSION_EQUAL "3") +if (NOT VersionRange_FIND_VERSION_MIN_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_PATCH) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_PATCH: ${VersionRange_FIND_VERSION_MIN_PATCH}") endif() -if (NOT VersionRange_FIND_VERSION_MIN_TWEAK VERSION_EQUAL "4") +if (NOT VersionRange_FIND_VERSION_MIN_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MIN_TWEAK) message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_TWEAK: ${VersionRange_FIND_VERSION_MIN_TWEAK}") endif() diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 7755a70ff4..a899f46ad2 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -30,10 +30,12 @@ run_cmake(CMP0084-OLD) run_cmake(CMP0084-WARN) run_cmake(CMP0084-NEW) run_cmake(WrongVersionRange) +run_cmake(EmptyVersionRange) run_cmake(VersionRangeWithEXACT) run_cmake(VersionRange) run_cmake(VersionRange2) run_cmake(VersionRange3) +run_cmake(VersionRange4) run_cmake(VersionRangeConfig) run_cmake(VersionRangeConfig2) run_cmake(VersionRangeConfigStd) diff --git a/Tests/RunCMake/find_package/VersionRange.cmake b/Tests/RunCMake/find_package/VersionRange.cmake index b3d8950702..30b88a80ae 100644 --- a/Tests/RunCMake/find_package/VersionRange.cmake +++ b/Tests/RunCMake/find_package/VersionRange.cmake @@ -3,6 +3,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...5.6.7.8) set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) diff --git a/Tests/RunCMake/find_package/VersionRange2.cmake b/Tests/RunCMake/find_package/VersionRange2.cmake index d0e685b455..9adcc64005 100644 --- a/Tests/RunCMake/find_package/VersionRange2.cmake +++ b/Tests/RunCMake/find_package/VersionRange2.cmake @@ -3,6 +3,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<5.6.7.8) set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) diff --git a/Tests/RunCMake/find_package/VersionRange3.cmake b/Tests/RunCMake/find_package/VersionRange3.cmake index 76eef1d670..41efac4613 100644 --- a/Tests/RunCMake/find_package/VersionRange3.cmake +++ b/Tests/RunCMake/find_package/VersionRange3.cmake @@ -5,6 +5,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<2.3.4.5) set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN 1.2.3.4) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 1) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 3) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 4) set (VersionRange_SPECIFIED_VERSION_MAX 2.3.4.5) set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 2) set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 3) diff --git a/Tests/RunCMake/find_package/VersionRange4.cmake b/Tests/RunCMake/find_package/VersionRange4.cmake new file mode 100644 index 0000000000..0953d04295 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange4.cmake @@ -0,0 +1,39 @@ + +# show the effect of the exclusion or inclusion of the upper endpoint + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 2.3.4.5...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 2.3.4.5...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MIN_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MIN_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MIN_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MIN_TWEAK 5) +set (VersionRange_SPECIFIED_VERSION_MAX 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() |