diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-20 22:51:03 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-11-20 22:51:03 (GMT) |
commit | f7fae15d39d6e290686487778485734227415088 (patch) | |
tree | 4d9b374c6b9cbee02781bf442ab078cfdd449f87 /Source/cmake.cxx | |
parent | f3d63c1932f5a9d2b159ccddf9acd09f8c5358c2 (diff) | |
download | CMake-f7fae15d39d6e290686487778485734227415088.zip CMake-f7fae15d39d6e290686487778485734227415088.tar.gz CMake-f7fae15d39d6e290686487778485734227415088.tar.bz2 |
ENH: add command line arguments to set cache entries
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 30fde30..946cf16 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -80,6 +80,35 @@ void cmake::Usage(const char* program) } // Parse the args +void cmake::SetCacheArgs(cmMakefile& builder, const std::vector<std::string>& args) +{ + for(unsigned int i=1; i < args.size(); ++i) + { + std::string arg = args[i]; + if(arg.find("-D",0) == 0) + { + std::string entry = arg.substr(2); + std::string var, value; + cmCacheManager::CacheEntryType type; + if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type)) + { + cmCacheManager::GetInstance()->AddCacheEntry( + var.c_str(), + cmSystemTools::EscapeSpaces(value.c_str()).c_str(), + "No help, variable specified on the command line.", + type); + std::cerr << "parse entry " << var.c_str()<< " " << value.c_str() << "\n"; + } + else + { + std::cerr << "Parse error in command line argument: " << arg << "\n" + << "Should be: VAR:type=value\n"; + } + } + } +} + +// Parse the args void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args) { m_Local = false; @@ -136,11 +165,6 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args) std::string path = arg.substr(2); builder.SetHomeOutputDirectory(path.c_str()); } - else if(arg.find("-D",0) == 0) - { - std::string value = arg.substr(2); - builder.AddDefinition(value.c_str(), true); - } else if(arg.find("-V",0) == 0) { m_Verbose = true; @@ -315,6 +339,8 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles) // Read and parse the input makefile mf.MakeStartDirectoriesCurrent(); cmCacheManager::GetInstance()->LoadCache(&mf); + // extract command line arguments that might add cache entries + this->SetCacheArgs(mf, args); // no generator specified on the command line if(!mf.GetMakefileGenerator()) { |