forked from qt-creator/qt-creator
Run CMake via canonical path instead of warning
Running CMake via a non-canonical path (including '..' in the path, or
via a symlink) can result in funny errors.
de6faa0f15 added a warning for that
condition. Unfortunately the auto-detection of CMake can return a path
to a symlink (e.g. for CMake from brew on macOS). Also it is helpful to
use a symlink to e.g. manage different CMake versions.
Instead of warning about the condition, and forcing the user to resolve
it manually, simply run CMake via its canonical path when actually
running it from Qt Creator.
Change-Id: I95623b45c5436a6d61c1419b7aba23e2a73a0650
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -96,7 +96,7 @@ public:
|
||||
CMakeToolTreeItem(const CMakeTool *item, bool changed)
|
||||
: m_id(item->id())
|
||||
, m_name(item->displayName())
|
||||
, m_executable(item->cmakeExecutable())
|
||||
, m_executable(item->filePath())
|
||||
, m_isAutoRun(item->isAutoRun())
|
||||
, m_autoCreateBuildDirectory(item->autoCreateBuildDirectory())
|
||||
, m_autodetected(item->isAutoDetected())
|
||||
@@ -130,7 +130,6 @@ public:
|
||||
m_pathExists = fi.exists();
|
||||
m_pathIsFile = fi.isFile();
|
||||
m_pathIsExecutable = fi.isExecutable();
|
||||
m_pathIsCanonical = CMakeTool::isCanonicalPath(m_executable);
|
||||
}
|
||||
|
||||
CMakeToolTreeItem() = default;
|
||||
@@ -175,8 +174,6 @@ public:
|
||||
error = QCoreApplication::translate(
|
||||
"CMakeProjectManager::Internal::CMakeToolTreeItem",
|
||||
"CMake executable path is not executable.");
|
||||
} else if (!m_pathIsCanonical) {
|
||||
error = CMakeTool::nonCanonicalPathToCMakeExecutableWarningMessage();
|
||||
}
|
||||
if (result.isEmpty() || error.isEmpty())
|
||||
return QString("%1%2").arg(result).arg(error);
|
||||
@@ -190,9 +187,6 @@ public:
|
||||
const bool hasError = !m_pathExists || !m_pathIsFile || !m_pathIsExecutable;
|
||||
if (hasError)
|
||||
return Utils::Icons::CRITICAL.icon();
|
||||
const bool hasWarning = !m_pathIsCanonical;
|
||||
if (hasWarning)
|
||||
return Utils::Icons::WARNING.icon();
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
@@ -207,7 +201,6 @@ public:
|
||||
bool m_pathExists = false;
|
||||
bool m_pathIsFile = false;
|
||||
bool m_pathIsExecutable = false;
|
||||
bool m_pathIsCanonical = false;
|
||||
bool m_autoCreateBuildDirectory = false;
|
||||
bool m_autodetected = false;
|
||||
bool m_changed = true;
|
||||
@@ -272,7 +265,7 @@ void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
|
||||
{
|
||||
CMakeTool *orig = CMakeToolManager::findById(item->m_id);
|
||||
item->m_changed = !orig || orig->displayName() != item->m_name
|
||||
|| orig->cmakeExecutable() != item->m_executable;
|
||||
|| orig->filePath() != item->m_executable;
|
||||
|
||||
//make sure the item is marked as changed when the default cmake was changed
|
||||
CMakeTool *origDefTool = CMakeToolManager::defaultCMakeTool();
|
||||
@@ -333,7 +326,7 @@ void CMakeToolItemModel::apply()
|
||||
item->m_changed = false;
|
||||
if (CMakeTool *cmake = CMakeToolManager::findById(item->m_id)) {
|
||||
cmake->setDisplayName(item->m_name);
|
||||
cmake->setCMakeExecutable(item->m_executable);
|
||||
cmake->setFilePath(item->m_executable);
|
||||
cmake->setAutorun(item->m_isAutoRun);
|
||||
cmake->setAutoCreateBuildDirectory(item->m_autoCreateBuildDirectory);
|
||||
} else {
|
||||
@@ -346,7 +339,7 @@ void CMakeToolItemModel::apply()
|
||||
: CMakeTool::ManualDetection;
|
||||
auto cmake = std::make_unique<CMakeTool>(detection, item->m_id);
|
||||
cmake->setDisplayName(item->m_name);
|
||||
cmake->setCMakeExecutable(item->m_executable);
|
||||
cmake->setFilePath(item->m_executable);
|
||||
if (!CMakeToolManager::registerCMakeTool(std::move(cmake)))
|
||||
item->m_changed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user