summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx53
1 files changed, 25 insertions, 28 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 6141f50..4363c12 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -23,7 +23,9 @@
#include "cmTargetLinkLibraryType.h"
#include "cmUtils.hxx"
#include "cmVersionConfig.h"
+#include "cmWorkingDirectory.h"
#include "cm_auto_ptr.hxx"
+#include "cm_sys_stat.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include <cm_jsoncpp_writer.h>
@@ -105,10 +107,6 @@
#include <sys/time.h>
#endif
-#include <sys/types.h>
-// include sys/stat.h after sys/types.h
-#include <sys/stat.h> // struct stat
-
#include <algorithm>
#include <cmsys/FStream.hxx>
#include <cmsys/Glob.hxx>
@@ -120,8 +118,6 @@
#include <string.h>
#include <utility>
-class cmCommand;
-
namespace {
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -179,7 +175,8 @@ cmake::cmake()
this->AddDefaultGenerators();
this->AddDefaultExtraGenerators();
- this->AddDefaultCommands();
+ this->AddScriptingCommands();
+ this->AddProjectCommands();
// Make sure we can capture the build tool output.
cmSystemTools::EnableVSConsoleOutput();
@@ -1654,13 +1651,14 @@ const char* cmake::GetCacheDefinition(const std::string& name) const
return this->State->GetInitializedCacheValue(name);
}
-void cmake::AddDefaultCommands()
+void cmake::AddScriptingCommands()
{
- std::vector<cmCommand*> const commands = GetPredefinedCommands();
- for (std::vector<cmCommand*>::const_iterator i = commands.begin();
- i != commands.end(); ++i) {
- this->State->AddCommand(*i);
- }
+ GetScriptingCommands(this->State);
+}
+
+void cmake::AddProjectCommands()
+{
+ GetProjectCommands(this->State);
}
void cmake::AddDefaultGenerators()
@@ -2199,24 +2197,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");