|
@@ -66,6 +66,7 @@ static const char* cmDocumentationOptions[][2] = {
|
|
|
{ "-E", "CMake command mode." },
|
|
|
{ "-L[A][H]", "List non-advanced cached variables." },
|
|
|
{ "--build <dir>", "Build a CMake-generated project binary tree." },
|
|
|
+ { "--open <dir>", "Open generated project in the associated application." },
|
|
|
{ "-N", "View mode only." },
|
|
|
{ "-P <file>", "Process script mode." },
|
|
|
{ "--find-package", "Run in pkg-config like mode." },
|
|
@@ -100,6 +101,7 @@ static int do_command(int ac, char const* const* av)
|
|
|
|
|
|
int do_cmake(int ac, char const* const* av);
|
|
|
static int do_build(int ac, char const* const* av);
|
|
|
+static int do_open(int ac, char const* const* av);
|
|
|
|
|
|
static cmMakefile* cmakemainGetMakefile(void* clientdata)
|
|
|
{
|
|
@@ -186,6 +188,9 @@ int main(int ac, char const* const* av)
|
|
|
if (strcmp(av[1], "--build") == 0) {
|
|
|
return do_build(ac, av);
|
|
|
}
|
|
|
+ if (strcmp(av[1], "--open") == 0) {
|
|
|
+ return do_open(ac, av);
|
|
|
+ }
|
|
|
if (strcmp(av[1], "-E") == 0) {
|
|
|
return do_command(ac, av);
|
|
|
}
|
|
@@ -423,3 +428,41 @@ static int do_build(int ac, char const* const* av)
|
|
|
return cm.Build(dir, target, config, nativeOptions, clean);
|
|
|
#endif
|
|
|
}
|
|
|
+
|
|
|
+static int do_open(int ac, char const* const* av)
|
|
|
+{
|
|
|
+#ifndef CMAKE_BUILD_WITH_CMAKE
|
|
|
+ std::cerr << "This cmake does not support --open\n";
|
|
|
+ return -1;
|
|
|
+#else
|
|
|
+ std::string dir;
|
|
|
+
|
|
|
+ enum Doing
|
|
|
+ {
|
|
|
+ DoingNone,
|
|
|
+ DoingDir,
|
|
|
+ };
|
|
|
+ Doing doing = DoingDir;
|
|
|
+ for (int i = 2; i < ac; ++i) {
|
|
|
+ switch (doing) {
|
|
|
+ case DoingDir:
|
|
|
+ dir = cmSystemTools::CollapseFullPath(av[i]);
|
|
|
+ doing = DoingNone;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ std::cerr << "Unknown argument " << av[i] << std::endl;
|
|
|
+ dir.clear();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dir.empty()) {
|
|
|
+ std::cerr << "Usage: cmake --open <dir>\n";
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ cmake cm(cmake::RoleInternal);
|
|
|
+ cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm);
|
|
|
+ cm.SetProgressCallback(cmakemainProgressCallback, &cm);
|
|
|
+ return cm.Open(dir, false) ? 0 : 1;
|
|
|
+#endif
|
|
|
+}
|