|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
#include "cmMakefile.h"
|
|
|
#include "cmMessageType.h"
|
|
|
+#include "cmPolicies.h"
|
|
|
#include "cmStateTypes.h"
|
|
|
#include "cmStringAlgorithms.h"
|
|
|
#include "cmSystemTools.h"
|
|
|
@@ -19,6 +20,7 @@ struct cmFindProgramHelper
|
|
|
cmFindProgramHelper(cmMakefile* makefile, cmFindBase const* base)
|
|
|
: DebugSearches("find_program", base)
|
|
|
, Makefile(makefile)
|
|
|
+ , PolicyCMP0109(makefile->GetPolicyStatus(cmPolicies::CMP0109))
|
|
|
{
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
|
|
|
// Consider platform-specific extensions.
|
|
|
@@ -48,6 +50,8 @@ struct cmFindProgramHelper
|
|
|
cmFindBaseDebugState DebugSearches;
|
|
|
cmMakefile* Makefile;
|
|
|
|
|
|
+ cmPolicies::PolicyStatus PolicyCMP0109;
|
|
|
+
|
|
|
void AddName(std::string const& name) { this->Names.push_back(name); }
|
|
|
void SetName(std::string const& name)
|
|
|
{
|
|
|
@@ -85,7 +89,7 @@ struct cmFindProgramHelper
|
|
|
this->TestNameExt = cmStrCat(name, ext);
|
|
|
this->TestPath =
|
|
|
cmSystemTools::CollapseFullPath(this->TestNameExt, path);
|
|
|
- bool exists = cmSystemTools::FileExists(this->TestPath, true);
|
|
|
+ bool exists = this->FileIsExecutable(this->TestPath);
|
|
|
exists ? this->DebugSearches.FoundAt(this->TestPath)
|
|
|
: this->DebugSearches.FailedAt(this->TestPath);
|
|
|
if (exists) {
|
|
|
@@ -95,6 +99,48 @@ struct cmFindProgramHelper
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+ bool FileIsExecutable(std::string const& file) const
|
|
|
+ {
|
|
|
+ switch (this->PolicyCMP0109) {
|
|
|
+ case cmPolicies::OLD:
|
|
|
+ return cmSystemTools::FileExists(file, true);
|
|
|
+ case cmPolicies::NEW:
|
|
|
+ case cmPolicies::REQUIRED_ALWAYS:
|
|
|
+ case cmPolicies::REQUIRED_IF_USED:
|
|
|
+ return cmSystemTools::FileIsExecutable(file);
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ bool const isExeOld = cmSystemTools::FileExists(file, true);
|
|
|
+ bool const isExeNew = cmSystemTools::FileIsExecutable(file);
|
|
|
+ if (isExeNew == isExeOld) {
|
|
|
+ return isExeNew;
|
|
|
+ }
|
|
|
+ if (isExeNew) {
|
|
|
+ this->Makefile->IssueMessage(
|
|
|
+ MessageType::AUTHOR_WARNING,
|
|
|
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0109),
|
|
|
+ "\n"
|
|
|
+ "The file\n"
|
|
|
+ " ",
|
|
|
+ file,
|
|
|
+ "\n"
|
|
|
+ "is executable but not readable. "
|
|
|
+ "CMake is ignoring it for compatibility."));
|
|
|
+ } else {
|
|
|
+ this->Makefile->IssueMessage(
|
|
|
+ MessageType::AUTHOR_WARNING,
|
|
|
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0109),
|
|
|
+ "\n"
|
|
|
+ "The file\n"
|
|
|
+ " ",
|
|
|
+ file,
|
|
|
+ "\n"
|
|
|
+ "is readable but not executable. "
|
|
|
+ "CMake is using it for compatibility."));
|
|
|
+ }
|
|
|
+ return isExeOld;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status)
|