diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2019-12-09 13:19:35 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2020-01-14 22:25:49 (GMT) |
commit | ee4673c1ae1e4a1aa4687412717567c2ffbb501b (patch) | |
tree | d8fc21374a252ecd7ad9ad92e1921c42897b95a0 /Tests/RunCMake/FPHSA | |
parent | 93526fd91319d952e60760c735a9bb191bc4ede3 (diff) | |
download | CMake-ee4673c1ae1e4a1aa4687412717567c2ffbb501b.zip CMake-ee4673c1ae1e4a1aa4687412717567c2ffbb501b.tar.gz CMake-ee4673c1ae1e4a1aa4687412717567c2ffbb501b.tar.bz2 |
FPHSA: detect package name mismatches
The `FPHSA_NAME_MISMATCHED` variable may be set if this is intentional
(but should be cleared after the call to not affect other FPHSA calls).
It may also be passed via the `NAME_MISMATCHED` option for new-signature
FPHSA calls.
Diffstat (limited to 'Tests/RunCMake/FPHSA')
-rw-r--r-- | Tests/RunCMake/FPHSA/FindNameMismatch.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/NameMismatch-stderr.txt | 23 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/NameMismatch.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 1 |
8 files changed, 55 insertions, 0 deletions
diff --git a/Tests/RunCMake/FPHSA/FindNameMismatch.cmake b/Tests/RunCMake/FPHSA/FindNameMismatch.cmake new file mode 100644 index 0000000..540aa67 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatch.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake new file mode 100644 index 0000000..d155ea7 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchOld.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH "old signature" "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake new file mode 100644 index 0000000..042a59a --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressed.cmake @@ -0,0 +1,6 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +set(FPHSA_NAME_MISMATCHED 1) +find_package_handle_standard_args(NAMEMISMATCH "old signature" "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +unset(FPHSA_NAME_MISMATCHED) +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake new file mode 100644 index 0000000..6a0e964 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedArg.cmake @@ -0,0 +1,4 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NAMEMISMATCH NAME_MISMATCHED REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake new file mode 100644 index 0000000..791cfee --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindNameMismatchSuppressedCompat.cmake @@ -0,0 +1,6 @@ +set("${CMAKE_FIND_PACKAGE_NAME}_MODULE" "${CMAKE_CURRENT_LIST_FILE}") +include(FindPackageHandleStandardArgs) +set(FPHSA_NAME_MISMATCHED 1) +find_package_handle_standard_args(NAMEMISMATCH REQUIRED_VARS "${CMAKE_FIND_PACKAGE_NAME}_MODULE") +unset(FPHSA_NAME_MISMATCHED) +set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1) diff --git a/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt new file mode 100644 index 0000000..722b50b --- /dev/null +++ b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt @@ -0,0 +1,23 @@ +CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + The package name passed to `find_package_handle_standard_args` + \(NAMEMISMATCH\) does not match the name of the calling package + \(NameMismatch\). This can lead to problems in calling code that expects + `find_package` result variables \(e.g., `_FOUND`\) to follow a certain + pattern. +Call Stack \(most recent call first\): + FindNameMismatch.cmake:3 \(find_package_handle_standard_args\) + NameMismatch.cmake:3 \(find_package\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + The package name passed to `find_package_handle_standard_args` + \(NAMEMISMATCH\) does not match the name of the calling package + \(NameMismatchOld\). This can lead to problems in calling code that expects + `find_package` result variables \(e.g., `_FOUND`\) to follow a certain + pattern. +Call Stack \(most recent call first\): + FindNameMismatchOld.cmake:3 \(find_package_handle_standard_args\) + NameMismatch.cmake:4 \(find_package\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/FPHSA/NameMismatch.cmake b/Tests/RunCMake/FPHSA/NameMismatch.cmake new file mode 100644 index 0000000..9ca3cc6 --- /dev/null +++ b/Tests/RunCMake/FPHSA/NameMismatch.cmake @@ -0,0 +1,7 @@ +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +find_package(NameMismatch REQUIRED) +find_package(NameMismatchOld REQUIRED) +find_package(NameMismatchSuppressed REQUIRED) +find_package(NameMismatchSuppressedCompat REQUIRED) +find_package(NameMismatchSuppressedArg REQUIRED) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index f3e6c3e..286915d 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(BadFoundVar) +run_cmake(NameMismatch) # The pseudo module will "find" a package with the given version. Check if the # version selection code in FPHSA works correctly. |