From 7ded253013b60f7c36b65e0346c658b88f6cffd3 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Mon, 30 Oct 2006 15:59:54 -0500 Subject: ENH: Add support for displaying the list of components --- Source/cmGlobalGenerator.cxx | 41 ++++++++++++++++++++++++++++++++++--- Source/cmInstallTargetGenerator.cxx | 1 + Source/cmake.cxx | 12 +++++++++++ Source/cmake.h | 8 ++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 49000b4..40da2f61 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1395,12 +1395,16 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); singleLine.push_back(this->GetCMakeInstance()->GetCTestCommand()); + singleLine.push_back("--force-new-ctest-process"); if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); singleLine.push_back(mf->GetDefinition("CMAKE_CFG_INTDIR")); } - singleLine.push_back("--force-new-ctest-process"); + else // TODO: This is a hack. Should be something to do with the generator + { + singleLine.push_back("$(ARGS)"); + } cpackCommandLines.push_back(singleLine); (*targets)[this->GetTestTargetName()] = this->CreateGlobalTarget(this->GetTestTargetName(), @@ -1464,9 +1468,40 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) //Install if(this->InstallTargetEnabled) { + if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') + { + std::set* componentsSet + = this->GetCMakeInstance()->GetInstallComponents(); + cpackCommandLines.erase(cpackCommandLines.begin(), + cpackCommandLines.end()); + depends.erase(depends.begin(), depends.end()); + cmOStringStream ostr; + if ( componentsSet->size() > 0 ) + { + ostr << "Available install components are:"; + std::set::iterator it; + for ( + it = componentsSet->begin(); + it != componentsSet->end(); + ++ it ) + { + ostr << " \"" << it->c_str() << "\""; + } + } + else + { + ostr << "Only default component available"; + } + singleLine.push_back(ostr.str().c_str()); + //cpackCommandLines.push_back(singleLine); + (*targets)["list_install_components"] + = this->CreateGlobalTarget("list_install_components", + ostr.str().c_str(), + &cpackCommandLines, depends); + } std::string cmd; cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); + cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); if ( this->GetPreinstallTargetName() ) @@ -1518,7 +1553,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { singleLine.insert(singleLine.begin()+1, "-DCMAKE_INSTALL_LOCAL_ONLY=1"); cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); + cpackCommandLines.end()); cpackCommandLines.push_back(singleLine); (*targets)[install_local] = diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 61536c8..19a0fd2 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -33,6 +33,7 @@ cmInstallTargetGenerator Component(component), Optional(optional) { this->Target->SetHaveInstallRule(true); + this->Target->GetMakefile()->GetCMakeInstance()->AddInstallComponent(component); } //---------------------------------------------------------------------------- diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7929227..e5ebac7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1307,6 +1307,18 @@ int cmake::ExecuteCMakeCommand(std::vector& args) return 1; } +//---------------------------------------------------------------------------- +void cmake::AddInstallComponent(const char* component) +{ + if ( !component ) + { + return; + } + this->InstallComponents.insert(component); +} + + +//---------------------------------------------------------------------------- void cmake::GetRegisteredGenerators(std::vector& names) { for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); diff --git a/Source/cmake.h b/Source/cmake.h index 643dfec..0bb467d 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -284,6 +284,12 @@ class cmake // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } void DebugOutputOn() { this->DebugOutput = true;} + + //! Add or get installation components + void AddInstallComponent(const char* component); + std::set* GetInstallComponents() + { return &this->InstallComponents; } + protected: typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); typedef std::map WrittenFiles; + std::set InstallComponents; + ///! return true if the same cmake was used to make the cache. bool CacheVersionMatches(); ///! read in a cmake list file to initialize the cache -- cgit v0.12