[cmake-developers] Proposed change to behavior of find_program
Thompson, KT
kgt at lanl.gov
Fri Dec 19 17:46:00 EST 2014
CMake developers,
I am proposing a small change to SystemTools.cxx to address a problem I have on multiple systems. I need find_program to return the path to an executable file that is not marked with the read permission bit, but is marked with the execute bit (e.g.: chmod 111 file).
On Linux systems, find_program unnecessarily requires that a file be readable. I propose that the FileExists function be changed to test for execute permission instead of read permission:
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1148,13 +1148,13 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename)
{
return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES);
}
- return access(filename.c_str(), R_OK) == 0;
+ return access(filename.c_str(), X_OK) == 0;
#elif defined(_WIN32)
return (GetFileAttributesW(
SystemTools::ConvertToWindowsExtendedPath(filename).c_str())
!= INVALID_FILE_ATTRIBUTES);
#else
- return access(filename.c_str(), R_OK) == 0;
+ return access(filename.c_str(), X_OK) == 0;
#endif
}
Comments? Thoughts?
-kt
Kelly (KT) Thompson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141219/b82d27f4/attachment-0001.html>
More information about the cmake-developers
mailing list