forked from qt-creator/qt-creator
Environment: Use Utils::FileName for path() and related methods
Update users accordingly. Change-Id: I9432e82308e9d0630514c6c8632aeb6b6ee0cf90 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -146,43 +146,38 @@ static void readAndDeleteLegacyCMakeSettings ()
|
||||
|
||||
static QList<CMakeTool *> autoDetectCMakeTools()
|
||||
{
|
||||
FileNameList suspects;
|
||||
|
||||
Utils::Environment env = Environment::systemEnvironment();
|
||||
|
||||
QStringList path = env.path();
|
||||
path.removeDuplicates();
|
||||
Utils::FileNameList path = env.path();
|
||||
path = Utils::filteredUnique(path);
|
||||
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
const QString progFiles = QLatin1String(qgetenv("ProgramFiles"));
|
||||
path.append(progFiles + "/CMake");
|
||||
path.append(progFiles + "/CMake/bin");
|
||||
path.append(Utils::FileName::fromString(progFiles + "/CMake"));
|
||||
path.append(Utils::FileName::fromString(progFiles + "/CMake/bin"));
|
||||
const QString progFilesX86 = QLatin1String(qgetenv("ProgramFiles(x86)"));
|
||||
if (!progFilesX86.isEmpty()) {
|
||||
path.append(progFilesX86 + "/CMake");
|
||||
path.append(progFilesX86 + "/CMake/bin");
|
||||
path.append(Utils::FileName::fromString(progFilesX86 + "/CMake"));
|
||||
path.append(Utils::FileName::fromString(progFilesX86 + "/CMake/bin"));
|
||||
}
|
||||
}
|
||||
|
||||
if (HostOsInfo::isMacHost()) {
|
||||
path.append("/Applications/CMake.app/Contents/bin");
|
||||
path.append("/usr/local/bin");
|
||||
path.append("/opt/local/bin");
|
||||
path.append(Utils::FileName::fromString("/Applications/CMake.app/Contents/bin"));
|
||||
path.append(Utils::FileName::fromString("/usr/local/bin"));
|
||||
path.append(Utils::FileName::fromString("/opt/local/bin"));
|
||||
}
|
||||
|
||||
QStringList execs = env.appendExeExtensions(QLatin1String("cmake"));
|
||||
const QStringList execs = env.appendExeExtensions(QLatin1String("cmake"));
|
||||
|
||||
foreach (QString base, path) {
|
||||
const QChar slash = QLatin1Char('/');
|
||||
FileNameList suspects;
|
||||
foreach (const Utils::FileName &base, path) {
|
||||
if (base.isEmpty())
|
||||
continue;
|
||||
// Avoid turning '/' into '//' on Windows which triggers Windows to check
|
||||
// for network drives!
|
||||
if (!base.endsWith(slash))
|
||||
base += slash;
|
||||
|
||||
foreach (const QString &exec, execs) {
|
||||
QFileInfo fi(base + exec);
|
||||
QFileInfo fi;
|
||||
for (const QString &exec : execs) {
|
||||
fi.setFile(base.toString(), exec);
|
||||
if (fi.exists() && fi.isFile() && fi.isExecutable())
|
||||
suspects << FileName::fromString(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user