summaryrefslogtreecommitdiffstats
path: root/Source/cmDepends.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2017-03-01 18:41:50 (GMT)
committerBrad King <brad.king@kitware.com>2017-03-06 15:38:58 (GMT)
commitaba92ffd92bb1cc4bbe898b7abe65347b0468d33 (patch)
tree7fff657ef3fe0dd115886283b808025cfa8faa34 /Source/cmDepends.cxx
parent047a5e4d6656f362151b855b34c259708b8419ba (diff)
downloadCMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.zip
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.gz
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.bz2
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 c189419..b8c76b9 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;
}