diff options
author | Vladimir Menshakov <vladimir.menshakov@gmail.com> | 2020-04-04 16:16:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-09 12:08:50 (GMT) |
commit | 86e6349ef7356866704ab2a5aa439fd4d201cdd5 (patch) | |
tree | 2f6c88b8041508d8b6dc01d7caee764de18a387a /Tests | |
parent | df543e37f1c60919c98bb11494458e5dedd72c11 (diff) | |
download | CMake-86e6349ef7356866704ab2a5aa439fd4d201cdd5.zip CMake-86e6349ef7356866704ab2a5aa439fd4d201cdd5.tar.gz CMake-86e6349ef7356866704ab2a5aa439fd4d201cdd5.tar.bz2 |
find_program: Find programs that are executable but not readable
`find_program` internally uses `cmSystemTools::FileExists`
which calls `access(R_OK)` instead of `access(X_OK)`.
Use `cmSystemTools::IsFileExecutable` instead to fix this
issue. An example of such a program is `sudo`.
Fixes: #10468
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/find_program/ExeNoRead-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/ExeNoRead.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/RunCMakeTest.cmake | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt new file mode 100644 index 0000000..35a83f2 --- /dev/null +++ b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt @@ -0,0 +1 @@ +-- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/ExeNoRead-build/ExeNoRead' diff --git a/Tests/RunCMake/find_program/ExeNoRead.cmake b/Tests/RunCMake/find_program/ExeNoRead.cmake new file mode 100644 index 0000000..7e22dc5 --- /dev/null +++ b/Tests/RunCMake/find_program/ExeNoRead.cmake @@ -0,0 +1,4 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead" "#!/bin/sh\n") +execute_process(COMMAND chmod -r+x "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead") +find_program(ExeNoRead_EXECUTABLE NAMES ExeNoRead NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_BINARY_DIR}") +message(STATUS "ExeNoRead_EXECUTABLE='${ExeNoRead_EXECUTABLE}'") diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 0ff9a97..95ffd84 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -10,3 +10,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) run_cmake(WindowsExe) endif() + +if(UNIX) + run_cmake(ExeNoRead) +endif() |