summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_file
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2020-03-06 13:30:01 (GMT)
committerSylvain Joubert <joubert.sy@gmail.com>2020-03-06 15:40:26 (GMT)
commitdc008095961fe4c2478d575931e8caf6c9bff92d (patch)
treed468b514eca32bf28351b91f41628ab8be64ca36 /Tests/RunCMake/find_file
parentcc070e66cd9bd0d4e0ce56ad9dd307dbb854e61f (diff)
downloadCMake-dc008095961fe4c2478d575931e8caf6c9bff92d.zip
CMake-dc008095961fe4c2478d575931e8caf6c9bff92d.tar.gz
CMake-dc008095961fe4c2478d575931e8caf6c9bff92d.tar.bz2
find_*: Add support for REQUIRED keyword
In the same spirit as the REQUIRED keyword on find_package, this will stop cmake execution with an error on a failed find_program, find_file, find_path or find_library.
Diffstat (limited to 'Tests/RunCMake/find_file')
-rw-r--r--Tests/RunCMake/find_file/Required-result.txt1
-rw-r--r--Tests/RunCMake/find_file/Required-stderr.txt4
-rw-r--r--Tests/RunCMake/find_file/Required-stdout.txt1
-rw-r--r--Tests/RunCMake/find_file/Required.cmake12
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake1
5 files changed, 19 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_file/Required-result.txt b/Tests/RunCMake/find_file/Required-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_file/Required-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_file/Required-stderr.txt b/Tests/RunCMake/find_file/Required-stderr.txt
new file mode 100644
index 0000000..f9c337c
--- /dev/null
+++ b/Tests/RunCMake/find_file/Required-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at Required.cmake:9 \(find_file\):
+ Could not find FILE_doNotExists using the following files: doNotExists.h
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/find_file/Required-stdout.txt b/Tests/RunCMake/find_file/Required-stdout.txt
new file mode 100644
index 0000000..87a8e86
--- /dev/null
+++ b/Tests/RunCMake/find_file/Required-stdout.txt
@@ -0,0 +1 @@
+-- FILE_exists='[^']*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
diff --git a/Tests/RunCMake/find_file/Required.cmake b/Tests/RunCMake/find_file/Required.cmake
new file mode 100644
index 0000000..9cf0927
--- /dev/null
+++ b/Tests/RunCMake/find_file/Required.cmake
@@ -0,0 +1,12 @@
+find_file(FILE_exists
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_DEFAULT_PATH
+ REQUIRED
+ )
+message(STATUS "FILE_exists='${FILE_exists}'")
+
+find_file(FILE_doNotExists
+ NAMES doNotExists.h
+ REQUIRED
+ )
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 9f56a57..93dfb78 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -3,3 +3,4 @@ include(RunCMake)
run_cmake(FromPATHEnv)
run_cmake(FromPrefixPath)
run_cmake(PrefixInPATH)
+run_cmake(Required)