diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index d5870e83d77..83cc3273f18 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -852,9 +852,31 @@ void CMakeBuildSystem::ensureBuildDirectory(const BuildDirParameters ¶meters { const FilePath bdir = parameters.buildDirectory; - if (!buildConfiguration()->createBuildDirectory()) - handleParsingFailed( - tr("Failed to create build directory \"%1\".").arg(bdir.toUserOutput())); + if (!buildConfiguration()->createBuildDirectory()) { + handleParsingFailed(tr("Failed to create build directory \"%1\".").arg(bdir.toUserOutput())); + return; + } + + const CMakeTool *tool = parameters.cmakeTool(); + if (!tool) { + handleParsingFailed(tr("No CMake tool set up in kit.")); + return; + } + + if (tool->cmakeExecutable().needsDevice()) { + if (bdir.needsDevice()) { + if (bdir.scheme() != tool->cmakeExecutable().scheme() + || bdir.host() != tool->cmakeExecutable().host()) { + handleParsingFailed( + tr("The CMake executable and the build directory are not on the same device.")); + return; + } + } else if (!tool->cmakeExecutable().ensureReachable(bdir)) { + // Make sure that the build directory is available on the device. + handleParsingFailed( + tr("The remote CMake executable cannot write to the local build directory.")); + } + } } void CMakeBuildSystem::stopParsingAndClearState() diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index 4752743da88..fd158ac61e5 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -55,6 +55,15 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & const FilePath cmakeExecutable = cmake->cmakeExecutable(); + if (!cmakeExecutable.ensureReachable(parameters.sourceDirectory) + || !cmakeExecutable.ensureReachable(parameters.buildDirectory)) { + QString msg = ::CMakeProjectManager::Internal::CMakeProcess::tr( + "The source or build directory is not reachable by the CMake executable."); + BuildSystem::appendBuildSystemOutput(msg + '\n'); + emit finished(); + return; + } + const FilePath sourceDirectory = parameters.sourceDirectory.onDevice(cmakeExecutable); const FilePath buildDirectory = parameters.buildDirectory.onDevice(cmakeExecutable);