2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2001-11-05 16:37:22 +03:00
|
|
|
#include "../cmCacheManager.h"
|
|
|
|
#include "../cmSystemTools.h"
|
2001-11-30 00:44:22 +03:00
|
|
|
#include "../cmake.h"
|
2003-02-14 18:53:37 +03:00
|
|
|
#include "../cmDocumentation.h"
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2001-11-14 17:56:33 +03:00
|
|
|
#include "cmCursesMainForm.h"
|
2007-08-27 17:01:14 +04:00
|
|
|
#include "cmCursesStandardIncludes.h"
|
2001-11-14 17:56:33 +03:00
|
|
|
|
|
|
|
#include <form.h>
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationName[][3] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
{0,
|
|
|
|
" ccmake - Curses Interface for CMake.", 0},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationUsage[][3] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
|
|
|
{0,
|
2003-08-20 21:00:46 +04:00
|
|
|
" ccmake <path-to-source>\n"
|
|
|
|
" ccmake <path-to-existing-build>", 0},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationDescription[][3] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
|
|
|
{0,
|
2003-07-22 01:13:53 +04:00
|
|
|
"The \"ccmake\" executable is the CMake curses interface. Project "
|
|
|
|
"configuration settings may be specified interactively through "
|
|
|
|
"this GUI. Brief instructions are provided at the bottom of the "
|
|
|
|
"terminal when the program is running.", 0},
|
|
|
|
CMAKE_STANDARD_INTRODUCTION,
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-04-03 07:48:12 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationOptions[][3] =
|
2003-04-03 07:48:12 +04:00
|
|
|
{
|
|
|
|
CMAKE_STANDARD_OPTIONS_TABLE,
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-08-06 23:12:43 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationSeeAlso[][3] =
|
2003-08-06 23:12:43 +04:00
|
|
|
{
|
|
|
|
{0, "cmake", 0},
|
|
|
|
{0, "ctest", 0},
|
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
cmCursesForm* cmCursesForm::CurrentForm=0;
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-06-11 17:14:19 +04:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
|
2002-06-19 01:20:07 +04:00
|
|
|
void onsig(int)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
if (cmCursesForm::CurrentForm)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
|
|
|
endwin();
|
2011-10-13 21:51:18 +04:00
|
|
|
initscr(); /* Initialization */
|
|
|
|
noecho(); /* Echo off */
|
|
|
|
cbreak(); /* nl- or cr not needed */
|
|
|
|
keypad(stdscr,TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2001-11-05 02:05:21 +03:00
|
|
|
refresh();
|
|
|
|
int x,y;
|
2001-11-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
cmCursesForm::CurrentForm->Render(1,1,x,y);
|
|
|
|
cmCursesForm::CurrentForm->UpdateStatusBar();
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
signal(SIGWINCH, onsig);
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2002-06-11 17:14:19 +04:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-09-18 22:18:43 +04:00
|
|
|
void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2002-09-18 22:18:43 +04:00
|
|
|
cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
|
|
|
|
self->AddError(message, title);
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2007-12-14 01:56:50 +03:00
|
|
|
cmSystemTools::FindExecutableDirectory(argv[0]);
|
2003-02-14 18:53:37 +03:00
|
|
|
cmDocumentation doc;
|
2011-11-14 01:44:53 +04:00
|
|
|
doc.addCMakeStandardDocSections();
|
2003-07-08 06:44:18 +04:00
|
|
|
if(doc.CheckOptions(argc, argv))
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
cmake hcm;
|
|
|
|
std::vector<cmDocumentationEntry> commands;
|
2007-06-28 19:00:57 +04:00
|
|
|
std::vector<cmDocumentationEntry> compatCommands;
|
2006-10-05 03:21:20 +04:00
|
|
|
std::vector<cmDocumentationEntry> generators;
|
2007-06-28 19:00:57 +04:00
|
|
|
hcm.GetCommandDocumentation(commands, true, false);
|
|
|
|
hcm.GetCommandDocumentation(compatCommands, false, true);
|
2006-10-05 03:21:20 +04:00
|
|
|
hcm.GetGeneratorDocumentation(generators);
|
2003-08-06 22:49:52 +04:00
|
|
|
doc.SetName("ccmake");
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Name",cmDocumentationName);
|
|
|
|
doc.SetSection("Usage",cmDocumentationUsage);
|
|
|
|
doc.SetSection("Description",cmDocumentationDescription);
|
|
|
|
doc.SetSection("Generators",generators);
|
2011-10-12 18:24:04 +04:00
|
|
|
doc.PrependSection("Options",cmDocumentationOptions);
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Command",commands);
|
|
|
|
doc.SetSection("Compatibility Commands",compatCommands);
|
2003-08-06 23:12:43 +04:00
|
|
|
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
2003-07-08 06:44:18 +04:00
|
|
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
2011-10-13 21:51:18 +04:00
|
|
|
}
|
|
|
|
|
2001-12-04 19:16:04 +03:00
|
|
|
bool debug = false;
|
2001-11-30 00:44:22 +03:00
|
|
|
unsigned int i;
|
2001-11-30 18:58:23 +03:00
|
|
|
int j;
|
2001-11-30 00:44:22 +03:00
|
|
|
std::vector<std::string> args;
|
2001-11-30 18:58:23 +03:00
|
|
|
for(j =0; j < argc; ++j)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2001-12-04 19:16:04 +03:00
|
|
|
if(strcmp(argv[j], "-debug") == 0)
|
|
|
|
{
|
|
|
|
debug = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args.push_back(argv[j]);
|
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-05-07 19:03:56 +04:00
|
|
|
std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
|
2001-11-30 00:44:22 +03:00
|
|
|
for(i=1; i < args.size(); ++i)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
std::string arg = args[i];
|
2002-05-07 19:03:56 +04:00
|
|
|
if(arg.find("-B",0) == 0)
|
|
|
|
{
|
|
|
|
cacheDir = arg.substr(2);
|
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
cmSystemTools::DisableRunCommandOutput();
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2001-12-04 19:16:04 +03:00
|
|
|
if (debug)
|
|
|
|
{
|
|
|
|
cmCursesForm::DebugStart();
|
|
|
|
}
|
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
initscr(); /* Initialization */
|
|
|
|
noecho(); /* Echo off */
|
|
|
|
cbreak(); /* nl- or cr not needed */
|
|
|
|
keypad(stdscr,TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
signal(SIGWINCH, onsig);
|
|
|
|
|
|
|
|
int x,y;
|
2001-11-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
2011-10-13 21:51:18 +04:00
|
|
|
if ( x < cmCursesMainForm::MIN_WIDTH ||
|
2001-11-30 00:44:22 +03:00
|
|
|
y < cmCursesMainForm::MIN_HEIGHT )
|
2001-11-06 06:10:52 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
endwin();
|
|
|
|
std::cerr << "Window is too small. A size of at least "
|
2011-10-13 21:51:18 +04:00
|
|
|
<< cmCursesMainForm::MIN_WIDTH << " x "
|
2002-10-24 02:03:27 +04:00
|
|
|
<< cmCursesMainForm::MIN_HEIGHT
|
|
|
|
<< " is required to run ccmake." << std::endl;
|
2001-11-30 00:44:22 +03:00
|
|
|
return 1;
|
2001-11-06 06:10:52 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
|
|
|
|
|
|
|
cmCursesMainForm* myform;
|
|
|
|
|
2002-05-01 19:34:27 +04:00
|
|
|
myform = new cmCursesMainForm(args, x);
|
2003-01-22 18:33:34 +03:00
|
|
|
if(myform->LoadCache(cacheDir.c_str()))
|
|
|
|
{
|
|
|
|
curses_clear();
|
|
|
|
touchwin(stdscr);
|
|
|
|
endwin();
|
|
|
|
delete myform;
|
2003-01-22 19:27:53 +03:00
|
|
|
std::cerr << "Error running cmake::LoadCache(). Aborting.\n";
|
2003-01-22 18:33:34 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2002-09-18 22:18:43 +04:00
|
|
|
cmSystemTools::SetErrorCallback(CMakeErrorHandler, myform);
|
2001-11-30 00:44:22 +03:00
|
|
|
|
|
|
|
cmCursesForm::CurrentForm = myform;
|
|
|
|
|
|
|
|
myform->InitializeUI();
|
2003-05-29 19:14:48 +04:00
|
|
|
if ( myform->Configure(1) == 0 )
|
|
|
|
{
|
|
|
|
myform->Render(1, 1, x, y);
|
|
|
|
myform->HandleInput();
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
// Need to clean-up better
|
2001-11-30 19:34:13 +03:00
|
|
|
curses_clear();
|
2001-11-30 00:44:22 +03:00
|
|
|
touchwin(stdscr);
|
2001-11-05 02:05:21 +03:00
|
|
|
endwin();
|
2001-11-30 00:44:22 +03:00
|
|
|
delete cmCursesForm::CurrentForm;
|
|
|
|
cmCursesForm::CurrentForm = 0;
|
|
|
|
|
2001-12-06 19:49:16 +03:00
|
|
|
std::cout << std::endl << std::endl;
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|