diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2cb2de3c1..d6ec70fce 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -378,19 +378,10 @@ bool cmSystemTools::RunCommand(const char* command, return false; } - // Change to specified working directory. - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - if(dir) - { - if(cmSystemTools::ChangeDirectory(dir) < 0) - { - return false; - } - } - output = ""; cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); + cmsysProcess_SetWorkingDirectory(cp, dir); cmsysProcess_Execute(cp); char* data; @@ -420,12 +411,6 @@ bool cmSystemTools::RunCommand(const char* command, cmsysProcess_Delete(cp); - // Restore old working directory. - if(dir) - { - cmSystemTools::ChangeDirectory(cwd.c_str()); - } - return result; }