diff options
author | Brad King <brad.king@kitware.com> | 2021-10-29 13:10:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-11-01 13:03:51 (GMT) |
commit | 37c2f722fcae58f2834a061f52f2ddb78dac2fb2 (patch) | |
tree | c42d4b6e5bf899b8f7fd616ca89c74328a8a8801 /Source/cmFindProgramCommand.cxx | |
parent | d8b5b0c7e429bb1011027ab59fc2b5d3e2222ab0 (diff) | |
download | CMake-37c2f722fcae58f2834a061f52f2ddb78dac2fb2.zip CMake-37c2f722fcae58f2834a061f52f2ddb78dac2fb2.tar.gz CMake-37c2f722fcae58f2834a061f52f2ddb78dac2fb2.tar.bz2 |
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.
Diffstat (limited to 'Source/cmFindProgramCommand.cxx')
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 1c87625..9a4b063 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -104,6 +104,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: return cmSystemTools::FileExists(file, true); |