diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2022-06-11 14:25:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-06-14 20:17:46 (GMT) |
commit | f3b5a7d6df02d5c714a848e9709c563b9555af71 (patch) | |
tree | bb0aeb6168fd43afaaaa64df4fb70f7d5233e8d9 /Tests/RunCMake/find_path | |
parent | b78624fd29b91f748f3edcdaeea997a52691b647 (diff) | |
download | CMake-f3b5a7d6df02d5c714a848e9709c563b9555af71.zip CMake-f3b5a7d6df02d5c714a848e9709c563b9555af71.tar.gz CMake-f3b5a7d6df02d5c714a848e9709c563b9555af71.tar.bz2 |
find_(program,library,file,path): add validation function
Fixes: #23603
Diffstat (limited to 'Tests/RunCMake/find_path')
13 files changed, 73 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index 63cadc2..9c76f2e 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -7,6 +7,10 @@ run_cmake(Required) run_cmake(NO_CACHE) run_cmake(REGISTRY_VIEW-no-view) run_cmake(REGISTRY_VIEW-wrong-view) +run_cmake(VALIDATOR-no-function) +run_cmake(VALIDATOR-undefined-function) +run_cmake(VALIDATOR-specify-macro) +run_cmake(VALIDATOR) if(APPLE) run_cmake(FrameworksWithSubdirs) diff --git a/Tests/RunCMake/find_path/VALIDATOR-no-function-result.txt b/Tests/RunCMake/find_path/VALIDATOR-no-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-no-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/VALIDATOR-no-function-stderr.txt b/Tests/RunCMake/find_path/VALIDATOR-no-function-stderr.txt new file mode 100644 index 0000000..1dfd064 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-no-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-no-function.cmake:[0-9]+ \(find_path\): + find_path missing required argument for "VALIDATOR" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_path/VALIDATOR-no-function.cmake b/Tests/RunCMake/find_path/VALIDATOR-no-function.cmake new file mode 100644 index 0000000..bac2752 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-no-function.cmake @@ -0,0 +1,2 @@ + +find_path(result NAMES input.txt VALIDATOR) diff --git a/Tests/RunCMake/find_path/VALIDATOR-specify-macro-result.txt b/Tests/RunCMake/find_path/VALIDATOR-specify-macro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-specify-macro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/VALIDATOR-specify-macro-stderr.txt b/Tests/RunCMake/find_path/VALIDATOR-specify-macro-stderr.txt new file mode 100644 index 0000000..92ee17e --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-specify-macro-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-specify-macro.cmake:[0-9]+ \(find_path\): + find_path command specified for "VALIDATOR" is not a function: check. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_path/VALIDATOR-specify-macro.cmake b/Tests/RunCMake/find_path/VALIDATOR-specify-macro.cmake new file mode 100644 index 0000000..62b44ed --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-specify-macro.cmake @@ -0,0 +1,5 @@ + +macro(CHECK result path) +endmacro() + +find_path(result NAMES input.txt VALIDATOR check) diff --git a/Tests/RunCMake/find_path/VALIDATOR-stderr.txt b/Tests/RunCMake/find_path/VALIDATOR-stderr.txt new file mode 100644 index 0000000..851353d --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-stderr.txt @@ -0,0 +1,3 @@ +CHECK='[^']+/Tests/RunCMake/find_path/include/' +CHECK='[^']+/Tests/RunCMake/find_path/include/' +CHECK='[^']+/Tests/RunCMake/find_path/include/' diff --git a/Tests/RunCMake/find_path/VALIDATOR-stdout.txt b/Tests/RunCMake/find_path/VALIDATOR-stdout.txt new file mode 100644 index 0000000..3fce030 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-stdout.txt @@ -0,0 +1,3 @@ +-- DIR='[^']+/Tests/RunCMake/find_path/include' +-- DIR='[^']+/Tests/RunCMake/find_path/include' +-- DIR='DIR-NOTFOUND' diff --git a/Tests/RunCMake/find_path/VALIDATOR-undefined-function-result.txt b/Tests/RunCMake/find_path/VALIDATOR-undefined-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-undefined-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/VALIDATOR-undefined-function-stderr.txt b/Tests/RunCMake/find_path/VALIDATOR-undefined-function-stderr.txt new file mode 100644 index 0000000..d3e0517 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-undefined-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-undefined-function.cmake:[0-9]+ \(find_path\): + find_path command specified for "VALIDATOR" is undefined: undefined. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_path/VALIDATOR-undefined-function.cmake b/Tests/RunCMake/find_path/VALIDATOR-undefined-function.cmake new file mode 100644 index 0000000..3fb55c5 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR-undefined-function.cmake @@ -0,0 +1,2 @@ + +find_path(result NAMES input.txt VALIDATOR undefined) diff --git a/Tests/RunCMake/find_path/VALIDATOR.cmake b/Tests/RunCMake/find_path/VALIDATOR.cmake new file mode 100644 index 0000000..1e01250 --- /dev/null +++ b/Tests/RunCMake/find_path/VALIDATOR.cmake @@ -0,0 +1,39 @@ + +function(CHECK_DEFAULT result filename) + message("CHECK='${filename}'") +endfunction() + +function(CHECK_OK result filename) + message("CHECK='${filename}'") + set(${result} TRUE PARENT_SCOPE) +endfunction() + +function(CHECK_KO result filename) + message("CHECK='${filename}'") + set(${result} FALSE PARENT_SCOPE) +endfunction() + + +find_path(DIR + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_default + ) +message(STATUS "DIR='${DIR}'") +unset(DIR CACHE) + +find_path(DIR + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_ok + ) +message(STATUS "DIR='${DIR}'") +unset(DIR CACHE) + +find_path(DIR + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_ko + ) +message(STATUS "DIR='${DIR}'") +unset(DIR CACHE) |