summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.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/cmMakefile.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/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx11
1 files changed, 2 insertions, 9 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c75d101..204fd8f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -36,6 +36,7 @@
#include "cmTest.h"
#include "cmTestGenerator.h" // IWYU pragma: keep
#include "cmVersion.h"
+#include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
#include "cmake.h"
@@ -3147,8 +3148,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir);
+ cmWorkingDirectory workdir(bindir);
// make sure the same generator is used
// use this program as the cmake to be run, it should not
@@ -3162,8 +3162,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->GetGlobalGenerator()->GetName() +
"' could not be created.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3227,8 +3225,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->IssueMessage(cmake::FATAL_ERROR,
"Failed to configure test project build system.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3237,8 +3233,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this->IssueMessage(cmake::FATAL_ERROR,
"Failed to generate test project build system.");
cmSystemTools::SetFatalErrorOccured();
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3247,7 +3241,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
int ret = this->GetGlobalGenerator()->TryCompile(
srcdir, bindir, projectName, targetName, fast, output, this);
- cmSystemTools::ChangeDirectory(cwd);
this->IsSourceFileTryCompile = false;
return ret;
}