From 8ea2db2639b55b5c3590a594f9beddd9740cf679 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 19 May 2015 10:13:08 -0400 Subject: [PATCH] cmake-gui: Replace command-line install dialog with information box The QMacInstallDialog infrastructure no longer works on modern OS X versions. Drop it and replace the dialog with a simple info box that explains to the user how to run 'cmake-gui --install' to add symlinks. Also suggest simply modifying the PATH. This approach is similar to the Xcode 'xcode-select --install' method of installing Xcode Command Line Tools. --- Source/QtDialog/CMakeLists.txt | 4 - Source/QtDialog/CMakeSetup.cxx | 1 - Source/QtDialog/CMakeSetupDialog.cxx | 36 +++++++- Source/QtDialog/MacInstallDialog.ui | 103 ---------------------- Source/QtDialog/QMacInstallDialog.cxx | 121 -------------------------- Source/QtDialog/QMacInstallDialog.h | 20 ----- 6 files changed, 32 insertions(+), 253 deletions(-) delete mode 100644 Source/QtDialog/MacInstallDialog.ui delete mode 100644 Source/QtDialog/QMacInstallDialog.cxx delete mode 100644 Source/QtDialog/QMacInstallDialog.h diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 9cc993a79..168f57d04 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -99,15 +99,12 @@ set(SRCS QCMakeCacheView.h QCMakeWidgets.cxx QCMakeWidgets.h - QMacInstallDialog.cxx - QMacInstallDialog.h ) QT4_WRAP_UI(UI_SRCS CMakeSetupDialog.ui Compilers.ui CrossCompiler.ui AddCacheEntry.ui - MacInstallDialog.ui ) QT4_WRAP_CPP(MOC_SRCS AddCacheEntry.h @@ -117,7 +114,6 @@ QT4_WRAP_CPP(MOC_SRCS QCMake.h QCMakeCacheView.h QCMakeWidgets.h - QMacInstallDialog.h ) QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 167f37c07..2d336ee95 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -15,7 +15,6 @@ #include #include #include -#include "QMacInstallDialog.h" #include "CMakeSetupDialog.h" #include "cmDocumentation.h" #include "cmake.h" diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index b8077f227..426fa1217 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "QCMake.h" @@ -121,7 +120,7 @@ CMakeSetupDialog::CMakeSetupDialog() this, SLOT(showUserChanges())); #if defined(Q_WS_MAC) || defined(Q_OS_MAC) this->InstallForCommandLineAction - = ToolsMenu->addAction(tr("&Install For Command Line Use")); + = ToolsMenu->addAction(tr("&How to Install For Command Line Use")); QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)), this, SLOT(doInstallForCommandLine())); #endif @@ -420,8 +419,37 @@ bool CMakeSetupDialog::doConfigureInternal() void CMakeSetupDialog::doInstallForCommandLine() { - QMacInstallDialog setupdialog(0); - setupdialog.exec(); + QString title = tr("How to Install For Command Line Use"); + QString msg = tr( + "One may add CMake to the PATH:\n" + "\n" + " PATH=\"%1\":\"$PATH\"\n" + "\n" + "Or, to install symlinks to '/usr/bin', run:\n" + "\n" + " sudo \"%2\" --install\n" + "\n" + "Or, to install symlinks to another directory, run:\n" + "\n" + " sudo \"%3\" --install=/path/to/bin\n" + ); + msg = msg.arg(cmSystemTools::GetFilenamePath( + cmSystemTools::GetCMakeCommand()).c_str()); + msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str()); + msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str()); + + QDialog dialog; + dialog.setWindowTitle(title); + QVBoxLayout* l = new QVBoxLayout(&dialog); + QLabel* lab = new QLabel(&dialog); + l->addWidget(lab); + lab->setText(msg); + lab->setWordWrap(false); + QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok, + Qt::Horizontal, &dialog); + QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept())); + l->addWidget(btns); + dialog.exec(); } bool CMakeSetupDialog::doGenerateInternal() diff --git a/Source/QtDialog/MacInstallDialog.ui b/Source/QtDialog/MacInstallDialog.ui deleted file mode 100644 index c7e31dbbe..000000000 --- a/Source/QtDialog/MacInstallDialog.ui +++ /dev/null @@ -1,103 +0,0 @@ - - Dialog - - - - 0 - 0 - 470 - 159 - - - - Install Command Line Tools - - - - 9 - - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Skip Install Command Line - - - - - - - Install Command Line Links - - - - - - - - - Choose... - - - - - - - Install Folder: - - - - - - - - - - This will create symbolic links to the command line tools of cmake into the specified install folder. - - - true - - - - - - - - diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx deleted file mode 100644 index fa7df4339..000000000 --- a/Source/QtDialog/QMacInstallDialog.cxx +++ /dev/null @@ -1,121 +0,0 @@ -#include "QMacInstallDialog.h" -#include -#include "cmSystemTools.h" -#include -#include -#include "ui_MacInstallDialog.h" - -class QMacInstallDialog::QMacInstallDialogInternals : public Ui::Dialog -{ -public: -}; - -QMacInstallDialog::QMacInstallDialog(QWidget*w) - :QDialog(w) -{ - this->Internals = new QMacInstallDialogInternals; - this->Internals->setupUi(this); - QObject::connect(this->Internals->choosePathButton, SIGNAL(clicked(bool)), - this, SLOT(ShowBrowser())); - QObject::connect(this->Internals->skipInstallButton, SIGNAL(clicked(bool)), - this, SLOT(SkipInstall())); - QObject::connect(this->Internals->doInstallButton, SIGNAL(clicked(bool)), - this, SLOT(DoInstall())); - this->Internals->InstallPrefix->setText("/usr/bin/"); - -} - -QMacInstallDialog::~QMacInstallDialog() -{ - delete this->Internals; -} - -void QMacInstallDialog::DoInstall() -{ - QDir installDir(this->Internals->InstallPrefix->text()); - QString installTo = installDir.path(); - if(!cmSystemTools::FileExists(installTo.toLocal8Bit().data())) - { - QString message = tr("Build install does not exist, " - "should I create it?\n\n" - "Directory: "); - message += installDir.path(); - QString title = tr("Create Directory"); - QMessageBox::StandardButton btn; - btn = QMessageBox::information(this, title, message, - QMessageBox::Yes | QMessageBox::No); - if(btn == QMessageBox::Yes) - { - cmSystemTools::MakeDirectory(installTo.toLocal8Bit().data()); - } - } - QDir cmExecDir(QApplication::applicationDirPath()); - cmExecDir.cd("../bin"); - QFileInfoList list = cmExecDir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo = list.at(i); - QString filename = fileInfo.fileName(); - if(filename.size() && filename[0] == '.') - { - continue; - } - QString file = fileInfo.absoluteFilePath(); - QString newName = installTo; - newName += "/"; - newName += filename; - // Remove the old files - if(cmSystemTools::FileExists(newName.toLocal8Bit().data())) - { - std::cout << "rm [" << newName.toLocal8Bit().data() << "]\n"; - if(!cmSystemTools::RemoveFile(newName.toLocal8Bit().data())) - { - QString message = tr("Failed to remove file " - "installation may be incomplete: "); - message += newName; - QString title = tr("Error Removing file"); - QMessageBox::StandardButton btn = - QMessageBox::critical(this, title, message, - QMessageBox::Ok|QMessageBox::Abort); - if(btn == QMessageBox::Abort) - { - return; - } - } - } - std::cout << "ln -s [" << file.toLocal8Bit().data() << "] ["; - std::cout << newName.toLocal8Bit().data() << "]\n"; - if(!cmSystemTools::CreateSymlink(file.toLocal8Bit().data(), - newName.toLocal8Bit().data())) - { - QString message = tr("Failed create symlink " - "installation may be incomplete: "); - message += newName; - QString title = tr("Error Creating Symlink"); - QMessageBox::StandardButton btn = - QMessageBox::critical(this, title, message, - QMessageBox::Ok|QMessageBox::Abort); - if(btn == QMessageBox::Abort) - { - return; - } - } - } - this->done(0); -} - -void QMacInstallDialog::SkipInstall() -{ - this->done(0); -} - - -void QMacInstallDialog::ShowBrowser() -{ - QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Install Prefix"), this->Internals->InstallPrefix->text()); - if(!dir.isEmpty()) - { - this->Internals->InstallPrefix->setText(dir); - } -} diff --git a/Source/QtDialog/QMacInstallDialog.h b/Source/QtDialog/QMacInstallDialog.h deleted file mode 100644 index efe67dfaf..000000000 --- a/Source/QtDialog/QMacInstallDialog.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QMacInstallDialog_h -#define QMacInstallDialog_h -#include - -class QMacInstallDialog : public QDialog -{ - Q_OBJECT; -public: - QMacInstallDialog(QWidget*w); - ~QMacInstallDialog(); -private slots: - void ShowBrowser(); - void SkipInstall(); - void DoInstall(); -private: - class QMacInstallDialogInternals; - QMacInstallDialogInternals* Internals; -}; - -#endif