diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2017-03-01 18:41:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-06 15:38:58 (GMT) |
commit | aba92ffd92bb1cc4bbe898b7abe65347b0468d33 (patch) | |
tree | 7fff657ef3fe0dd115886283b808025cfa8faa34 /Source/cmake.cxx | |
parent | 047a5e4d6656f362151b855b34c259708b8419ba (diff) | |
download | CMake-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/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b2384cd..3af3be6 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -23,6 +23,7 @@ #include "cmTargetLinkLibraryType.h" #include "cmUtils.hxx" #include "cmVersionConfig.h" +#include "cmWorkingDirectory.h" #include "cm_auto_ptr.hxx" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -2199,24 +2200,23 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) resultFile += "/__cmake_systeminformation/results.txt"; } - // now run cmake on the CMakeLists file - cmSystemTools::ChangeDirectory(destPath); - std::vector<std::string> args2; - args2.push_back(args[0]); - args2.push_back(destPath); - std::string resultArg = "-DRESULT_FILE="; - resultArg += resultFile; - args2.push_back(resultArg); - int res = this->Run(args2, false); + { + // now run cmake on the CMakeLists file + cmWorkingDirectory workdir(destPath); + std::vector<std::string> args2; + args2.push_back(args[0]); + args2.push_back(destPath); + std::string resultArg = "-DRESULT_FILE="; + resultArg += resultFile; + args2.push_back(resultArg); + int res = this->Run(args2, false); - if (res != 0) { - std::cerr << "Error: --system-information failed on internal CMake!\n"; - return res; + if (res != 0) { + std::cerr << "Error: --system-information failed on internal CMake!\n"; + return res; + } } - // change back to the original directory - cmSystemTools::ChangeDirectory(cwd); - // echo results to stdout if needed if (writeToStdout) { FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r"); |