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/find_library | |
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/find_library')
-rw-r--r-- | Tests/RunCMake/find_library/Required-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/Required-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/Required-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/Required.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/RunCMakeTest.cmake | 1 |
5 files changed, 21 insertions, 0 deletions
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) |