mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
find_program: Explicitly skip WindowsApps/python*.exe app installer links
Windows provide a "python" executable like this:
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps\python.exe
It is actually a Windows app exec link. If it points to an app
installer, avoid mistaking it for a working Python.
This commit is contained in:
@@ -103,6 +103,26 @@ struct cmFindProgramHelper
|
||||
});
|
||||
}
|
||||
bool FileIsExecutable(std::string const& file) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!this->FileIsExecutableCMP0109(file)) {
|
||||
return false;
|
||||
}
|
||||
// Pretend the Windows "python" app installer alias does not exist.
|
||||
if (cmSystemTools::LowerCase(file).find("/windowsapps/python") !=
|
||||
std::string::npos) {
|
||||
std::string dest;
|
||||
if (cmSystemTools::ReadSymlink(file, dest) &&
|
||||
cmHasLiteralSuffix(dest, "\\AppInstallerPythonRedirector.exe")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
return this->FileIsExecutableCMP0109(file);
|
||||
#endif
|
||||
}
|
||||
bool FileIsExecutableCMP0109(std::string const& file) const
|
||||
{
|
||||
switch (this->PolicyCMP0109) {
|
||||
case cmPolicies::OLD:
|
||||
|
||||
Reference in New Issue
Block a user