summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2010-07-12 19:48:51 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2010-09-01 17:08:14 (GMT)
commitf794d589a44918c905911eb7688d69350922c6b3 (patch)
treec5893a8eff5b26496740c5e4b77e47ca73268c8b /Source
parent48b5b855934be341c02139c0bed88c35c1b40d8f (diff)
downloadCMake-f794d589a44918c905911eb7688d69350922c6b3.zip
CMake-f794d589a44918c905911eb7688d69350922c6b3.tar.gz
CMake-f794d589a44918c905911eb7688d69350922c6b3.tar.bz2
Make --strict-mode option, and integrate with cmake-gui
Diffstat (limited to 'Source')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx9
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h1
-rw-r--r--Source/QtDialog/QCMake.cxx8
-rw-r--r--Source/QtDialog/QCMake.h3
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx13
-rw-r--r--Source/cmCommandArgumentParserHelper.h1
-rw-r--r--Source/cmake.cxx6
-rw-r--r--Source/cmake.h3
-rw-r--r--Source/cmakemain.cxx3
9 files changed, 43 insertions, 4 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 74a3d35..7600897 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -114,8 +114,12 @@ CMakeSetupDialog::CMakeSetupDialog()
this, SLOT(doInstallForCommandLine()));
#endif
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
- this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
+ this->SuppressDevWarningsAction =
+ OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
this->SuppressDevWarningsAction->setCheckable(true);
+ this->StrictModeAction =
+ OptionsMenu->addAction(tr("&Strict Mode (--strict-mode)"));
+ this->StrictModeAction->setCheckable(true);
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
debugAction->setCheckable(true);
@@ -240,6 +244,9 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)),
this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool)));
+ QObject::connect(this->StrictModeAction, SIGNAL(triggered(bool)),
+ this->CMakeThread->cmakeInstance(),
+ SLOT(setStrictMode(bool)));
if(!this->SourceDirectory->text().isEmpty() ||
!this->BinaryDirectory->lineEdit()->text().isEmpty())
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 0e3caec..cd2be6e 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -93,6 +93,7 @@ protected:
QAction* ConfigureAction;
QAction* GenerateAction;
QAction* SuppressDevWarningsAction;
+ QAction* StrictModeAction;
QAction* InstallForCommandLineAction;
State CurrentState;
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index dc31fad..31daf3c 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -28,6 +28,7 @@ QCMake::QCMake(QObject* p)
: QObject(p)
{
this->SuppressDevWarnings = false;
+ this->StrictMode = false;
qRegisterMetaType<QCMakeProperty>();
qRegisterMetaType<QCMakePropertyList>();
@@ -164,6 +165,8 @@ void QCMake::configure()
this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data()));
this->CMakeInstance->LoadCache();
this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
+ std::cerr << "set strict " << this->StrictMode << "\n";
+ this->CMakeInstance->SetStrictMode(this->StrictMode);
this->CMakeInstance->PreLoadCMakeFiles();
cmSystemTools::ResetErrorOccuredFlag();
@@ -417,3 +420,8 @@ void QCMake::setSuppressDevWarnings(bool value)
{
this->SuppressDevWarnings = value;
}
+
+void QCMake::setStrictMode(bool value)
+{
+ this->StrictMode = value;
+}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index bbfb3d7..f20893f 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -88,6 +88,8 @@ public slots:
void setDebugOutput(bool);
/// set whether to do suppress dev warnings
void setSuppressDevWarnings(bool value);
+ /// set whether to run cmake in strict mode
+ void setStrictMode(bool value);
public:
/// get the list of cache properties
@@ -133,6 +135,7 @@ protected:
static void errorCallback(const char* msg, const char* title,
bool&, void* cd);
bool SuppressDevWarnings;
+ bool StrictMode;
QString SourceDirectory;
QString BinaryDirectory;
QString Generator;
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 027a2ba..410058f 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -20,6 +20,7 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
//
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
+ this->StrictMode = false;
this->FileLine = -1;
this->FileName = 0;
this->RemoveEmpty = true;
@@ -123,10 +124,15 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
const char* value = this->Makefile->GetDefinition(var);
if(!value && !this->RemoveEmpty)
{
- if(!this->Makefile->VariableCleared(var))
+ // check to see if we need to print a warning
+ // if strict mode is on and the variable has
+ // not been "cleared"/initialized with a set(foo ) call
+ if(this->StrictMode && !this->Makefile->VariableCleared(var))
{
- std::cerr << this->FileName << ":" << this->FileLine << ":" <<
- " warning: uninitialized variable \'" << var << "\'\n";
+ cmOStringStream msg;
+ msg << this->FileName << ":" << this->FileLine << ":" <<
+ " warning: uninitialized variable \'" << var << "\'";
+ cmSystemTools::Message(msg.str().c_str());
}
return 0;
}
@@ -324,6 +330,7 @@ void cmCommandArgumentParserHelper::Error(const char* str)
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
{
this->Makefile = mf;
+ this->StrictMode = mf->GetCMakeInstance()->GetStrictMode();
}
void cmCommandArgumentParserHelper::SetResult(const char* value)
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 62cbc80..d7206ee 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -96,6 +96,7 @@ private:
const cmMakefile* Makefile;
std::string Result;
const char* FileName;
+ bool StrictMode;
long FileLine;
bool EscapeQuotes;
std::string ErrorString;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 0f9ef1b..2e77748 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -140,6 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
cmake::cmake()
{
this->Trace = false;
+ this->StrictMode = false;
this->SuppressDevWarnings = false;
this->DoSuppressDevWarnings = false;
this->DebugOutput = false;
@@ -613,6 +614,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << "Running with trace output on.\n";
this->SetTrace(true);
}
+ else if(arg.find("--strict-mode",0) == 0)
+ {
+ std::cout << "Running in strict mode.\n";
+ this->SetStrictMode(true);
+ }
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);
diff --git a/Source/cmake.h b/Source/cmake.h
index 8312795..5c2f17a 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -306,6 +306,8 @@ class cmake
// Do we want trace output during the cmake run.
bool GetTrace() { return this->Trace;}
void SetTrace(bool b) { this->Trace = b;}
+ bool GetStrictMode() { return this->StrictMode;}
+ void SetStrictMode(bool b) { this->StrictMode = b;}
// Define a property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
const char *ShortDescription,
@@ -443,6 +445,7 @@ private:
bool ScriptMode;
bool DebugOutput;
bool Trace;
+ bool StrictMode;
std::string CMakeEditCommand;
std::string CMakeCommand;
std::string CXXEnvironment;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index ddff71d..ac2a338 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -120,6 +120,9 @@ static const char * cmDocumentationOptions[][3] =
{"--trace", "Put cmake in trace mode.",
"Print a trace of all calls made and from where with "
"message(send_error ) calls."},
+ {"--strict-mode", "Put cmake in strict mode.",
+ "In strict mode cmake will print a warning when an uninitialized variable "
+ "is used."},
{"--help-command cmd [file]", "Print help for a single command and exit.",
"Full documentation specific to the given command is displayed. "
"If a file is specified, the documentation is written into and the output "