diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-08-07 19:41:57 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-08-07 19:41:57 (GMT) |
commit | 8d7b502337470c3e18d35a6b5e205e657482c2fe (patch) | |
tree | 1af3c841051c00beecda76858a3a6836d40a4947 /Source/cmFindPackageCommand.cxx | |
parent | f6d8942ac86e3a480febc93961e1dd0aba2f0b0d (diff) | |
download | CMake-8d7b502337470c3e18d35a6b5e205e657482c2fe.zip CMake-8d7b502337470c3e18d35a6b5e205e657482c2fe.tar.gz CMake-8d7b502337470c3e18d35a6b5e205e657482c2fe.tar.bz2 |
ENH: add global properties for collecting enabled/disabled features during
the cmake run and add macros print_enabled/disabled_features() and
set_feature_info(), so projects can get a nice overview at the end of the
cmake run what has been found and what hasn't
FIND_PACKAGE() automatically adds the packages to these global properties,
except when used with QUIET
Maybe this can also be useful for packagers to find out dependencies of
projects.
Alex
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 518d3a9..364b64c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -124,10 +124,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) bool foundModule = false; if(!this->FindModule(foundModule, quiet, required)) { + this->AppendSuccessInformation(quiet); return false; } if(foundModule) { + this->AppendSuccessInformation(quiet); return true; } } @@ -172,6 +174,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) { if(!this->FindConfig()) { + this->AppendSuccessInformation(quiet); return false; } } @@ -272,6 +275,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } #endif + this->AppendSuccessInformation(quiet); return result; } @@ -435,3 +439,67 @@ bool cmFindPackageCommand::ReadListFile(const char* f) this->SetError(e.c_str()); return false; } + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AppendToProperty(const char* propertyName) +{ + std::string propertyValue; + const char *prop = + this->Makefile->GetCMakeInstance()->GetProperty(propertyName); + if (prop && *prop) + { + propertyValue = prop; + + std::vector<std::string> contents; + cmSystemTools::ExpandListArgument(propertyValue, contents, false); + + bool alreadyInserted = false; + for(std::vector<std::string>::const_iterator it = contents.begin(); + it != contents.end(); ++ it ) + { + if (*it == this->Name) + { + alreadyInserted = true; + break; + } + } + if (!alreadyInserted) + { + propertyValue += ";"; + propertyValue += this->Name; + } + } + else + { + propertyValue = this->Name; + } + this->Makefile->GetCMakeInstance()->SetProperty(propertyName, + propertyValue.c_str()); + } + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AppendSuccessInformation(bool quiet) +{ + std::string found = this->Name; + found += "_FOUND"; + std::string upperFound = cmSystemTools::UpperCase(found); + + const char* upperResult = this->Makefile->GetDefinition(upperFound.c_str()); + const char* result = this->Makefile->GetDefinition(found.c_str()); + if ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult))) + { + this->AppendToProperty("PACKAGES_FOUND"); + if (!quiet) + { + this->AppendToProperty("ENABLED_FEATURES"); + } + } + else + { + this->AppendToProperty("PACKAGES_NOT_FOUND"); + if (!quiet) + { + this->AppendToProperty("DISABLED_FEATURES"); + } + } +} |