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 | |
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')
52 files changed, 294 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake index 23765d4..296bb71 100644 --- a/Tests/RunCMake/find_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_file/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) run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File) diff --git a/Tests/RunCMake/find_file/VALIDATOR-no-function-result.txt b/Tests/RunCMake/find_file/VALIDATOR-no-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-no-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_file/VALIDATOR-no-function-stderr.txt b/Tests/RunCMake/find_file/VALIDATOR-no-function-stderr.txt new file mode 100644 index 0000000..4d49649 --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-no-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-no-function.cmake:[0-9]+ \(find_file\): + find_file missing required argument for "VALIDATOR" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_file/VALIDATOR-no-function.cmake b/Tests/RunCMake/find_file/VALIDATOR-no-function.cmake new file mode 100644 index 0000000..4800fe9 --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-no-function.cmake @@ -0,0 +1,2 @@ + +find_file(result NAMES input.txt VALIDATOR) diff --git a/Tests/RunCMake/find_file/VALIDATOR-specify-macro-result.txt b/Tests/RunCMake/find_file/VALIDATOR-specify-macro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-specify-macro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_file/VALIDATOR-specify-macro-stderr.txt b/Tests/RunCMake/find_file/VALIDATOR-specify-macro-stderr.txt new file mode 100644 index 0000000..7e0eda0 --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-specify-macro-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-specify-macro.cmake:[0-9]+ \(find_file\): + find_file 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_file/VALIDATOR-specify-macro.cmake b/Tests/RunCMake/find_file/VALIDATOR-specify-macro.cmake new file mode 100644 index 0000000..ec0ce9a --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-specify-macro.cmake @@ -0,0 +1,5 @@ + +macro(CHECK result path) +endmacro() + +find_file(result NAMES input.txt VALIDATOR check) diff --git a/Tests/RunCMake/find_file/VALIDATOR-stderr.txt b/Tests/RunCMake/find_file/VALIDATOR-stderr.txt new file mode 100644 index 0000000..6c8159b --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-stderr.txt @@ -0,0 +1,3 @@ +CHECK='[^']+/Tests/RunCMake/find_file/include/PrefixInPATH.h' +CHECK='[^']+/Tests/RunCMake/find_file/include/PrefixInPATH.h' +CHECK='[^']+/Tests/RunCMake/find_file/include/PrefixInPATH.h' diff --git a/Tests/RunCMake/find_file/VALIDATOR-stdout.txt b/Tests/RunCMake/find_file/VALIDATOR-stdout.txt new file mode 100644 index 0000000..44fa77c --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-stdout.txt @@ -0,0 +1,3 @@ +-- FILE='[^']+/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- FILE='[^']+/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- FILE='FILE-NOTFOUND' diff --git a/Tests/RunCMake/find_file/VALIDATOR-undefined-function-result.txt b/Tests/RunCMake/find_file/VALIDATOR-undefined-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-undefined-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_file/VALIDATOR-undefined-function-stderr.txt b/Tests/RunCMake/find_file/VALIDATOR-undefined-function-stderr.txt new file mode 100644 index 0000000..b4125e6 --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-undefined-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-undefined-function.cmake:[0-9]+ \(find_file\): + find_file command specified for "VALIDATOR" is undefined: undefined. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_file/VALIDATOR-undefined-function.cmake b/Tests/RunCMake/find_file/VALIDATOR-undefined-function.cmake new file mode 100644 index 0000000..c465887 --- /dev/null +++ b/Tests/RunCMake/find_file/VALIDATOR-undefined-function.cmake @@ -0,0 +1,2 @@ + +find_file(result NAMES input.txt VALIDATOR undefined) diff --git a/Tests/RunCMake/find_file/VALIDATOR.cmake b/Tests/RunCMake/find_file/VALIDATOR.cmake new file mode 100644 index 0000000..72dd8f9 --- /dev/null +++ b/Tests/RunCMake/find_file/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_file(FILE + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_default + ) +message(STATUS "FILE='${FILE}'") +unset(FILE CACHE) + +find_file(FILE + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_ok + ) +message(STATUS "FILE='${FILE}'") +unset(FILE CACHE) + +find_file(FILE + NAMES PrefixInPATH.h + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include + VALIDATOR check_ko + ) +message(STATUS "FILE='${FILE}'") +unset(FILE CACHE) diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index de0ee14..cc005d0 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -13,6 +13,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) run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp") diff --git a/Tests/RunCMake/find_library/VALIDATOR-no-function-result.txt b/Tests/RunCMake/find_library/VALIDATOR-no-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-no-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/VALIDATOR-no-function-stderr.txt b/Tests/RunCMake/find_library/VALIDATOR-no-function-stderr.txt new file mode 100644 index 0000000..6c04aa4 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-no-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-no-function.cmake:[0-9]+ \(find_library\): + find_library missing required argument for "VALIDATOR" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_library/VALIDATOR-no-function.cmake b/Tests/RunCMake/find_library/VALIDATOR-no-function.cmake new file mode 100644 index 0000000..516e54e --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-no-function.cmake @@ -0,0 +1,2 @@ + +find_library(result NAMES input.txt VALIDATOR) diff --git a/Tests/RunCMake/find_library/VALIDATOR-specify-macro-result.txt b/Tests/RunCMake/find_library/VALIDATOR-specify-macro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-specify-macro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/VALIDATOR-specify-macro-stderr.txt b/Tests/RunCMake/find_library/VALIDATOR-specify-macro-stderr.txt new file mode 100644 index 0000000..03e7df9 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-specify-macro-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-specify-macro.cmake:[0-9]+ \(find_library\): + find_library 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_library/VALIDATOR-specify-macro.cmake b/Tests/RunCMake/find_library/VALIDATOR-specify-macro.cmake new file mode 100644 index 0000000..fa90d72 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-specify-macro.cmake @@ -0,0 +1,5 @@ + +macro(CHECK result path) +endmacro() + +find_library(result NAMES input.txt VALIDATOR check) diff --git a/Tests/RunCMake/find_library/VALIDATOR-stderr.txt b/Tests/RunCMake/find_library/VALIDATOR-stderr.txt new file mode 100644 index 0000000..7211450 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-stderr.txt @@ -0,0 +1,3 @@ +CHECK='[^']+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' +CHECK='[^']+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' +CHECK='[^']+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' diff --git a/Tests/RunCMake/find_library/VALIDATOR-stdout.txt b/Tests/RunCMake/find_library/VALIDATOR-stdout.txt new file mode 100644 index 0000000..bd2549b --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-stdout.txt @@ -0,0 +1,3 @@ +-- LIB='[^']+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' +-- LIB='[^']+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' +-- LIB='LIB-NOTFOUND' diff --git a/Tests/RunCMake/find_library/VALIDATOR-undefined-function-result.txt b/Tests/RunCMake/find_library/VALIDATOR-undefined-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-undefined-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/VALIDATOR-undefined-function-stderr.txt b/Tests/RunCMake/find_library/VALIDATOR-undefined-function-stderr.txt new file mode 100644 index 0000000..dc7ad9e --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-undefined-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-undefined-function.cmake:[0-9]+ \(find_library\): + find_library command specified for "VALIDATOR" is undefined: undefined. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_library/VALIDATOR-undefined-function.cmake b/Tests/RunCMake/find_library/VALIDATOR-undefined-function.cmake new file mode 100644 index 0000000..9ac7ee0 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR-undefined-function.cmake @@ -0,0 +1,2 @@ + +find_library(result NAMES input.txt VALIDATOR undefined) diff --git a/Tests/RunCMake/find_library/VALIDATOR.cmake b/Tests/RunCMake/find_library/VALIDATOR.cmake new file mode 100644 index 0000000..7593941 --- /dev/null +++ b/Tests/RunCMake/find_library/VALIDATOR.cmake @@ -0,0 +1,41 @@ +list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) +list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) + +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_library(LIB + NAMES PrefixInPATH + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib + VALIDATOR check_default + ) +message(STATUS "LIB='${LIB}'") +unset(LIB CACHE) + +find_library(LIB + NAMES PrefixInPATH + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib + VALIDATOR check_ok + ) +message(STATUS "LIB='${LIB}'") +unset(LIB CACHE) + +find_library(LIB + NAMES PrefixInPATH + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib + VALIDATOR check_ko + ) +message(STATUS "LIB='${LIB}'") +unset(LIB CACHE) 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) diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index d0ce8fc..f8ecb8f 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -9,6 +9,10 @@ run_cmake(NO_CACHE) run_cmake(IgnorePrefixPath) 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(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$") run_cmake(WindowsCom) diff --git a/Tests/RunCMake/find_program/VALIDATOR-no-function-result.txt b/Tests/RunCMake/find_program/VALIDATOR-no-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-no-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/VALIDATOR-no-function-stderr.txt b/Tests/RunCMake/find_program/VALIDATOR-no-function-stderr.txt new file mode 100644 index 0000000..b8868af --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-no-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-no-function.cmake:[0-9]+ \(find_program\): + find_program missing required argument for "VALIDATOR" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_program/VALIDATOR-no-function.cmake b/Tests/RunCMake/find_program/VALIDATOR-no-function.cmake new file mode 100644 index 0000000..0d6a74f --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-no-function.cmake @@ -0,0 +1,2 @@ + +find_program(result NAMES input.txt VALIDATOR) diff --git a/Tests/RunCMake/find_program/VALIDATOR-specify-macro-result.txt b/Tests/RunCMake/find_program/VALIDATOR-specify-macro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-specify-macro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/VALIDATOR-specify-macro-stderr.txt b/Tests/RunCMake/find_program/VALIDATOR-specify-macro-stderr.txt new file mode 100644 index 0000000..1ae5148 --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-specify-macro-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-specify-macro.cmake:[0-9]+ \(find_program\): + find_program 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_program/VALIDATOR-specify-macro.cmake b/Tests/RunCMake/find_program/VALIDATOR-specify-macro.cmake new file mode 100644 index 0000000..43bb9ec --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-specify-macro.cmake @@ -0,0 +1,5 @@ + +macro(CHECK result path) +endmacro() + +find_program(result NAMES input.txt VALIDATOR check) diff --git a/Tests/RunCMake/find_program/VALIDATOR-stderr.txt b/Tests/RunCMake/find_program/VALIDATOR-stderr.txt new file mode 100644 index 0000000..6704ed1 --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-stderr.txt @@ -0,0 +1,3 @@ +CHECK='[^']+/Tests/RunCMake/find_program/A/testA' +CHECK='[^']+/Tests/RunCMake/find_program/A/testA' +CHECK='[^']+/Tests/RunCMake/find_program/A/testA' diff --git a/Tests/RunCMake/find_program/VALIDATOR-stdout.txt b/Tests/RunCMake/find_program/VALIDATOR-stdout.txt new file mode 100644 index 0000000..d434742 --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-stdout.txt @@ -0,0 +1,3 @@ +-- PROG='[^']+/Tests/RunCMake/find_program/A/testA' +-- PROG='[^']+/Tests/RunCMake/find_program/A/testA' +-- PROG='PROG-NOTFOUND' diff --git a/Tests/RunCMake/find_program/VALIDATOR-undefined-function-result.txt b/Tests/RunCMake/find_program/VALIDATOR-undefined-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-undefined-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/VALIDATOR-undefined-function-stderr.txt b/Tests/RunCMake/find_program/VALIDATOR-undefined-function-stderr.txt new file mode 100644 index 0000000..a89ffa0 --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-undefined-function-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at VALIDATOR-undefined-function.cmake:[0-9]+ \(find_program\): + find_program command specified for "VALIDATOR" is undefined: undefined. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_program/VALIDATOR-undefined-function.cmake b/Tests/RunCMake/find_program/VALIDATOR-undefined-function.cmake new file mode 100644 index 0000000..96be5fd --- /dev/null +++ b/Tests/RunCMake/find_program/VALIDATOR-undefined-function.cmake @@ -0,0 +1,2 @@ + +find_program(result NAMES input.txt VALIDATOR undefined) diff --git a/Tests/RunCMake/find_program/VALIDATOR.cmake b/Tests/RunCMake/find_program/VALIDATOR.cmake new file mode 100644 index 0000000..8be2b39 --- /dev/null +++ b/Tests/RunCMake/find_program/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_program(PROG + NAMES testA + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A + VALIDATOR check_default + ) +message(STATUS "PROG='${PROG}'") +unset(PROG CACHE) + +find_program(PROG + NAMES testA + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A + VALIDATOR check_ok + ) +message(STATUS "PROG='${PROG}'") +unset(PROG CACHE) + +find_program(PROG + NAMES testA + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A + VALIDATOR check_ko + ) +message(STATUS "PROG='${PROG}'") +unset(PROG CACHE) |