summaryrefslogtreecommitdiff
path: root/Source/cmDepends.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2017-03-01 13:41:50 -0500
committerBrad King <brad.king@kitware.com>2017-03-06 10:38:58 -0500
commitaba92ffd92bb1cc4bbe898b7abe65347b0468d33 (patch)
tree7fff657ef3fe0dd115886283b808025cfa8faa34 /Source/cmDepends.cxx
parent047a5e4d6656f362151b855b34c259708b8419ba (diff)
downloadcmake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.gz
cmWorkingDirectory: use the new class
These functions just need to change the directory for a block of code and then go back to the caller's expected location. Use cmWorkingDirectory to ensure that all return paths are handled.
Diffstat (limited to 'Source/cmDepends.cxx')
-rw-r--r--Source/cmDepends.cxx14
1 files changed, 2 insertions, 12 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index c189419de8..b8c76b92dd 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -7,6 +7,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <cmsys/FStream.hxx>
#include <sstream>
@@ -75,13 +76,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
std::map<std::string, DependencyVector>& validDeps)
{
// Dependency checks must be done in proper working directory.
- std::string oldcwd = ".";
- if (this->CompileDirectory != ".") {
- // Get the CWD but do not call CollapseFullPath because
- // we only need it to cd back, and the form does not matter
- oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false);
- cmSystemTools::ChangeDirectory(this->CompileDirectory);
- }
+ cmWorkingDirectory workdir(this->CompileDirectory);
// Check whether dependencies must be regenerated.
bool okay = true;
@@ -93,11 +88,6 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
okay = false;
}
- // Restore working directory.
- if (oldcwd != ".") {
- cmSystemTools::ChangeDirectory(oldcwd);
- }
-
return okay;
}