[cmake-commits] alex committed cmake.cxx 1.316 1.317
cmFindPackageCommand.cxx 1.21 1.22
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Aug 7 15:41:59 EDT 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv2392/Source
Modified Files:
cmake.cxx cmFindPackageCommand.cxx
Log Message:
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
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.316
retrieving revision 1.317
diff -u -d -r1.316 -r1.317
--- cmake.cxx 1 Aug 2007 18:58:55 -0000 1.316
+++ cmake.cxx 7 Aug 2007 19:41:57 -0000 1.317
@@ -3044,6 +3044,32 @@
"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.");
}
Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cmFindPackageCommand.cxx 11 Apr 2007 19:13:05 -0000 1.21
+++ cmFindPackageCommand.cxx 7 Aug 2007 19:41:57 -0000 1.22
@@ -124,10 +124,12 @@
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 @@
{
if(!this->FindConfig())
{
+ this->AppendSuccessInformation(quiet);
return false;
}
}
@@ -272,6 +275,7 @@
}
#endif
+ this->AppendSuccessInformation(quiet);
return result;
}
@@ -435,3 +439,67 @@
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");
+ }
+ }
+}
More information about the Cmake-commits
mailing list