From 1052a6700f46588258682a266aa84e28aa36625f Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 15 May 2002 17:23:09 -0400 Subject: [PATCH] added initial attempt to support win32 bootstrapping --- Source/cmake.cxx | 65 +++++++++++++++++++++++++++++++++++++++++++++++- Source/cmake.h | 8 ++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c9a438c99..b5b6883b8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -327,6 +327,13 @@ void cmake::AddCMakePaths(const std::vector& args) cMakeRoot += "/share/CMake"; modules = cMakeRoot + "/Modules/FindVTK.cmake"; } + if(!cmSystemTools::FileExists(modules.c_str())) + { + // next try exe + cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); + // is there no Modules direcory there? + modules = cMakeRoot + "/Modules/FindVTK.cmake"; + } if (!cmSystemTools::FileExists(modules.c_str())) { // couldn't find modules @@ -339,7 +346,58 @@ void cmake::AddCMakePaths(const std::vector& args) ("CMAKE_ROOT", cMakeRoot.c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); } - + + +void cmake::HandleBootstrap(cmMakefile& mf, const std::string& args0) +{ + if (cmSystemTools::GetFilenameNameWithoutExtension(args0) == + "bootstrap") + { + int done = 0; + + while (!done) + { + int choice = 0; + std::cout << + "\n\nPlease select the tool you wish to use to build CMake." + "\nPlease note that selecting a tool here will not limit" + "\nwhat tools the resulting CMake executable supports.\n\n"; + std::vector names; + cmMakefileGenerator::GetRegisteredGenerators(names); + int count = 1; + for(std::vector::iterator i =names.begin(); + i != names.end(); ++i, ++count) + { + std::cout << "\t" << count << ") " << i->c_str() << "\n"; + } + std::cin >> choice; + if (choice > 0 && choice < count) + { + done = 1; + cmMakefileGenerator* gen = + cmMakefileGenerator::CreateGenerator(names[choice-1].c_str()); + if(!gen) + { + cmSystemTools::Error("Could not create named generator ", + names[choice-1].c_str()); + } + else + { + mf.SetMakefileGenerator(gen); + mf.AddDefinition("CMAKE_BOOTSTRAP","1"); + std::cout << + "\n\nThank You. CMake will now generate the appropriate files for\nbeing built with " << names[choice-1].c_str() << "\n\n"; + } + } + else + { + std::cout << "Please make a selection between 1 and " << + count -1 << "\n"; + } + } + } +} + int cmake::Generate(const std::vector& args, bool buildMakefiles) { if(args.size() == 1 && !cmSystemTools::FileExists("CMakeLists.txt")) @@ -390,6 +448,11 @@ int cmake::Generate(const std::vector& args, bool buildMakefiles) // extract command line arguments that might add cache entries this->SetCacheArgs(mf, args); + + // handle bootstraping command + this->HandleBootstrap(mf,args[0]); + + // no generator specified on the command line if(!mf.GetMakefileGenerator()) { diff --git a/Source/cmake.h b/Source/cmake.h index 53203e338..32efd8671 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -51,6 +51,14 @@ class cmake */ void AddCMakePaths(const std::vector&); + /** + * Handle the case where cmake is being used to bootstrap itself. + * This typically happens on windows, where a cmake executable is + * used to produce makefiles for cmake itself. When bootstrapping + * CMAKE_BOOTSTRAP is set to 1 + */ + void HandleBootstrap(cmMakefile& builder, const std::string& arg0); + /** * constructor */