diff options
author | Brad King <brad.king@kitware.com> | 2018-06-18 14:08:01 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-06-18 14:08:54 (GMT) |
commit | b0b99d877e92028a0265ac86d1d6c79276a04811 (patch) | |
tree | 354c88c71d9944c40360b744ea9f4579c6f9e629 /Tests/RunCMake | |
parent | a75638c1301df84de6af61cff2acd781c59cafa2 (diff) | |
parent | c76c1ea2086a071c0afb143918b275bb8cf3b806 (diff) | |
download | CMake-b0b99d877e92028a0265ac86d1d6c79276a04811.zip CMake-b0b99d877e92028a0265ac86d1d6c79276a04811.tar.gz CMake-b0b99d877e92028a0265ac86d1d6c79276a04811.tar.bz2 |
Merge topic 'find_program-conditional-cwd'
c76c1ea208 find_program: Consider CWD only for paths with separator
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2120
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/RelAndAbsPath.cmake | 63 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/RunCMakeTest.cmake | 1 | ||||
-rwxr-xr-x | Tests/RunCMake/find_program/testCWD | 1 |
4 files changed, 71 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt new file mode 100644 index 0000000..cb3c99f --- /dev/null +++ b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt @@ -0,0 +1,6 @@ +-- PROG_ABS='PROG_ABS-NOTFOUND' +-- PROG_ABS_NPD='PROG_ABS_NPD-NOTFOUND' +-- PROG_CWD='PROG_CWD-NOTFOUND' +-- PROG_CWD_NPD='PROG_CWD_NPD-NOTFOUND' +-- PROG_CWD_DOT='[^']*/Tests/RunCMake/find_program/testCWD' +-- PROG_CWD_DOT_NPD='[^']*/Tests/RunCMake/find_program/testCWD' diff --git a/Tests/RunCMake/find_program/RelAndAbsPath.cmake b/Tests/RunCMake/find_program/RelAndAbsPath.cmake new file mode 100644 index 0000000..9a42c5e --- /dev/null +++ b/Tests/RunCMake/find_program/RelAndAbsPath.cmake @@ -0,0 +1,63 @@ +# testNoSuchFile should only be found if the file absolute path is +# incorrectly prepended with the search path. + +function(strip_windows_path_prefix p outvar) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + string(REGEX REPLACE "^.:" "" p "${p}") + endif() + set(${outvar} "${p}" PARENT_SCOPE) +endfunction() + +strip_windows_path_prefix("${CMAKE_CURRENT_SOURCE_DIR}" srcdir) + +file(MAKE_DIRECTORY "tmp${srcdir}") +configure_file(testCWD "tmp${srcdir}/testNoSuchFile" COPYONLY) + +find_program(PROG_ABS + NAMES "${srcdir}/testNoSuchFile" + PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp" + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS='${PROG_ABS}'") + +find_program(PROG_ABS_NPD + NAMES "${srcdir}/testNoSuchFile" + PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp" + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS_NPD='${PROG_ABS_NPD}'") + +# ./testCWD should not be found without '.' being in the path list. + +configure_file(testCWD testCWD COPYONLY) + +find_program(PROG_CWD + NAMES testCWD + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD='${PROG_CWD}'") + +find_program(PROG_CWD_NPD + NAMES testCWD + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_NPD='${PROG_CWD_NPD}'") + +# Confirm that adding '.' to path does locate ./testCWD. + +find_program(PROG_CWD_DOT + NAMES testCWD + PATHS . + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_DOT='${PROG_CWD_DOT}'") + +find_program(PROG_CWD_DOT_NPD + NAMES testCWD + PATHS . + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_DOT_NPD='${PROG_CWD_DOT_NPD}'") diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 89307c1..6903f05 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(EnvAndHints) run_cmake(DirsPerName) run_cmake(NamesPerDir) +run_cmake(RelAndAbsPath) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) diff --git a/Tests/RunCMake/find_program/testCWD b/Tests/RunCMake/find_program/testCWD new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/Tests/RunCMake/find_program/testCWD @@ -0,0 +1 @@ +#!/bin/sh |