diff options
author | Sylvain Joubert <joubert.sy@gmail.com> | 2020-03-06 13:30:01 (GMT) |
---|---|---|
committer | Sylvain Joubert <joubert.sy@gmail.com> | 2020-03-06 15:40:26 (GMT) |
commit | dc008095961fe4c2478d575931e8caf6c9bff92d (patch) | |
tree | d468b514eca32bf28351b91f41628ab8be64ca36 /Tests/RunCMake | |
parent | cc070e66cd9bd0d4e0ce56ad9dd307dbb854e61f (diff) | |
download | CMake-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')
20 files changed, 78 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) diff --git a/Tests/RunCMake/find_library/Required-result.txt b/Tests/RunCMake/find_library/Required-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/Required-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/Required-stderr.txt b/Tests/RunCMake/find_library/Required-stderr.txt new file mode 100644 index 0000000..545d164 --- /dev/null +++ b/Tests/RunCMake/find_library/Required-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Required.cmake:11 \(find_library\): + Could not find LIB_doNotExists using the following names: doNotExists +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_library/Required-stdout.txt b/Tests/RunCMake/find_library/Required-stdout.txt new file mode 100644 index 0000000..b88ab79 --- /dev/null +++ b/Tests/RunCMake/find_library/Required-stdout.txt @@ -0,0 +1 @@ +-- LIB_exists='[^']*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' diff --git a/Tests/RunCMake/find_library/Required.cmake b/Tests/RunCMake/find_library/Required.cmake new file mode 100644 index 0000000..78c9f87 --- /dev/null +++ b/Tests/RunCMake/find_library/Required.cmake @@ -0,0 +1,14 @@ +list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) +list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) +find_library(LIB_exists + NAMES PrefixInPATH + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib + NO_DEFAULT_PATH + REQUIRED + ) +message(STATUS "LIB_exists='${LIB_exists}'") + +find_library(LIB_doNotExists + NAMES doNotExists + REQUIRED + ) diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index 643a5b9..b6aadce 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -7,3 +7,4 @@ if(CMAKE_HOST_UNIX) run_cmake(LibArchLink) endif() run_cmake(PrefixInPATH) +run_cmake(Required) diff --git a/Tests/RunCMake/find_path/Required-result.txt b/Tests/RunCMake/find_path/Required-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/Required-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/Required-stderr.txt b/Tests/RunCMake/find_path/Required-stderr.txt new file mode 100644 index 0000000..db65c2f --- /dev/null +++ b/Tests/RunCMake/find_path/Required-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Required.cmake:9 \(find_path\): + Could not find PATH_doNotExists using the following files: doNotExists.h +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_path/Required-stdout.txt b/Tests/RunCMake/find_path/Required-stdout.txt new file mode 100644 index 0000000..225fcab --- /dev/null +++ b/Tests/RunCMake/find_path/Required-stdout.txt @@ -0,0 +1 @@ +-- PATH_exists='[^']*/Tests/RunCMake/find_path/include' diff --git a/Tests/RunCMake/find_path/Required.cmake b/Tests/RunCMake/find_path/Required.cmake new file mode 100644 index 0000000..172dc11 --- /dev/null +++ b/Tests/RunCMake/find_path/Required.cmake @@ -0,0 +1,12 @@ +find_path(PATH_exists + NAMES PrefixInPATH.h + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include + NO_DEFAULT_PATH + REQUIRED + ) +message(STATUS "PATH_exists='${PATH_exists}'") + +find_path(PATH_doNotExists + NAMES doNotExists.h + REQUIRED + ) diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index ed55f51..5c919bb 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(EmptyOldStyle) run_cmake(FromPATHEnv) run_cmake(PrefixInPATH) +run_cmake(Required) if(APPLE) run_cmake(FrameworksWithSubdirs) diff --git a/Tests/RunCMake/find_program/Required-result.txt b/Tests/RunCMake/find_program/Required-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/Required-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/Required-stderr.txt b/Tests/RunCMake/find_program/Required-stderr.txt new file mode 100644 index 0000000..214a8d4 --- /dev/null +++ b/Tests/RunCMake/find_program/Required-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Required.cmake:9 \(find_program\): + Could not find PROG_AandB using the following names: testAandB +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_program/Required-stdout.txt b/Tests/RunCMake/find_program/Required-stdout.txt new file mode 100644 index 0000000..3c8f1b5 --- /dev/null +++ b/Tests/RunCMake/find_program/Required-stdout.txt @@ -0,0 +1 @@ +-- PROG_A='[^']*/Tests/RunCMake/find_program/A/testA' diff --git a/Tests/RunCMake/find_program/Required.cmake b/Tests/RunCMake/find_program/Required.cmake new file mode 100644 index 0000000..a75aa53 --- /dev/null +++ b/Tests/RunCMake/find_program/Required.cmake @@ -0,0 +1,12 @@ +find_program(PROG_A + NAMES testA + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A + NO_DEFAULT_PATH + REQUIRED + ) +message(STATUS "PROG_A='${PROG_A}'") + +find_program(PROG_AandB + NAMES testAandB + REQUIRED + ) diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 6903f05..0ff9a97 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -4,6 +4,7 @@ run_cmake(EnvAndHints) run_cmake(DirsPerName) run_cmake(NamesPerDir) run_cmake(RelAndAbsPath) +run_cmake(Required) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) |