summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-05-01 15:25:28 (GMT)
committerBrad King <brad.king@kitware.com>2024-05-01 15:25:28 (GMT)
commit68a8c89430d94e89cf0044e6f3775fb61d447594 (patch)
treeeba107a41e31c7699279cc5f43f6c3e7da8afa9d /Tests
parent0ccc9f519dc00891fadb9e9189a652013b7c30e2 (diff)
downloadCMake-68a8c89430d94e89cf0044e6f3775fb61d447594.zip
CMake-68a8c89430d94e89cf0044e6f3775fb61d447594.tar.gz
CMake-68a8c89430d94e89cf0044e6f3775fb61d447594.tar.bz2
FPHSA: Add hint for failure when called before project()
Help project authors recognize an ordering mistake. Inspired-by: Jeremy Rifkin @jeremy-rifkin Closes: #25941
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt6
-rw-r--r--Tests/RunCMake/FPHSA/BeforeProject-Error-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/BeforeProject-Error-stderr.txt12
-rw-r--r--Tests/RunCMake/FPHSA/BeforeProject-Error.cmake2
-rw-r--r--Tests/RunCMake/FPHSA/BeforeProject-Missing-stdout.txt2
-rw-r--r--Tests/RunCMake/FPHSA/BeforeProject-Missing.cmake2
-rw-r--r--Tests/RunCMake/FPHSA/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/FPHSA/FindBeforeProject.cmake3
-rw-r--r--Tests/RunCMake/FPHSA/NameMismatch-stderr.txt12
-rw-r--r--Tests/RunCMake/FPHSA/RunCMakeTest.cmake2
10 files changed, 38 insertions, 9 deletions
diff --git a/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt b/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt
index 4c739d8..3ae1ba7 100644
--- a/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt
+++ b/Tests/RunCMake/FPHSA/BadFoundVar-stderr.txt
@@ -2,6 +2,6 @@ CMake Error at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\)
The argument for FOUND_VAR is "badfoundvar_FOUND", but only
"BadFoundVar_FOUND" and "BADFOUNDVAR_FOUND" are valid names.
Call Stack \(most recent call first\):
- FindBadFoundVar.cmake:5 \(find_package_handle_standard_args\)
- BadFoundVar.cmake:3 \(find_package\)
- CMakeLists.txt:3 \(include\)
+ FindBadFoundVar.cmake:[0-9]+ \(find_package_handle_standard_args\)
+ BadFoundVar.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FPHSA/BeforeProject-Error-result.txt b/Tests/RunCMake/FPHSA/BeforeProject-Error-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/BeforeProject-Error-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/BeforeProject-Error-stderr.txt b/Tests/RunCMake/FPHSA/BeforeProject-Error-stderr.txt
new file mode 100644
index 0000000..c8e53fc
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/BeforeProject-Error-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at [^
+]*/Modules/FindPackageHandleStandardArgs\.cmake:[0-9]+ \(message\):
+ Could NOT find BeforeProject \(missing: SOME_VAR\)
+
+ Hint: The project\(\) command has not yet been called\. It sets up
+ system-specific search paths\.
+Call Stack \(most recent call first\):
+ [^
+]*/Modules/FindPackageHandleStandardArgs\.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\)
+ FindBeforeProject\.cmake:[0-9]+ \(find_package_handle_standard_args\)
+ BeforeProject-Error\.cmake:[0-9]+ \(find_package\)
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/FPHSA/BeforeProject-Error.cmake b/Tests/RunCMake/FPHSA/BeforeProject-Error.cmake
new file mode 100644
index 0000000..53a8073
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/BeforeProject-Error.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+find_package(BeforeProject REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/BeforeProject-Missing-stdout.txt b/Tests/RunCMake/FPHSA/BeforeProject-Missing-stdout.txt
new file mode 100644
index 0000000..05df0b0
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/BeforeProject-Missing-stdout.txt
@@ -0,0 +1,2 @@
+-- Could NOT find BeforeProject \(missing: SOME_VAR\)[ ]*
+Hint: The project\(\) command has not yet been called\. It sets up system-specific search paths\.
diff --git a/Tests/RunCMake/FPHSA/BeforeProject-Missing.cmake b/Tests/RunCMake/FPHSA/BeforeProject-Missing.cmake
new file mode 100644
index 0000000..8d44ca9
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/BeforeProject-Missing.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+find_package(BeforeProject)
diff --git a/Tests/RunCMake/FPHSA/CMakeLists.txt b/Tests/RunCMake/FPHSA/CMakeLists.txt
index 93ee9df..dc34259 100644
--- a/Tests/RunCMake/FPHSA/CMakeLists.txt
+++ b/Tests/RunCMake/FPHSA/CMakeLists.txt
@@ -1,3 +1,8 @@
cmake_minimum_required(VERSION 3.5)
+if(RunCMake_TEST MATCHES "^BeforeProject")
+ include(${RunCMake_TEST}.cmake)
+ project(${RunCMake_TEST} NONE)
+ return()
+endif()
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FPHSA/FindBeforeProject.cmake b/Tests/RunCMake/FPHSA/FindBeforeProject.cmake
new file mode 100644
index 0000000..6bf49f1
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/FindBeforeProject.cmake
@@ -0,0 +1,3 @@
+set(SOME_VAR FALSE)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(BeforeProject REQUIRED_VARS SOME_VAR)
diff --git a/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt
index 722b50b..8ee6ec1 100644
--- a/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt
+++ b/Tests/RunCMake/FPHSA/NameMismatch-stderr.txt
@@ -5,9 +5,9 @@ CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \
`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\)
+ FindNameMismatch.cmake:[0-9]+ \(find_package_handle_standard_args\)
+ NameMismatch.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
@@ -17,7 +17,7 @@ CMake Warning \(dev\) at .*/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \
`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\)
+ FindNameMismatchOld.cmake:[0-9]+ \(find_package_handle_standard_args\)
+ NameMismatch.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
index 3b095a6..be9b127 100644
--- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
@@ -1,6 +1,8 @@
include(RunCMake)
run_cmake(BadFoundVar)
+run_cmake(BeforeProject-Error)
+run_cmake(BeforeProject-Missing)
run_cmake(NameMismatch)
# The pseudo module will "find" a package with the given version. Check if the