summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/CMakeSetup.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/QtDialog/CMakeSetup.cxx')
-rw-r--r--Source/QtDialog/CMakeSetup.cxx78
1 files changed, 67 insertions, 11 deletions
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 349269e..38d6d44 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -15,11 +15,11 @@
#include <QTranslator>
#include <QLocale>
#include <QTextCodec>
-#include "QMacInstallDialog.h"
#include "CMakeSetupDialog.h"
#include "cmDocumentation.h"
#include "cmake.h"
#include "cmVersion.h"
+#include "cmAlgorithms.h"
#include <cmsys/CommandLineArguments.hxx>
#include <cmsys/SystemTools.hxx>
#include <cmsys/Encoding.hxx>
@@ -48,6 +48,10 @@ static const char * cmDocumentationOptions[][2] =
{0,0}
};
+#if defined(Q_OS_MAC)
+static int cmOSXInstall(std::string dir);
+#endif
+
int main(int argc, char** argv)
{
cmsys::Encoding::CommandLineArguments encoding_args =
@@ -79,6 +83,17 @@ int main(int argc, char** argv)
return (doc.PrintRequestedDocumentation(std::cout)? 0:1);
}
+#if defined(Q_OS_MAC)
+ if (argc2 == 2 && strcmp(argv2[1], "--install") == 0)
+ {
+ return cmOSXInstall("/usr/bin");
+ }
+ if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install="))
+ {
+ return cmOSXInstall(argv2[1]+10);
+ }
+#endif
+
QApplication app(argc, argv);
#if defined(CMAKE_ENCODING_UTF8)
@@ -93,16 +108,6 @@ int main(int argc, char** argv)
QApplication::removeLibraryPath(p);
}
- // if arg for install
- for(int i =0; i < argc2; i++)
- {
- if(strcmp(argv2[i], "--mac-install") == 0)
- {
- QMacInstallDialog setupdialog(0);
- setupdialog.exec();
- return 0;
- }
- }
// tell the cmake library where cmake is
QDir cmExecDir(QApplication::applicationDirPath());
#if defined(Q_OS_MAC)
@@ -189,3 +194,54 @@ int main(int argc, char** argv)
return app.exec();
}
+#if defined(Q_OS_MAC)
+# include <errno.h>
+# include <string.h>
+# include <sys/stat.h>
+# include <unistd.h>
+static bool cmOSXInstall(std::string const& dir, std::string const& tool)
+{
+ if (tool.empty())
+ {
+ return true;
+ }
+ std::string link = dir + cmSystemTools::GetFilenameName(tool);
+ struct stat st;
+ if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode))
+ {
+ char buf[4096];
+ ssize_t s = readlink(link.c_str(), buf, sizeof(buf)-1);
+ if (s >= 0 && std::string(buf, s) == tool)
+ {
+ std::cerr << "Exists: '" << link << "' -> '" << tool << "'\n";
+ return true;
+ }
+ }
+ if (symlink(tool.c_str(), link.c_str()) == 0)
+ {
+ std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n";
+ return true;
+ }
+ else
+ {
+ int err = errno;
+ std::cerr << "Failed: '" << link << "' -> '" << tool << "': "
+ << strerror(err) << "\n";
+ return false;
+ }
+}
+static int cmOSXInstall(std::string dir)
+{
+ if (!cmHasLiteralSuffix(dir, "/"))
+ {
+ dir += "/";
+ }
+ return (
+ cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) &&
+ cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand())
+ ) ? 0 : 1;
+}
+#endif