diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-09-06 21:28:24 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-09-06 21:28:24 (GMT) |
commit | d204791e45b245fd0a10b2b31ab6ace9a8c3cf65 (patch) | |
tree | 183547168a76c000f332f7bad6b77a43f309a09d /Source/cmake.cxx | |
parent | ecd4acfb01035d227f68c29ce0f65b2193bbd410 (diff) | |
download | CMake-d204791e45b245fd0a10b2b31ab6ace9a8c3cf65.zip CMake-d204791e45b245fd0a10b2b31ab6ace9a8c3cf65.tar.gz CMake-d204791e45b245fd0a10b2b31ab6ace9a8c3cf65.tar.bz2 |
ENH: integrate borland support
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 127 |
1 files changed, 107 insertions, 20 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c1c3128..18235ee 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -44,26 +44,48 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // include the generator #if defined(_WIN32) && !defined(__CYGWIN__) #include "cmMSProjectGenerator.h" +#include "cmBorlandMakefileGenerator.h" #else #include "cmUnixMakefileGenerator.h" #endif +cmake::cmake() +{ + m_Verbose = false; +#if defined(_WIN32) && !defined(__CYGWIN__) + cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator); + cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator); +#else + cmMakefileGenerator::RegisterGenerator(new cmUnixMakefileGenerator); +#endif +} + void cmake::Usage(const char* program) { std::cerr << "cmake version " << cmMakefile::GetMajorVersion() << "." << cmMakefile::GetMinorVersion() << "\n"; std::cerr << "Usage: " << program << " srcdir \n" << "Where cmake is run from the directory where you want the object files written\n"; + std::cerr << "[-GgeneratorName] (where generator name can be: "; + std::vector<std::string> names; + cmMakefileGenerator::GetRegisteredGenerators(names); + for(std::vector<std::string>::iterator i =names.begin(); + i != names.end(); ++i) + { + std::cerr << i->c_str() << " "; + } + std::cerr << ")\n"; } // Parse the args void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args) { m_Local = false; - + bool directoriesSet = false; // watch for cmake and cmake srcdir invocations if (args.size() <= 2) { + directoriesSet = true; builder.SetHomeOutputDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); builder.SetStartOutputDirectory @@ -89,36 +111,78 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args) std::string arg = args[i]; if(arg.find("-H",0) == 0) { + directoriesSet = true; std::string path = arg.substr(2); builder.SetHomeDirectory(path.c_str()); } - if(arg.find("-S",0) == 0) + else if(arg.find("-S",0) == 0) { + directoriesSet = true; m_Local = true; std::string path = arg.substr(2); builder.SetStartDirectory(path.c_str()); } - if(arg.find("-O",0) == 0) + else if(arg.find("-O",0) == 0) { + directoriesSet = true; std::string path = arg.substr(2); builder.SetStartOutputDirectory(path.c_str()); } - if(arg.find("-B",0) == 0) + else if(arg.find("-B",0) == 0) { + directoriesSet = true; std::string path = arg.substr(2); builder.SetHomeOutputDirectory(path.c_str()); } - if(arg.find("-D",0) == 0) + else if(arg.find("-D",0) == 0) { std::string value = arg.substr(2); builder.AddDefinition(value.c_str(), true); } - if(arg.find("-V",0) == 0) + else if(arg.find("-V",0) == 0) { m_Verbose = true; } + else if(arg.find("-G",0) == 0) + { + std::string value = arg.substr(2); + cmMakefileGenerator* gen = + cmMakefileGenerator::CreateGenerator(value.c_str()); + if(!gen) + { + cmSystemTools::Error("Could not create named generator ", + value.c_str()); + } + else + { + builder.SetMakefileGenerator(gen); + } + } + // no option assume it is the path to the source + else + { + directoriesSet = true; + builder.SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + builder.SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + builder.SetHomeDirectory + (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str()); + builder.SetStartDirectory + (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str()); + } + } + if(!directoriesSet) + { + builder.SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + builder.SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + builder.SetHomeDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + builder.SetStartDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); } - if (!m_Local) { builder.SetStartDirectory(builder.GetHomeDirectory()); @@ -244,23 +308,46 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles) } // Create a makefile cmMakefile mf; - - // extract the directory arguments - cmake::SetArgs(mf, args); - - // create the generator + // extract the directory arguments, could create a Generator + this->SetArgs(mf, args); + // Read and parse the input makefile + mf.MakeStartDirectoriesCurrent(); + cmCacheManager::GetInstance()->LoadCache(&mf); + // no generator specified on the command line + if(!mf.GetMakefileGenerator()) + { + cmMakefileGenerator* gen; + const char* genName = mf.GetDefinition("CMAKE_GENERATOR"); + if(genName) + { + gen = cmMakefileGenerator::CreateGenerator(genName); + } + else + { #if defined(_WIN32) && !defined(__CYGWIN__) - cmMSProjectGenerator* gen = new cmMSProjectGenerator; + gen = new cmMSProjectGenerator; #else - cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator; + gen = new cmUnixMakefileGenerator; #endif - + } + if(!gen) + { + cmSystemTools::Error("Could not create generator"); + return -1; + } + mf.SetMakefileGenerator(gen); + // add the + } + cmMakefileGenerator* gen = mf.GetMakefileGenerator(); gen->SetLocal(m_Local); - - // Read and parse the input makefile - mf.SetMakefileGenerator(gen); - mf.MakeStartDirectoriesCurrent(); - cmCacheManager::GetInstance()->LoadCache(&mf); + if(!mf.GetDefinition("CMAKE_GENERATOR")) + { + mf.AddCacheDefinition("CMAKE_GENERATOR", + gen->GetName(), + "Name of generator.", + cmCacheManager::INTERNAL); + } + // setup CMAKE_ROOT and CMAKE_COMMAND this->AddCMakePaths(args); |