|
|
@@ -140,6 +140,7 @@ cmake::cmake(Role role, cmState::Mode mode)
|
|
|
, State(cm::make_unique<cmState>())
|
|
|
, Messenger(cm::make_unique<cmMessenger>())
|
|
|
{
|
|
|
+ this->TraceFile.close();
|
|
|
this->State->SetMode(mode);
|
|
|
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
|
|
|
|
|
|
@@ -740,6 +741,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
|
|
cmSystemTools::ConvertToUnixSlashes(file);
|
|
|
this->AddTraceSource(file);
|
|
|
this->SetTrace(true);
|
|
|
+ } else if (arg.find("--trace-redirect=", 0) == 0) {
|
|
|
+ std::string file = arg.substr(strlen("--trace-redirect="));
|
|
|
+ cmSystemTools::ConvertToUnixSlashes(file);
|
|
|
+ this->SetTraceFile(file);
|
|
|
+ this->SetTrace(true);
|
|
|
} else if (arg.find("--trace", 0) == 0) {
|
|
|
std::cout << "Running with trace output on.\n";
|
|
|
this->SetTrace(true);
|
|
|
@@ -870,6 +876,20 @@ cmake::LogLevel cmake::StringToLogLevel(const std::string& levelStr)
|
|
|
return (it != levels.cend()) ? it->second : LogLevel::LOG_UNDEFINED;
|
|
|
}
|
|
|
|
|
|
+void cmake::SetTraceFile(const std::string& file)
|
|
|
+{
|
|
|
+ this->TraceFile.close();
|
|
|
+ this->TraceFile.open(file.c_str());
|
|
|
+ if (!this->TraceFile) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << "Error opening trace file " << file << ": "
|
|
|
+ << cmSystemTools::GetLastSystemError();
|
|
|
+ cmSystemTools::Error(ss.str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ std::cout << "Trace will be written to " << file << "\n";
|
|
|
+}
|
|
|
+
|
|
|
void cmake::SetDirectoriesFromFile(const std::string& arg)
|
|
|
{
|
|
|
// Check if the argument refers to a CMakeCache.txt or
|