summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-04-07 14:31:10 (GMT)
committerBrad King <brad.king@kitware.com>2020-04-07 14:31:10 (GMT)
commitff2e597ba23227e61c7d33a1168a5b5b9c858606 (patch)
tree27ccf36f1106449bd3e927483dba283b8c1743ca
parent2cc7baa1bc7f9e37b1a19d6700c64890142030d8 (diff)
parentc5635588adbfa0428ca738c3ed3e690ae058af37 (diff)
downloadCMake-ff2e597ba23227e61c7d33a1168a5b5b9c858606.zip
CMake-ff2e597ba23227e61c7d33a1168a5b5b9c858606.tar.gz
CMake-ff2e597ba23227e61c7d33a1168a5b5b9c858606.tar.bz2
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream * upstream-KWSys: KWSys 2020-04-07 (caff9c3b)
-rw-r--r--Source/kwsys/SystemTools.cxx19
-rw-r--r--Source/kwsys/SystemTools.hxx.in5
2 files changed, 17 insertions, 7 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 5ae4ff8..880b2d2 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2807,7 +2807,7 @@ std::string SystemTools::FindProgram(const std::string& name,
for (std::string const& ext : extensions) {
tryPath = name;
tryPath += ext;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -2815,7 +2815,7 @@ std::string SystemTools::FindProgram(const std::string& name,
#endif
// now try just the name
- if (SystemTools::FileExists(name, true)) {
+ if (SystemTools::FileIsExecutable(name)) {
return SystemTools::CollapseFullPath(name);
}
// now construct the path
@@ -2845,7 +2845,7 @@ std::string SystemTools::FindProgram(const std::string& name,
tryPath = p;
tryPath += name;
tryPath += ext;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -2853,7 +2853,7 @@ std::string SystemTools::FindProgram(const std::string& name,
// now try it without them
tryPath = p;
tryPath += name;
- if (SystemTools::FileExists(tryPath, true)) {
+ if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
@@ -3008,6 +3008,11 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
}
}
+bool SystemTools::FileIsExecutable(const std::string& name)
+{
+ return !FileIsDirectory(name) && TestFileAccess(name, TEST_FILE_EXECUTE);
+}
+
bool SystemTools::FileIsSymlink(const std::string& name)
{
#if defined(_WIN32)
@@ -3172,7 +3177,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
failures.push_back(self);
SystemTools::ConvertToUnixSlashes(self);
self = SystemTools::FindProgram(self);
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
if (buildDir) {
std::string intdir = ".";
#ifdef CMAKE_INTDIR
@@ -3187,14 +3192,14 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
}
}
if (installPrefix) {
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
failures.push_back(self);
self = installPrefix;
self += "/bin/";
self += exeName;
}
}
- if (!SystemTools::FileExists(self)) {
+ if (!SystemTools::FileIsExecutable(self)) {
failures.push_back(self);
std::ostringstream msg;
msg << "Can not find the command line program ";
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index e13d03e..cd7b728 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -677,6 +677,11 @@ public:
static bool FileIsDirectory(const std::string& name);
/**
+ * Return true if the file is an executable
+ */
+ static bool FileIsExecutable(const std::string& name);
+
+ /**
* Return true if the file is a symlink
*/
static bool FileIsSymlink(const std::string& name);