Make --strict-mode option, and integrate with cmake-gui
This commit is contained in:
parent
48b5b85593
commit
f794d589a4
|
@ -24,9 +24,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
||||||
|
|
||||||
# Compile the ABI identification source.
|
# Compile the ABI identification source.
|
||||||
SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin")
|
SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin")
|
||||||
|
SET(CMAKE_FLAGS )
|
||||||
|
IF(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
|
||||||
|
SET(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
|
||||||
|
ENDIF()
|
||||||
TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
|
TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
|
||||||
${CMAKE_BINARY_DIR} ${src}
|
${CMAKE_BINARY_DIR} ${src}
|
||||||
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}"
|
CMAKE_FLAGS "${CMAKE_FLAGS}"
|
||||||
"-DCMAKE_${lang}_STANDARD_LIBRARIES="
|
"-DCMAKE_${lang}_STANDARD_LIBRARIES="
|
||||||
OUTPUT_VARIABLE OUTPUT
|
OUTPUT_VARIABLE OUTPUT
|
||||||
COPY_FILE "${BIN}"
|
COPY_FILE "${BIN}"
|
||||||
|
@ -58,10 +62,16 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
||||||
# Parse implicit linker information for this language, if available.
|
# Parse implicit linker information for this language, if available.
|
||||||
SET(implicit_dirs "")
|
SET(implicit_dirs "")
|
||||||
SET(implicit_libs "")
|
SET(implicit_libs "")
|
||||||
|
SET(MULTI_ARCH FALSE)
|
||||||
|
IF(DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||||
|
IF( "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" )
|
||||||
|
SET(MULTI_ARCH TRUE)
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
IF(CMAKE_${lang}_VERBOSE_FLAG
|
IF(CMAKE_${lang}_VERBOSE_FLAG
|
||||||
# Implicit link information cannot be used explicitly for
|
# Implicit link information cannot be used explicitly for
|
||||||
# multiple OS X architectures, so we skip it.
|
# multiple OS X architectures, so we skip it.
|
||||||
AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";"
|
AND NOT MULTI_ARCH
|
||||||
# Skip this with Xcode for now.
|
# Skip this with Xcode for now.
|
||||||
AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
|
AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
|
||||||
CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log)
|
CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log)
|
||||||
|
|
|
@ -243,7 +243,9 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
|
||||||
# ENDIF("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface")
|
# ENDIF("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface")
|
||||||
|
|
||||||
ENDIF(NOT CMAKE_EXECUTABLE_FORMAT)
|
ENDIF(NOT CMAKE_EXECUTABLE_FORMAT)
|
||||||
|
IF(NOT DEFINED CMAKE_EXECUTABLE_FORMAT)
|
||||||
|
SET(CMAKE_EXECUTABLE_FORMAT)
|
||||||
|
ENDIF()
|
||||||
# Return the information extracted.
|
# Return the information extracted.
|
||||||
SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
||||||
SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
|
SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
|
||||||
|
|
|
@ -114,8 +114,12 @@ CMakeSetupDialog::CMakeSetupDialog()
|
||||||
this, SLOT(doInstallForCommandLine()));
|
this, SLOT(doInstallForCommandLine()));
|
||||||
#endif
|
#endif
|
||||||
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
|
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->SuppressDevWarningsAction->setCheckable(true);
|
||||||
|
this->StrictModeAction =
|
||||||
|
OptionsMenu->addAction(tr("&Strict Mode (--strict-mode)"));
|
||||||
|
this->StrictModeAction->setCheckable(true);
|
||||||
|
|
||||||
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
|
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
|
||||||
debugAction->setCheckable(true);
|
debugAction->setCheckable(true);
|
||||||
|
@ -240,6 +244,9 @@ void CMakeSetupDialog::initialize()
|
||||||
|
|
||||||
QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)),
|
QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)),
|
||||||
this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(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() ||
|
if(!this->SourceDirectory->text().isEmpty() ||
|
||||||
!this->BinaryDirectory->lineEdit()->text().isEmpty())
|
!this->BinaryDirectory->lineEdit()->text().isEmpty())
|
||||||
|
|
|
@ -93,6 +93,7 @@ protected:
|
||||||
QAction* ConfigureAction;
|
QAction* ConfigureAction;
|
||||||
QAction* GenerateAction;
|
QAction* GenerateAction;
|
||||||
QAction* SuppressDevWarningsAction;
|
QAction* SuppressDevWarningsAction;
|
||||||
|
QAction* StrictModeAction;
|
||||||
QAction* InstallForCommandLineAction;
|
QAction* InstallForCommandLineAction;
|
||||||
State CurrentState;
|
State CurrentState;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ QCMake::QCMake(QObject* p)
|
||||||
: QObject(p)
|
: QObject(p)
|
||||||
{
|
{
|
||||||
this->SuppressDevWarnings = false;
|
this->SuppressDevWarnings = false;
|
||||||
|
this->StrictMode = false;
|
||||||
qRegisterMetaType<QCMakeProperty>();
|
qRegisterMetaType<QCMakeProperty>();
|
||||||
qRegisterMetaType<QCMakePropertyList>();
|
qRegisterMetaType<QCMakePropertyList>();
|
||||||
|
|
||||||
|
@ -164,6 +165,8 @@ void QCMake::configure()
|
||||||
this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data()));
|
this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data()));
|
||||||
this->CMakeInstance->LoadCache();
|
this->CMakeInstance->LoadCache();
|
||||||
this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
|
this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
|
||||||
|
std::cerr << "set strict " << this->StrictMode << "\n";
|
||||||
|
this->CMakeInstance->SetStrictMode(this->StrictMode);
|
||||||
this->CMakeInstance->PreLoadCMakeFiles();
|
this->CMakeInstance->PreLoadCMakeFiles();
|
||||||
|
|
||||||
cmSystemTools::ResetErrorOccuredFlag();
|
cmSystemTools::ResetErrorOccuredFlag();
|
||||||
|
@ -417,3 +420,8 @@ void QCMake::setSuppressDevWarnings(bool value)
|
||||||
{
|
{
|
||||||
this->SuppressDevWarnings = value;
|
this->SuppressDevWarnings = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QCMake::setStrictMode(bool value)
|
||||||
|
{
|
||||||
|
this->StrictMode = value;
|
||||||
|
}
|
||||||
|
|
|
@ -88,6 +88,8 @@ public slots:
|
||||||
void setDebugOutput(bool);
|
void setDebugOutput(bool);
|
||||||
/// set whether to do suppress dev warnings
|
/// set whether to do suppress dev warnings
|
||||||
void setSuppressDevWarnings(bool value);
|
void setSuppressDevWarnings(bool value);
|
||||||
|
/// set whether to run cmake in strict mode
|
||||||
|
void setStrictMode(bool value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// get the list of cache properties
|
/// get the list of cache properties
|
||||||
|
@ -133,6 +135,7 @@ protected:
|
||||||
static void errorCallback(const char* msg, const char* title,
|
static void errorCallback(const char* msg, const char* title,
|
||||||
bool&, void* cd);
|
bool&, void* cd);
|
||||||
bool SuppressDevWarnings;
|
bool SuppressDevWarnings;
|
||||||
|
bool StrictMode;
|
||||||
QString SourceDirectory;
|
QString SourceDirectory;
|
||||||
QString BinaryDirectory;
|
QString BinaryDirectory;
|
||||||
QString Generator;
|
QString Generator;
|
||||||
|
|
|
@ -20,6 +20,7 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
|
||||||
//
|
//
|
||||||
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
|
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
|
||||||
{
|
{
|
||||||
|
this->StrictMode = false;
|
||||||
this->FileLine = -1;
|
this->FileLine = -1;
|
||||||
this->FileName = 0;
|
this->FileName = 0;
|
||||||
this->RemoveEmpty = true;
|
this->RemoveEmpty = true;
|
||||||
|
@ -123,10 +124,15 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
||||||
const char* value = this->Makefile->GetDefinition(var);
|
const char* value = this->Makefile->GetDefinition(var);
|
||||||
if(!value && !this->RemoveEmpty)
|
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 << ":" <<
|
cmOStringStream msg;
|
||||||
" warning: uninitialized variable \'" << var << "\'\n";
|
msg << this->FileName << ":" << this->FileLine << ":" <<
|
||||||
|
" warning: uninitialized variable \'" << var << "\'";
|
||||||
|
cmSystemTools::Message(msg.str().c_str());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -324,6 +330,7 @@ void cmCommandArgumentParserHelper::Error(const char* str)
|
||||||
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
|
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
|
||||||
{
|
{
|
||||||
this->Makefile = mf;
|
this->Makefile = mf;
|
||||||
|
this->StrictMode = mf->GetCMakeInstance()->GetStrictMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCommandArgumentParserHelper::SetResult(const char* value)
|
void cmCommandArgumentParserHelper::SetResult(const char* value)
|
||||||
|
|
|
@ -96,6 +96,7 @@ private:
|
||||||
const cmMakefile* Makefile;
|
const cmMakefile* Makefile;
|
||||||
std::string Result;
|
std::string Result;
|
||||||
const char* FileName;
|
const char* FileName;
|
||||||
|
bool StrictMode;
|
||||||
long FileLine;
|
long FileLine;
|
||||||
bool EscapeQuotes;
|
bool EscapeQuotes;
|
||||||
std::string ErrorString;
|
std::string ErrorString;
|
||||||
|
|
|
@ -140,6 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
|
||||||
cmake::cmake()
|
cmake::cmake()
|
||||||
{
|
{
|
||||||
this->Trace = false;
|
this->Trace = false;
|
||||||
|
this->StrictMode = false;
|
||||||
this->SuppressDevWarnings = false;
|
this->SuppressDevWarnings = false;
|
||||||
this->DoSuppressDevWarnings = false;
|
this->DoSuppressDevWarnings = false;
|
||||||
this->DebugOutput = 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";
|
std::cout << "Running with trace output on.\n";
|
||||||
this->SetTrace(true);
|
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)
|
else if(arg.find("-G",0) == 0)
|
||||||
{
|
{
|
||||||
std::string value = arg.substr(2);
|
std::string value = arg.substr(2);
|
||||||
|
|
|
@ -306,6 +306,8 @@ class cmake
|
||||||
// Do we want trace output during the cmake run.
|
// Do we want trace output during the cmake run.
|
||||||
bool GetTrace() { return this->Trace;}
|
bool GetTrace() { return this->Trace;}
|
||||||
void SetTrace(bool b) { this->Trace = b;}
|
void SetTrace(bool b) { this->Trace = b;}
|
||||||
|
bool GetStrictMode() { return this->StrictMode;}
|
||||||
|
void SetStrictMode(bool b) { this->StrictMode = b;}
|
||||||
// Define a property
|
// Define a property
|
||||||
void DefineProperty(const char *name, cmProperty::ScopeType scope,
|
void DefineProperty(const char *name, cmProperty::ScopeType scope,
|
||||||
const char *ShortDescription,
|
const char *ShortDescription,
|
||||||
|
@ -443,6 +445,7 @@ private:
|
||||||
bool ScriptMode;
|
bool ScriptMode;
|
||||||
bool DebugOutput;
|
bool DebugOutput;
|
||||||
bool Trace;
|
bool Trace;
|
||||||
|
bool StrictMode;
|
||||||
std::string CMakeEditCommand;
|
std::string CMakeEditCommand;
|
||||||
std::string CMakeCommand;
|
std::string CMakeCommand;
|
||||||
std::string CXXEnvironment;
|
std::string CXXEnvironment;
|
||||||
|
|
|
@ -120,6 +120,9 @@ static const char * cmDocumentationOptions[][3] =
|
||||||
{"--trace", "Put cmake in trace mode.",
|
{"--trace", "Put cmake in trace mode.",
|
||||||
"Print a trace of all calls made and from where with "
|
"Print a trace of all calls made and from where with "
|
||||||
"message(send_error ) calls."},
|
"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.",
|
{"--help-command cmd [file]", "Print help for a single command and exit.",
|
||||||
"Full documentation specific to the given command is displayed. "
|
"Full documentation specific to the given command is displayed. "
|
||||||
"If a file is specified, the documentation is written into and the output "
|
"If a file is specified, the documentation is written into and the output "
|
||||||
|
|
Loading…
Reference in New Issue