Only set the property if the property was given

This commit is contained in:
Ben Boeckel 2011-01-20 14:05:39 -05:00
parent b6c302b1aa
commit d94f9c6487
1 changed files with 6 additions and 5 deletions

View File

@ -74,8 +74,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
{ {
std::string name; std::string name;
std::vector<std::string> configurations; std::vector<std::string> configurations;
std::string working_directory = this->Makefile->GetCurrentOutputDirectory(); std::string working_directory;
bool working_directory_set = false;
std::vector<std::string> command; std::vector<std::string> command;
// Read the arguments. // Read the arguments.
@ -109,13 +108,12 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
} }
else if(args[i] == "WORKING_DIRECTORY") else if(args[i] == "WORKING_DIRECTORY")
{ {
if(working_directory_set) if(!working_directory.empty())
{ {
this->SetError(" may be given at most one WORKING_DIRECTORY."); this->SetError(" may be given at most one WORKING_DIRECTORY.");
return false; return false;
} }
doing = DoingWorkingDirectory; doing = DoingWorkingDirectory;
working_directory_set = true;
} }
else if(doing == DoingName) else if(doing == DoingName)
{ {
@ -172,7 +170,10 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
cmTest* test = this->Makefile->CreateTest(name.c_str()); cmTest* test = this->Makefile->CreateTest(name.c_str());
test->SetOldStyle(false); test->SetOldStyle(false);
test->SetCommand(command); test->SetCommand(command);
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); if(!working_directory.empty())
{
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
}
this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations)); this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
return true; return true;