summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-08-07 19:41:57 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-08-07 19:41:57 (GMT)
commit8d7b502337470c3e18d35a6b5e205e657482c2fe (patch)
tree1af3c841051c00beecda76858a3a6836d40a4947 /Source
parentf6d8942ac86e3a480febc93961e1dd0aba2f0b0d (diff)
downloadCMake-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')
-rw-r--r--Source/cmFindPackageCommand.cxx68
-rw-r--r--Source/cmake.cxx26
2 files changed, 94 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");
+ }
+ }
+}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 17b04e1..8e7179e 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3044,6 +3044,32 @@ void cmake::DefineProperties(cmake *cm)
"FIND_LIBRARY command should automatically search the lib64 variant of "
"directories called lib in the search path when building 64-bit "
"binaries.");
+ cm->DefineProperty
+ ("ENABLED_FEATURES", cmProperty::GLOBAL,
+ "List of features which are enabled during the CMake run.",
+ "List of features which are enabled during the CMake run. Be default "
+ "it contains the names of all packages which were found. This is "
+ "determined using the <NAME>_FOUND variables. Packages which are "
+ "searched QUIET are not listed. A project can add its own features to "
+ "this list.This property is used by the macros in FeatureSummary.cmake.");
+ cm->DefineProperty
+ ("DISABLED_FEATURES", cmProperty::GLOBAL,
+ "List of features which are disabled during the CMake run.",
+ "List of features which are disabled during the CMake run. Be default "
+ "it contains the names of all packages which were not found. This is "
+ "determined using the <NAME>_FOUND variables. Packages which are "
+ "searched QUIET are not listed. A project can add its own features to "
+ "this list.This property is used by the macros in FeatureSummary.cmake.");
+ cm->DefineProperty
+ ("PACKAGES_FOUND", cmProperty::GLOBAL,
+ "List of packages which were found during the CMake run.",
+ "List of packages which were found during the CMake run. Whether a "
+ "package has been found is determined using the <NAME>_FOUND variables.");
+ cm->DefineProperty
+ ("PACKAGES_NOT_FOUND", cmProperty::GLOBAL,
+ "List of packages which were not found during the CMake run.",
+ "List of packages which were not found during the CMake run. Whether a "
+ "package has been found is determined using the <NAME>_FOUND variables.");
}