diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fca2f7e32..7e035e188 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -395,6 +395,21 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) { + // if trace is one, print out invoke information + if(this->GetCMakeInstance()->GetTrace()) + { + cmOStringStream msg; + msg << lff.FilePath << "(" << lff.Line << "): "; + msg << lff.Name << "("; + for(std::vector::const_iterator i = + lff.Arguments.begin(); i != lff.Arguments.end(); ++i) + { + msg << i->Value; + msg << " "; + } + msg << ")"; + cmSystemTools::Message(msg.str().c_str()); + } // Try invoking the command. if(!pcmd->InvokeInitialPass(lff.Arguments,status) || status.GetNestedError()) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index df95155da..3a0a463d3 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->SuppressDevWarnings = false; this->DoSuppressDevWarnings = false; this->DebugOutput = false; @@ -618,6 +619,11 @@ void cmake::SetArgs(const std::vector& args) std::cout << "Running with debug output on.\n"; this->SetDebugOutputOn(true); } + else if(arg.find("--trace",0) == 0) + { + std::cout << "Running with trace output on.\n"; + this->SetTrace(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 1c4351a97..8d030c73a 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -314,6 +314,9 @@ class cmake bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b;} + // Do we want trace output during the cmake run. + bool GetTrace() { return this->Trace;} + void SetTrace(bool b) { this->Trace = b;} // Define a property void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, @@ -438,6 +441,7 @@ private: bool InTryCompile; bool ScriptMode; bool DebugOutput; + bool Trace; std::string CMakeEditCommand; std::string CMakeCommand; std::string CXXEnvironment; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 83718ddbe..601c060a9 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -101,6 +101,9 @@ static const char * cmDocumentationOptions[][3] = {"--debug-output", "Put cmake in a debug mode.", "Print extra stuff during the cmake run like stack traces with " "message(send_error ) calls."}, + {"--trace", "Put cmake in trace mode.", + "Print a trace of all calls made and from where with " + "message(send_error ) calls."}, {"--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 "