diff options
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6141f50..737587d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -23,10 +23,12 @@ #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> +#include "cm_jsoncpp_writer.h" #include "cmGraphVizWriter.h" #include "cmVariableWatch.h" @@ -61,7 +63,6 @@ #include "cmGlobalVisualStudio12Generator.h" #include "cmGlobalVisualStudio14Generator.h" #include "cmGlobalVisualStudio15Generator.h" -#include "cmGlobalVisualStudio71Generator.h" #include "cmGlobalVisualStudio8Generator.h" #include "cmGlobalVisualStudio9Generator.h" #include "cmVSSetupHelper.h" @@ -105,14 +106,10 @@ #include <sys/time.h> #endif -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> // struct stat - +#include "cmsys/FStream.hxx" +#include "cmsys/Glob.hxx" +#include "cmsys/RegularExpression.hxx" #include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> #include <iostream> #include <sstream> #include <stdio.h> @@ -120,8 +117,6 @@ #include <string.h> #include <utility> -class cmCommand; - namespace { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -179,7 +174,8 @@ cmake::cmake() this->AddDefaultGenerators(); this->AddDefaultExtraGenerators(); - this->AddDefaultCommands(); + this->AddScriptingCommands(); + this->AddProjectCommands(); // Make sure we can capture the build tool output. cmSystemTools::EnableVSConsoleOutput(); @@ -1464,8 +1460,7 @@ void cmake::CreateDefaultGlobalGenerator() { "11.0", "Visual Studio 11 2012" }, // { "10.0", "Visual Studio 10 2010" }, // { "9.0", "Visual Studio 9 2008" }, // - { "8.0", "Visual Studio 8 2005" }, // - { "7.1", "Visual Studio 7 .NET 2003" } + { "8.0", "Visual Studio 8 2005" } }; static const char* const vsEntries[] = { "\\Setup\\VC;ProductDir", // @@ -1654,13 +1649,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() @@ -1674,7 +1670,6 @@ void cmake::AddDefaultGenerators() this->Generators.push_back(cmGlobalVisualStudio10Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio9Generator::NewFactory()); this->Generators.push_back(cmGlobalVisualStudio8Generator::NewFactory()); - this->Generators.push_back(cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory()); @@ -2199,24 +2194,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"); |