diff options
author | Andrea Pappacoda <andrea@pappacoda.it> | 2022-07-31 22:52:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-09-07 14:11:06 (GMT) |
commit | 8f50f135aefa3f287a87c80cc8edb3deee8ee198 (patch) | |
tree | cf11e4d91d6d8b797272528b21217e9e7266e8cb /Tests/RunCMake/FPHSA | |
parent | 57ccad00010cd32d07592f6cefd004714e6993ad (diff) | |
download | CMake-8f50f135aefa3f287a87c80cc8edb3deee8ee198.zip CMake-8f50f135aefa3f287a87c80cc8edb3deee8ee198.tar.gz CMake-8f50f135aefa3f287a87c80cc8edb3deee8ee198.tar.bz2 |
FPHSA: Improve error message when VERSION_VAR is empty or has been unset()
Previously, when `VERSION_VAR` is set but empty, FPHSA emitted a
confusing error message, saying that the package was found but of an
unsuitable version "". Fix the error message to state that the package
was not found.
Fixes: #23807
Diffstat (limited to 'Tests/RunCMake/FPHSA')
-rw-r--r-- | Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/empty_version-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/empty_version-stderr.txt | 9 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/empty_version.cmake | 1 |
4 files changed, 15 insertions, 1 deletions
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index 28b8570..e389e6b 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -38,9 +38,12 @@ run_cmake(exact_1.2.3.5) unset(RunCMake_DEFAULT_stderr) # check if searching for a version 0 works -list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") run_cmake(exact_0_matching) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=") +run_cmake(empty_version) + # check custom error message set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCustomMessage_VERSION=1.2.3.4") run_cmake(custom_message_1) diff --git a/Tests/RunCMake/FPHSA/empty_version-result.txt b/Tests/RunCMake/FPHSA/empty_version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/empty_version-stderr.txt b/Tests/RunCMake/FPHSA/empty_version-stderr.txt new file mode 100644 index 0000000..3b60c7a --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at [^ +]*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find Pseudo: \(Required is at least version "1"\) \(found TRUE\) +Call Stack \(most recent call first\): + [^ +]*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) + FindPseudo.cmake:[0-9]+ \(find_package_handle_standard_args\) + empty_version.cmake:[0-9]+ \(find_package\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/FPHSA/empty_version.cmake b/Tests/RunCMake/FPHSA/empty_version.cmake new file mode 100644 index 0000000..7b7ff34 --- /dev/null +++ b/Tests/RunCMake/FPHSA/empty_version.cmake @@ -0,0 +1 @@ +find_package(Pseudo 1 REQUIRED) |