1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: ccmake.cxx,v $
6 Date: $Date: 2007-12-13 22:56:50 $
7 Version: $Revision: 1.37 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "../cmCacheManager.h"
18 #include "../cmSystemTools.h"
20 #include "../cmDocumentation.h"
23 #include <sys/ioctl.h>
25 #include "cmCursesMainForm.h"
26 #include "cmCursesStandardIncludes.h"
30 //----------------------------------------------------------------------------
31 static const char * cmDocumentationName
[][3] =
34 " ccmake - Curses Interface for CMake.", 0},
38 //----------------------------------------------------------------------------
39 static const char * cmDocumentationUsage
[][3] =
42 " ccmake <path-to-source>\n"
43 " ccmake <path-to-existing-build>", 0},
47 //----------------------------------------------------------------------------
48 static const char * cmDocumentationDescription
[][3] =
51 "The \"ccmake\" executable is the CMake curses interface. Project "
52 "configuration settings may be specified interactively through "
53 "this GUI. Brief instructions are provided at the bottom of the "
54 "terminal when the program is running.", 0},
55 CMAKE_STANDARD_INTRODUCTION
,
59 //----------------------------------------------------------------------------
60 static const char * cmDocumentationOptions
[][3] =
62 CMAKE_STANDARD_OPTIONS_TABLE
,
66 //----------------------------------------------------------------------------
67 static const char * cmDocumentationSeeAlso
[][3] =
74 cmCursesForm
* cmCursesForm::CurrentForm
=0;
81 if (cmCursesForm::CurrentForm
)
84 initscr(); /* Initialization */
85 noecho(); /* Echo off */
86 cbreak(); /* nl- or cr not needed */
87 keypad(stdscr
,TRUE
); /* Use key symbols as
91 getmaxyx(stdscr
, y
, x
);
92 cmCursesForm::CurrentForm
->Render(1,1,x
,y
);
93 cmCursesForm::CurrentForm
->UpdateStatusBar();
95 signal(SIGWINCH
, onsig
);
100 void CMakeErrorHandler(const char* message
, const char* title
, bool&, void* clientData
)
102 cmCursesForm
* self
= static_cast<cmCursesForm
*>( clientData
);
103 self
->AddError(message
, title
);
106 int main(int argc
, char** argv
)
108 cmSystemTools::FindExecutableDirectory(argv
[0]);
110 if(doc
.CheckOptions(argc
, argv
))
113 std::vector
<cmDocumentationEntry
> commands
;
114 std::vector
<cmDocumentationEntry
> compatCommands
;
115 std::vector
<cmDocumentationEntry
> generators
;
116 hcm
.GetCommandDocumentation(commands
, true, false);
117 hcm
.GetCommandDocumentation(compatCommands
, false, true);
118 hcm
.GetGeneratorDocumentation(generators
);
119 doc
.SetName("ccmake");
120 doc
.SetSection("Name",cmDocumentationName
);
121 doc
.SetSection("Usage",cmDocumentationUsage
);
122 doc
.SetSection("Description",cmDocumentationDescription
);
123 doc
.SetSection("Generators",generators
);
124 doc
.SetSection("Options",cmDocumentationOptions
);
125 doc
.SetSection("Command",commands
);
126 doc
.SetSection("Compatibility Commands",compatCommands
);
127 doc
.SetSeeAlsoList(cmDocumentationSeeAlso
);
128 return doc
.PrintRequestedDocumentation(std::cout
)? 0:1;
134 std::vector
<std::string
> args
;
135 for(j
=0; j
< argc
; ++j
)
137 if(strcmp(argv
[j
], "-debug") == 0)
143 args
.push_back(argv
[j
]);
147 std::string cacheDir
= cmSystemTools::GetCurrentWorkingDirectory();
148 for(i
=1; i
< args
.size(); ++i
)
150 std::string arg
= args
[i
];
151 if(arg
.find("-B",0) == 0)
153 cacheDir
= arg
.substr(2);
157 cmSystemTools::DisableRunCommandOutput();
161 cmCursesForm::DebugStart();
164 initscr(); /* Initialization */
165 noecho(); /* Echo off */
166 cbreak(); /* nl- or cr not needed */
167 keypad(stdscr
,TRUE
); /* Use key symbols as
170 signal(SIGWINCH
, onsig
);
173 getmaxyx(stdscr
, y
, x
);
174 if ( x
< cmCursesMainForm::MIN_WIDTH
||
175 y
< cmCursesMainForm::MIN_HEIGHT
)
178 std::cerr
<< "Window is too small. A size of at least "
179 << cmCursesMainForm::MIN_WIDTH
<< " x "
180 << cmCursesMainForm::MIN_HEIGHT
181 << " is required to run ccmake." << std::endl
;
186 cmCursesMainForm
* myform
;
188 myform
= new cmCursesMainForm(args
, x
);
189 if(myform
->LoadCache(cacheDir
.c_str()))
195 std::cerr
<< "Error running cmake::LoadCache(). Aborting.\n";
199 cmSystemTools::SetErrorCallback(CMakeErrorHandler
, myform
);
201 cmCursesForm::CurrentForm
= myform
;
203 myform
->InitializeUI();
204 if ( myform
->Configure(1) == 0 )
206 myform
->Render(1, 1, x
, y
);
207 myform
->HandleInput();
210 // Need to clean-up better
214 delete cmCursesForm::CurrentForm
;
215 cmCursesForm::CurrentForm
= 0;
217 std::cout
<< std::endl
<< std::endl
;