Browse Source

Merge topic 'find_program-exe-no-read'

86e6349ef7 find_program: Find programs that are executable but not readable

Acked-by: Kitware Robot <[email protected]>
Merge-request: !4571
Brad King 5 years ago
parent
commit
bf120819c4

+ 1 - 1
Source/cmFindProgramCommand.cxx

@@ -85,7 +85,7 @@ struct cmFindProgramHelper
       this->TestNameExt = cmStrCat(name, ext);
       this->TestPath =
         cmSystemTools::CollapseFullPath(this->TestNameExt, path);
-      bool exists = cmSystemTools::FileExists(this->TestPath, true);
+      bool exists = cmSystemTools::FileIsExecutable(this->TestPath);
       exists ? this->DebugSearches.FoundAt(this->TestPath)
              : this->DebugSearches.FailedAt(this->TestPath);
       if (exists) {

+ 1 - 0
Tests/RunCMake/find_program/ExeNoRead-stdout.txt

@@ -0,0 +1 @@
+-- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/ExeNoRead-build/ExeNoRead'

+ 4 - 0
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}'")

+ 4 - 0
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()