Merge topic 'port-global-properties-to-cmState'

5d056c0d Port Global property interaction to cmState.
de722d7d Move property initialization to cmState.
9b5f80a8 Move global properties to cmState.
0076b5d8 cmake: Remove the happy global property scope pattern.
24b7f31d cmake: Remove unused cmCommand methods.
0aec4913 Port cmCommand consumers to cmState.
96f8c5f9 cmState: Move cmCommand-related methods from cmake class.
97e53ebb cmake: Simplify command clean up loop.
1e738bcf cmake: Simplify RemoveUnscriptableCommands algorithm.
62854e99 cmState: Move try_compile state from cmake class.
db8425be cmake: Get enabled languages from cmState.
74de9a73 cmGlobalGenerator: Delegate storage of enabled languages to cmState.
b159bff7 Move property definition to cmState.
This commit is contained in:
Brad King 2015-04-15 11:46:17 -04:00 committed by CMake Topic Stage
commit 8469b6f694
32 changed files with 439 additions and 415 deletions

View File

@ -198,7 +198,7 @@ int main (int argc, char const* const* argv)
"Read CPack config file: " << cpackConfigFile << std::endl); "Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst; cmake cminst;
cminst.RemoveUnscriptableCommands(); cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg; cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst); cmgg.SetCMakeInstance(&cminst);
cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());

View File

@ -214,7 +214,7 @@ void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command)
cmCTestCommand* newCom = command; cmCTestCommand* newCom = command;
newCom->CTest = this->CTest; newCom->CTest = this->CTest;
newCom->CTestScriptHandler = this; newCom->CTestScriptHandler = this;
this->CMake->AddCommand(newCom); this->CMake->GetState()->AddCommand(newCom);
} }
int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
@ -353,7 +353,7 @@ void cmCTestScriptHandler::CreateCMake()
// remove all cmake commands which are not scriptable, since they can't be // remove all cmake commands which are not scriptable, since they can't be
// used in ctest scripts // used in ctest scripts
this->CMake->RemoveUnscriptableCommands(); this->CMake->GetState()->RemoveUnscriptableCommands();
// add any ctest specific commands, probably should have common superclass // add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are // for ctest commands to clean this up. If a couple more commands are

View File

@ -17,6 +17,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmXMLParser.h" #include "cmXMLParser.h"
#include "cmState.h"
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
@ -1132,7 +1133,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script")); static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
cmake* cm = ch->GetCMake(); cmake* cm = ch->GetCMake();
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL); const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
// TODO: Encode values for a URL instead of trusting caller. // TODO: Encode values for a URL instead of trusting caller.
std::ostringstream str; std::ostringstream str;
str << "project=" str << "project="

View File

@ -1585,25 +1585,25 @@ void cmCTestTestHandler::GetListOfTests()
// Add handler for ADD_TEST // Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
newCom1->TestHandler = this; newCom1->TestHandler = this;
cm.AddCommand(newCom1); cm.GetState()->AddCommand(newCom1);
// Add handler for SUBDIRS // Add handler for SUBDIRS
cmCTestSubdirCommand* newCom2 = cmCTestSubdirCommand* newCom2 =
new cmCTestSubdirCommand; new cmCTestSubdirCommand;
newCom2->TestHandler = this; newCom2->TestHandler = this;
cm.AddCommand(newCom2); cm.GetState()->AddCommand(newCom2);
// Add handler for ADD_SUBDIRECTORY // Add handler for ADD_SUBDIRECTORY
cmCTestAddSubdirectoryCommand* newCom3 = cmCTestAddSubdirectoryCommand* newCom3 =
new cmCTestAddSubdirectoryCommand; new cmCTestAddSubdirectoryCommand;
newCom3->TestHandler = this; newCom3->TestHandler = this;
cm.AddCommand(newCom3); cm.GetState()->AddCommand(newCom3);
// Add handler for SET_SOURCE_FILES_PROPERTIES // Add handler for SET_SOURCE_FILES_PROPERTIES
cmCTestSetTestsPropertiesCommand* newCom4 cmCTestSetTestsPropertiesCommand* newCom4
= new cmCTestSetTestsPropertiesCommand; = new cmCTestSetTestsPropertiesCommand;
newCom4->TestHandler = this; newCom4->TestHandler = this;
cm.AddCommand(newCom4); cm.GetState()->AddCommand(newCom4);
const char* testFilename; const char* testFilename;
if( cmSystemTools::FileExists("CTestTestfile.cmake") ) if( cmSystemTools::FileExists("CTestTestfile.cmake") )

View File

@ -12,6 +12,7 @@
#include "cmAddLibraryCommand.h" #include "cmAddLibraryCommand.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
// cmLibraryCommand // cmLibraryCommand
bool cmAddLibraryCommand bool cmAddLibraryCommand
@ -330,7 +331,7 @@ bool cmAddLibraryCommand
yet its linker language. */ yet its linker language. */
if ((type == cmTarget::SHARED_LIBRARY || if ((type == cmTarget::SHARED_LIBRARY ||
type == cmTarget::MODULE_LIBRARY) && type == cmTarget::MODULE_LIBRARY) &&
(this->Makefile->GetCMakeInstance()->GetPropertyAsBool( (this->Makefile->GetState()->GetGlobalPropertyAsBool(
"TARGET_SUPPORTS_SHARED_LIBS") == false)) "TARGET_SUPPORTS_SHARED_LIBS") == false))
{ {
std::ostringstream w; std::ostringstream w;

View File

@ -164,7 +164,7 @@ int CCONV cmIsOn(void *arg, const char* name)
int CCONV cmCommandExists(void *arg, const char* name) int CCONV cmCommandExists(void *arg, const char* name)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
return static_cast<int>(mf->CommandExists(name)); return static_cast<int>(mf->GetState()->GetCommand(name) ? 1 : 0);
} }
void CCONV cmAddDefineFlag(void *arg, const char* definition) void CCONV cmAddDefineFlag(void *arg, const char* definition)
@ -867,7 +867,7 @@ void CCONV DefineSourceFileProperty (void *arg, const char *name,
int chained) int chained)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg); cmMakefile *mf = static_cast<cmMakefile *>(arg);
mf->GetCMakeInstance()->DefineProperty(name,cmProperty::SOURCE_FILE, mf->GetState()->DefineProperty(name,cmProperty::SOURCE_FILE,
briefDocs, longDocs, briefDocs, longDocs,
chained != 0); chained != 0);
} }

View File

@ -27,6 +27,7 @@
#include "cmCTestCommand.h" #include "cmCTestCommand.h"
#include "cmCTestStartCommand.h" #include "cmCTestStartCommand.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmState.h"
#include "cmCTestBuildHandler.h" #include "cmCTestBuildHandler.h"
#include "cmCTestBuildAndTestHandler.h" #include "cmCTestBuildAndTestHandler.h"
@ -1558,12 +1559,14 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
return; return;
} }
// This code should go when cdash is changed to use labels only // This code should go when cdash is changed to use labels only
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL); const char* subproject = cm->GetState()
->GetGlobalProperty("SubProject");
if(subproject) if(subproject)
{ {
ostr << "<Subproject name=\"" << subproject << "\">\n"; ostr << "<Subproject name=\"" << subproject << "\">\n";
const char* labels = const char* labels =
ch->GetCMake()->GetProperty("SubProjectLabels", cmProperty::GLOBAL); ch->GetCMake()->GetState()
->GetGlobalProperty("SubProjectLabels");
if(labels) if(labels)
{ {
ostr << " <Labels>\n"; ostr << " <Labels>\n";
@ -1581,7 +1584,7 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
} }
// This code should stay when cdash only does label based sub-projects // This code should stay when cdash only does label based sub-projects
const char* label = cm->GetProperty("Label", cmProperty::GLOBAL); const char* label = cm->GetState()->GetGlobalProperty("Label");
if(label) if(label)
{ {
ostr << "<Labels>\n"; ostr << "<Labels>\n";

View File

@ -15,6 +15,7 @@
#include "cmOrderDirectories.h" #include "cmOrderDirectories.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmState.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmTarget.h" #include "cmTarget.h"
@ -250,8 +251,8 @@ cmComputeLinkInformation
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// Check whether to recognize OpenBSD-style library versioned names. // Check whether to recognize OpenBSD-style library versioned names.
this->OpenBSD = this->Makefile->GetCMakeInstance() this->OpenBSD = this->Makefile->GetState()
->GetPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING"); ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
// The configuration being linked. // The configuration being linked.
this->Config = config; this->Config = config;
@ -796,9 +797,8 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
void cmComputeLinkInformation::ComputeLinkTypeInfo() void cmComputeLinkInformation::ComputeLinkTypeInfo()
{ {
// Check whether archives may actually be shared libraries. // Check whether archives may actually be shared libraries.
this->ArchivesMayBeShared = this->ArchivesMayBeShared = this->CMakeInstance->GetState()
this->CMakeInstance->GetPropertyAsBool( ->GetGlobalPropertyAsBool("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
"TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
// First assume we cannot do link type stuff. // First assume we cannot do link type stuff.
this->LinkTypeEnabled = false; this->LinkTypeEnabled = false;
@ -1527,9 +1527,10 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
// Print the warning at most once for this item. // Print the warning at most once for this item.
std::string wid = "CMP0008-WARNING-GIVEN-"; std::string wid = "CMP0008-WARNING-GIVEN-";
wid += item; wid += item;
if(!this->CMakeInstance->GetPropertyAsBool(wid)) if(!this->CMakeInstance->GetState()
->GetGlobalPropertyAsBool(wid))
{ {
this->CMakeInstance->SetProperty(wid, "1"); this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1");
std::ostringstream w; std::ostringstream w;
w << (this->Makefile->GetPolicies() w << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0008)) << "\n" ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
@ -1576,9 +1577,11 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
switch(this->Target->GetPolicyStatusCMP0003()) switch(this->Target->GetPolicyStatusCMP0003())
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
if(!this->CMakeInstance->GetPropertyAsBool("CMP0003-WARNING-GIVEN")) if(!this->CMakeInstance->GetState()
->GetGlobalPropertyAsBool("CMP0003-WARNING-GIVEN"))
{ {
this->CMakeInstance->SetProperty("CMP0003-WARNING-GIVEN", "1"); this->CMakeInstance->GetState()
->SetGlobalProperty("CMP0003-WARNING-GIVEN", "1");
std::ostringstream w; std::ostringstream w;
this->PrintLinkPolicyDiagnosis(w); this->PrintLinkPolicyDiagnosis(w);
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),

View File

@ -15,6 +15,7 @@
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmState.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h" #include "cmTarget.h"
@ -98,8 +99,10 @@ cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg)
{ {
this->GlobalGenerator = gg; this->GlobalGenerator = gg;
cmake* cm = this->GlobalGenerator->GetCMakeInstance(); cmake* cm = this->GlobalGenerator->GetCMakeInstance();
this->DebugMode = cm->GetPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE"); this->DebugMode = cm->GetState()
this->NoCycles = cm->GetPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES"); ->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
this->NoCycles = cm->GetState()
->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -481,8 +481,10 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
// does a command exist // does a command exist
if (this->IsKeyword("COMMAND", *arg) && argP1 != newArgs.end()) if (this->IsKeyword("COMMAND", *arg) && argP1 != newArgs.end())
{ {
cmCommand* command =
this->Makefile.GetState()->GetCommand(argP1->c_str());
this->HandlePredicate( this->HandlePredicate(
this->Makefile.CommandExists(argP1->c_str()), command ? true : false,
reducible, arg, newArgs, argP1, argP2); reducible, arg, newArgs, argP1, argP2);
} }
// does a policy exist // does a policy exist

View File

@ -11,6 +11,7 @@
============================================================================*/ ============================================================================*/
#include "cmDefinePropertyCommand.h" #include "cmDefinePropertyCommand.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
bool cmDefinePropertyCommand bool cmDefinePropertyCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@ -127,7 +128,7 @@ bool cmDefinePropertyCommand
} }
// Actually define the property. // Actually define the property.
this->Makefile->GetCMakeInstance()->DefineProperty this->Makefile->GetState()->DefineProperty
(this->PropertyName, scope, (this->PropertyName, scope,
this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited); this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);

View File

@ -469,8 +469,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
fout << "\t\t<nature>" << *nit << "</nature>\n"; fout << "\t\t<nature>" << *nit << "</nature>\n";
} }
if (const char *extraNaturesProp = mf->GetCMakeInstance()-> if (const char *extraNaturesProp = mf->GetState()
GetProperty("ECLIPSE_EXTRA_NATURES", cmProperty::GLOBAL)) ->GetGlobalProperty("ECLIPSE_EXTRA_NATURES"))
{ {
std::vector<std::string> extraNatures; std::vector<std::string> extraNatures;
cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures); cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);

View File

@ -54,8 +54,8 @@ bool cmFindLibraryCommand
} }
} }
if(this->Makefile->GetCMakeInstance() if(this->Makefile->GetState()
->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
{ {
// add special 64 bit paths if this is a 64 bit compile. // add special 64 bit paths if this is a 64 bit compile.
if(this->Makefile->PlatformIs64Bit()) if(this->Makefile->PlatformIs64Bit())
@ -226,8 +226,8 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf):
// Check whether to use OpenBSD-style library version comparisons. // Check whether to use OpenBSD-style library version comparisons.
this->OpenBSD = this->OpenBSD =
this->Makefile->GetCMakeInstance() this->Makefile->GetState()
->GetPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING"); ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -120,8 +120,8 @@ bool cmFindPackageCommand
// Lookup whether lib64 paths should be used. // Lookup whether lib64 paths should be used.
if(this->Makefile->PlatformIs64Bit() && if(this->Makefile->PlatformIs64Bit() &&
this->Makefile->GetCMakeInstance() this->Makefile->GetState()
->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
{ {
this->UseLib64Paths = true; this->UseLib64Paths = true;
} }
@ -1015,8 +1015,8 @@ bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
void cmFindPackageCommand::AppendToFoundProperty(bool found) void cmFindPackageCommand::AppendToFoundProperty(bool found)
{ {
std::vector<std::string> foundContents; std::vector<std::string> foundContents;
const char *foundProp = const char *foundProp = this->Makefile->GetState()
this->Makefile->GetCMakeInstance()->GetProperty("PACKAGES_FOUND"); ->GetGlobalProperty("PACKAGES_FOUND");
if (foundProp && *foundProp) if (foundProp && *foundProp)
{ {
std::string tmp = foundProp; std::string tmp = foundProp;
@ -1032,7 +1032,8 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
std::vector<std::string> notFoundContents; std::vector<std::string> notFoundContents;
const char *notFoundProp = const char *notFoundProp =
this->Makefile->GetCMakeInstance()->GetProperty("PACKAGES_NOT_FOUND"); this->Makefile->GetState()
->GetGlobalProperty("PACKAGES_NOT_FOUND");
if (notFoundProp && *notFoundProp) if (notFoundProp && *notFoundProp)
{ {
std::string tmp = notFoundProp; std::string tmp = notFoundProp;
@ -1057,12 +1058,12 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
std::string tmp = cmJoin(foundContents, ";"); std::string tmp = cmJoin(foundContents, ";");
this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_FOUND", this->Makefile->GetState()
tmp.c_str()); ->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str());
tmp = cmJoin(notFoundContents, ";"); tmp = cmJoin(notFoundContents, ";");
this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_NOT_FOUND", this->Makefile->GetState()
tmp.c_str()); ->SetGlobalProperty("PACKAGES_NOT_FOUND", tmp.c_str());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1071,8 +1072,8 @@ void cmFindPackageCommand::AppendSuccessInformation()
{ {
std::string transitivePropName = "_CMAKE_"; std::string transitivePropName = "_CMAKE_";
transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY"; transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
this->Makefile->GetCMakeInstance() this->Makefile->GetState()
->SetProperty(transitivePropName, "False"); ->SetGlobalProperty(transitivePropName, "False");
} }
std::string found = this->Name; std::string found = this->Name;
found += "_FOUND"; found += "_FOUND";
@ -1090,8 +1091,8 @@ void cmFindPackageCommand::AppendSuccessInformation()
std::string quietInfoPropName = "_CMAKE_"; std::string quietInfoPropName = "_CMAKE_";
quietInfoPropName += this->Name; quietInfoPropName += this->Name;
quietInfoPropName += "_QUIET"; quietInfoPropName += "_QUIET";
this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName, this->Makefile->GetState()
this->Quiet ? "TRUE" : "FALSE"); ->SetGlobalProperty(quietInfoPropName, this->Quiet ? "TRUE" : "FALSE");
// set a global property to record the required version of this package // set a global property to record the required version of this package
std::string versionInfoPropName = "_CMAKE_"; std::string versionInfoPropName = "_CMAKE_";
@ -1104,15 +1105,15 @@ void cmFindPackageCommand::AppendSuccessInformation()
versionInfo += " "; versionInfo += " ";
versionInfo += this->Version; versionInfo += this->Version;
} }
this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName, this->Makefile->GetState()
versionInfo.c_str()); ->SetGlobalProperty(versionInfoPropName, versionInfo.c_str());
if (this->Required) if (this->Required)
{ {
std::string requiredInfoPropName = "_CMAKE_"; std::string requiredInfoPropName = "_CMAKE_";
requiredInfoPropName += this->Name; requiredInfoPropName += this->Name;
requiredInfoPropName += "_TYPE"; requiredInfoPropName += "_TYPE";
this->Makefile->GetCMakeInstance()->SetProperty( this->Makefile->GetState()
requiredInfoPropName, "REQUIRED"); ->SetGlobalProperty(requiredInfoPropName, "REQUIRED");
} }

View File

@ -193,9 +193,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
} }
std::string newName = "_" + this->Args[0]; std::string newName = "_" + this->Args[0];
mf.GetCMakeInstance()->RenameCommand(this->Args[0], mf.GetState()->RenameCommand(this->Args[0], newName);
newName); mf.GetState()->AddCommand(f);
mf.AddCommand(f);
// remove the function blocker now that the function is defined // remove the function blocker now that the function is defined
mf.RemoveFunctionBlocker(this, lff); mf.RemoveFunctionBlocker(this, lff);

View File

@ -14,6 +14,7 @@
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
// cmGetCMakePropertyCommand // cmGetCMakePropertyCommand
@ -53,7 +54,8 @@ bool cmGetCMakePropertyCommand
else else
{ {
const char *prop = const char *prop =
this->Makefile->GetCMakeInstance()->GetProperty(args[1]); this->Makefile->GetState()
->GetGlobalProperty(args[1]);
if (prop) if (prop)
{ {
output = prop; output = prop;

View File

@ -143,7 +143,7 @@ bool cmGetPropertyCommand
// Lookup brief documentation. // Lookup brief documentation.
std::string output; std::string output;
if(cmPropertyDefinition* def = if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()-> this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
output = def->GetShortDescription(); output = def->GetShortDescription();
@ -159,7 +159,7 @@ bool cmGetPropertyCommand
// Lookup full documentation. // Lookup full documentation.
std::string output; std::string output;
if(cmPropertyDefinition* def = if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()-> this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
output = def->GetFullDescription(); output = def->GetFullDescription();
@ -173,7 +173,7 @@ bool cmGetPropertyCommand
else if(this->InfoType == OutDefined) else if(this->InfoType == OutDefined)
{ {
// Lookup if the property is defined // Lookup if the property is defined
if(this->Makefile->GetCMakeInstance()-> if(this->Makefile->GetState()->
GetPropertyDefinition(this->PropertyName, scope)) GetPropertyDefinition(this->PropertyName, scope))
{ {
this->Makefile->AddDefinition(this->Variable, "1"); this->Makefile->AddDefinition(this->Variable, "1");
@ -237,7 +237,8 @@ bool cmGetPropertyCommand::HandleGlobalMode()
// Get the property. // Get the property.
cmake* cm = this->Makefile->GetCMakeInstance(); cmake* cm = this->Makefile->GetCMakeInstance();
return this->StoreResult(cm->GetProperty(this->PropertyName)); return this->StoreResult(cm->GetState()
->GetGlobalProperty(this->PropertyName));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -200,7 +200,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
if (cnameString != pathString) if (cnameString != pathString)
{ {
const char* cvars = const char* cvars =
this->GetCMakeInstance()->GetProperty( this->GetCMakeInstance()->GetState()->GetGlobalProperty(
"__CMAKE_DELETE_CACHE_CHANGE_VARS_"); "__CMAKE_DELETE_CACHE_CHANGE_VARS_");
if(cvars) if(cvars)
{ {
@ -210,7 +210,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
changeVars += langComp; changeVars += langComp;
changeVars += ";"; changeVars += ";";
changeVars += cname; changeVars += cname;
this->GetCMakeInstance()->SetProperty( this->GetCMakeInstance()->GetState()->SetGlobalProperty(
"__CMAKE_DELETE_CACHE_CHANGE_VARS_", "__CMAKE_DELETE_CACHE_CHANGE_VARS_",
changeVars.c_str()); changeVars.c_str());
} }
@ -969,13 +969,7 @@ void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l, void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
cmMakefile* mf) cmMakefile* mf)
{ {
std::vector<std::string>::iterator it = this->CMakeInstance->GetState()->SetLanguageEnabled(l);
std::lower_bound(this->LanguageEnabled.begin(),
this->LanguageEnabled.end(), l);
if (it == this->LanguageEnabled.end() || *it != l)
{
this->LanguageEnabled.insert(it, l);
}
// Fill the language-to-extension map with the current variable // Fill the language-to-extension map with the current variable
// settings to make sure it is available for the try_compile() // settings to make sure it is available for the try_compile()
@ -1086,13 +1080,12 @@ bool cmGlobalGenerator::IgnoreFile(const char* ext) const
bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
{ {
return std::binary_search(this->LanguageEnabled.begin(), return this->CMakeInstance->GetState()->GetLanguageEnabled(l);
this->LanguageEnabled.end(), l);
} }
void cmGlobalGenerator::ClearEnabledLanguages() void cmGlobalGenerator::ClearEnabledLanguages()
{ {
this->LanguageEnabled.clear(); return this->CMakeInstance->GetState()->ClearEnabledLanguages();
} }
void cmGlobalGenerator::Configure() void cmGlobalGenerator::Configure()
@ -1177,8 +1170,8 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
{ {
// If the property is not enabled then okay. // If the property is not enabled then okay.
if(!this->CMakeInstance if(!this->CMakeInstance->GetState()
->GetPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS")) ->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
{ {
return true; return true;
} }
@ -1966,7 +1959,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
void void
cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
{ {
lang = this->LanguageEnabled; lang = this->CMakeInstance->GetState()->GetEnabledLanguages();
} }
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
@ -2398,8 +2391,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGlobalGenerator::GetPredefinedTargetsFolder() const char* cmGlobalGenerator::GetPredefinedTargetsFolder()
{ {
const char* prop = const char* prop = this->GetCMakeInstance()->GetState()
this->GetCMakeInstance()->GetProperty("PREDEFINED_TARGETS_FOLDER"); ->GetGlobalProperty("PREDEFINED_TARGETS_FOLDER");
if (prop) if (prop)
{ {
@ -2412,7 +2405,8 @@ const char* cmGlobalGenerator::GetPredefinedTargetsFolder()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGlobalGenerator::UseFolderProperty() bool cmGlobalGenerator::UseFolderProperty()
{ {
const char* prop = this->GetCMakeInstance()->GetProperty("USE_FOLDERS"); const char* prop = this->GetCMakeInstance()->GetState()
->GetGlobalProperty("USE_FOLDERS");
// If this property is defined, let the setter turn this on or off... // If this property is defined, let the setter turn this on or off...
// //

View File

@ -273,7 +273,7 @@ bool cmLoadCommandCommand
// create a function blocker and set it up // create a function blocker and set it up
cmLoadedCommand *f = new cmLoadedCommand(); cmLoadedCommand *f = new cmLoadedCommand();
(*initFunction)(&f->info); (*initFunction)(&f->info);
this->Makefile->AddCommand(f); this->Makefile->GetState()->AddCommand(f);
return true; return true;
} }
this->SetError("Attempt to load command failed. " this->SetError("Attempt to load command failed. "

View File

@ -18,6 +18,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
#include <assert.h> #include <assert.h>
@ -234,8 +235,8 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
{ {
cmGlobalNinjaGenerator::WriteDivider(os); cmGlobalNinjaGenerator::WriteDivider(os);
const char* jobpools = this->GetCMakeInstance() const char* jobpools = this->GetCMakeInstance()->GetState()
->GetProperty("JOB_POOLS", cmProperty::GLOBAL); ->GetGlobalProperty("JOB_POOLS");
if (jobpools) if (jobpools)
{ {
cmGlobalNinjaGenerator::WriteComment(os, cmGlobalNinjaGenerator::WriteComment(os,

View File

@ -232,9 +232,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
f->Functions = this->Functions; f->Functions = this->Functions;
mf.RecordPolicies(f->Policies); mf.RecordPolicies(f->Policies);
std::string newName = "_" + this->Args[0]; std::string newName = "_" + this->Args[0];
mf.GetCMakeInstance()->RenameCommand(this->Args[0], mf.GetState()->RenameCommand(this->Args[0], newName);
newName); mf.GetState()->AddCommand(f);
mf.AddCommand(f);
// remove the function blocker now that the macro is defined // remove the function blocker now that the macro is defined
mf.RemoveFunctionBlocker(this, lff); mf.RemoveFunctionBlocker(this, lff);

View File

@ -244,12 +244,6 @@ void cmMakefile::Print() const
#endif #endif
} }
bool cmMakefile::CommandExists(const char* name) const
{
return this->GetCMakeInstance()->CommandExists(name);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefile::IssueMessage(cmake::MessageType t, void cmMakefile::IssueMessage(cmake::MessageType t,
std::string const& text) const std::string const& text) const
@ -340,7 +334,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
static_cast<void>(stack_manager); static_cast<void>(stack_manager);
// Lookup the command prototype. // Lookup the command prototype.
if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name)) if(cmCommand* proto = this->GetState()->GetCommand(name))
{ {
// Clone the prototype. // Clone the prototype.
cmsys::auto_ptr<cmCommand> pcmd(proto->Clone()); cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
@ -718,11 +712,6 @@ void cmMakefile::EnforceDirectoryLevelRules() const
} }
} }
void cmMakefile::AddCommand(cmCommand* wg)
{
this->GetCMakeInstance()->AddCommand(wg);
}
// Set the make file // Set the make file
void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
{ {
@ -4250,7 +4239,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
return this->LocalGenerator->GetParent()->GetMakefile()-> return this->LocalGenerator->GetParent()->GetMakefile()->
GetProperty(prop, scope); GetProperty(prop, scope);
} }
return this->GetCMakeInstance()->GetProperty(prop,scope); return this->GetState()->GetGlobalProperty(prop);
} }
return retVal; return retVal;
@ -4476,21 +4465,6 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
} }
} }
// define properties
void cmMakefile::DefineProperties(cmake *cm)
{
cm->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
"", "", true);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmMakefile::AddImportedTarget(const std::string& name, cmMakefile::AddImportedTarget(const std::string& name,
@ -4611,7 +4585,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
this->LocalGenerator->GetGlobalGenerator()->GetCMakeInstance(); this->LocalGenerator->GetGlobalGenerator()->GetCMakeInstance();
if(isCustom && existing->GetType() == cmTarget::UTILITY && if(isCustom && existing->GetType() == cmTarget::UTILITY &&
this != existing->GetMakefile() && this != existing->GetMakefile() &&
cm->GetPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS")) cm->GetState()
->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
{ {
return true; return true;
} }

View File

@ -746,14 +746,6 @@ public:
bool ExecuteCommand(const cmListFileFunction& lff, bool ExecuteCommand(const cmListFileFunction& lff,
cmExecutionStatus &status); cmExecutionStatus &status);
/** Check if a command exists. */
bool CommandExists(const char* name) const;
/**
* Add a command to this cmake instance
*/
void AddCommand(cmCommand* );
///! Enable support for named language, if nil then all languages are ///! Enable support for named language, if nil then all languages are
///enabled. ///enabled.
void EnableLanguage(std::vector<std::string>const& languages, bool optional); void EnableLanguage(std::vector<std::string>const& languages, bool optional);
@ -851,9 +843,6 @@ public:
const std::vector<cmTestGenerator*>& GetTestGenerators() const const std::vector<cmTestGenerator*>& GetTestGenerators() const
{ return this->TestGenerators; } { return this->TestGenerators; }
// Define the properties
static void DefineProperties(cmake *cm);
// push and pop variable scopes // push and pop variable scopes
void PushScope(); void PushScope();
void PopScope(); void PopScope();

View File

@ -20,6 +20,7 @@
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h" #include "cmCustomCommandGenerator.h"
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
@ -51,7 +52,8 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target)
this->GeneratorTarget = this->GlobalGenerator->GetGeneratorTarget(target); this->GeneratorTarget = this->GlobalGenerator->GetGeneratorTarget(target);
cmake* cm = this->GlobalGenerator->GetCMakeInstance(); cmake* cm = this->GlobalGenerator->GetCMakeInstance();
this->NoRuleMessages = false; this->NoRuleMessages = false;
if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES")) if(const char* ruleStatus = cm->GetState()
->GetGlobalProperty("RULE_MESSAGES"))
{ {
this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus); this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus);
} }

View File

@ -12,6 +12,7 @@
#include "cmPropertyMap.h" #include "cmPropertyMap.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h"
cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
{ {
@ -73,7 +74,8 @@ const char *cmPropertyMap
// should we chain up? // should we chain up?
if (this->CMakeInstance) if (this->CMakeInstance)
{ {
chain = this->CMakeInstance->IsPropertyChained(name,scope); chain = this->CMakeInstance->GetState()->
IsPropertyChained(name,scope);
} }
return 0; return 0;
} }

View File

@ -16,6 +16,7 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmState.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
@ -472,12 +473,12 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
} }
// Set target folder // Set target folder
const char* autogenFolder = makefile->GetCMakeInstance()->GetProperty( const char* autogenFolder = makefile->GetState()
"AUTOMOC_TARGETS_FOLDER"); ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
if (!autogenFolder) if (!autogenFolder)
{ {
autogenFolder = makefile->GetCMakeInstance()->GetProperty( autogenFolder = makefile->GetState()
"AUTOGEN_TARGETS_FOLDER"); ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
} }
if (autogenFolder && *autogenFolder) if (autogenFolder && *autogenFolder)
{ {

View File

@ -13,10 +13,21 @@
#include "cmake.h" #include "cmake.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmCommand.h"
#include "cmAlgorithms.h"
#include <assert.h>
cmState::cmState(cmake* cm) cmState::cmState(cmake* cm)
: CMakeInstance(cm) : CMakeInstance(cm),
IsInTryCompile(false)
{ {
this->Initialize();
}
cmState::~cmState()
{
cmDeleteAll(this->Commands);
} }
const char* cmCacheEntryTypes[] = const char* cmCacheEntryTypes[] =
@ -178,3 +189,258 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
this->CMakeInstance->GetCacheManager() this->CMakeInstance->GetCacheManager()
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
} }
void cmState::Initialize()
{
this->GlobalProperties.clear();
this->PropertyDefinitions.clear();
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::TARGET,
"", "", true);
this->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
"", "", true);
}
void cmState::DefineProperty(const std::string& name,
cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
{
this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
FullDescription,
chained);
}
cmPropertyDefinition *cmState
::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
{
return &(this->PropertyDefinitions[scope][name]);
}
return 0;
}
bool cmState::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
bool cmState::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}
void cmState::SetLanguageEnabled(std::string const& l)
{
std::vector<std::string>::iterator it =
std::lower_bound(this->EnabledLanguages.begin(),
this->EnabledLanguages.end(), l);
if (it == this->EnabledLanguages.end() || *it != l)
{
this->EnabledLanguages.insert(it, l);
}
}
bool cmState::GetLanguageEnabled(std::string const& l) const
{
return std::binary_search(this->EnabledLanguages.begin(),
this->EnabledLanguages.end(), l);
}
std::vector<std::string> cmState::GetEnabledLanguages() const
{
return this->EnabledLanguages;
}
void cmState::ClearEnabledLanguages()
{
this->EnabledLanguages.clear();
}
bool cmState::GetIsInTryCompile() const
{
return this->IsInTryCompile;
}
void cmState::SetIsInTryCompile(bool b)
{
this->IsInTryCompile = b;
}
void cmState::RenameCommand(std::string const& oldName,
std::string const& newName)
{
// if the command already exists, free the old one
std::string sOldName = cmSystemTools::LowerCase(oldName);
std::string sNewName = cmSystemTools::LowerCase(newName);
std::map<std::string, cmCommand*>::iterator pos =
this->Commands.find(sOldName);
if ( pos == this->Commands.end() )
{
return;
}
cmCommand* cmd = pos->second;
pos = this->Commands.find(sNewName);
if (pos != this->Commands.end())
{
delete pos->second;
this->Commands.erase(pos);
}
this->Commands.insert(std::make_pair(sNewName, cmd));
pos = this->Commands.find(sOldName);
this->Commands.erase(pos);
}
void cmState::AddCommand(cmCommand* command)
{
std::string name = cmSystemTools::LowerCase(command->GetName());
// if the command already exists, free the old one
std::map<std::string, cmCommand*>::iterator pos = this->Commands.find(name);
if (pos != this->Commands.end())
{
delete pos->second;
this->Commands.erase(pos);
}
this->Commands.insert(std::make_pair(name, command));
}
void cmState::RemoveUnscriptableCommands()
{
std::vector<std::string> unscriptableCommands;
for (std::map<std::string, cmCommand*>::iterator
pos = this->Commands.begin();
pos != this->Commands.end(); )
{
if (!pos->second->IsScriptable())
{
delete pos->second;
this->Commands.erase(pos++);
}
else
{
++pos;
}
}
}
cmCommand* cmState::GetCommand(std::string const& name) const
{
cmCommand* command = 0;
std::string sName = cmSystemTools::LowerCase(name);
std::map<std::string, cmCommand*>::const_iterator pos =
this->Commands.find(sName);
if (pos != this->Commands.end())
{
command = (*pos).second;
}
return command;
}
std::vector<std::string> cmState::GetCommandNames() const
{
std::vector<std::string> commandNames;
commandNames.reserve(this->Commands.size());
std::map<std::string, cmCommand*>::const_iterator cmds
= this->Commands.begin();
for ( ; cmds != this->Commands.end(); ++ cmds )
{
commandNames.push_back(cmds->first);
}
return commandNames;
}
void cmState::RemoveUserDefinedCommands()
{
for(std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
j != this->Commands.end(); )
{
if (j->second->IsA("cmMacroHelperCommand") ||
j->second->IsA("cmFunctionHelperCommand"))
{
delete j->second;
this->Commands.erase(j++);
}
else
{
++j;
}
}
}
void cmState::SetGlobalProperty(const std::string& prop, const char* value)
{
this->GlobalProperties.SetProperty(prop, value, cmProperty::GLOBAL);
}
void cmState::AppendGlobalProperty(const std::string& prop,
const char* value, bool asString)
{
this->GlobalProperties.AppendProperty(prop, value,
cmProperty::GLOBAL, asString);
}
const char *cmState::GetGlobalProperty(const std::string& prop)
{
// watch for special properties
std::string output = "";
if ( prop == "CACHE_VARIABLES" )
{
std::vector<std::string> cacheKeys = this->GetCacheEntryKeys();
this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
}
else if ( prop == "COMMANDS" )
{
std::vector<std::string> commands = this->GetCommandNames();
this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str());
}
else if ( prop == "IN_TRY_COMPILE" )
{
this->SetGlobalProperty("IN_TRY_COMPILE",
this->IsInTryCompile ? "1" : "0");
}
else if ( prop == "ENABLED_LANGUAGES" )
{
std::string langs;
langs = cmJoin(this->EnabledLanguages, ";");
this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
}
#define STRING_LIST_ELEMENT(F) ";" #F
if (prop == "CMAKE_C_KNOWN_FEATURES")
{
return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
}
if (prop == "CMAKE_CXX_KNOWN_FEATURES")
{
return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
}
#undef STRING_LIST_ELEMENT
bool dummy = false;
return this->GlobalProperties.GetPropertyValue(prop, cmProperty::GLOBAL,
dummy);
}
bool cmState::GetGlobalPropertyAsBool(const std::string& prop)
{
return cmSystemTools::IsOn(this->GetGlobalProperty(prop));
}

View File

@ -13,13 +13,17 @@
#define cmState_h #define cmState_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmPropertyDefinitionMap.h"
#include "cmPropertyMap.h"
class cmake; class cmake;
class cmCommand;
class cmState class cmState
{ {
public: public:
cmState(cmake* cm); cmState(cmake* cm);
~cmState();
enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,
UNINITIALIZED }; UNINITIALIZED };
@ -55,8 +59,49 @@ public:
void RemoveCacheEntryProperty(std::string const& key, void RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName); std::string const& propertyName);
void Initialize();
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
(const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
void SetLanguageEnabled(std::string const& l);
bool GetLanguageEnabled(std::string const& l) const;
std::vector<std::string> GetEnabledLanguages() const;
void ClearEnabledLanguages();
bool GetIsInTryCompile() const;
void SetIsInTryCompile(bool b);
cmCommand* GetCommand(std::string const& name) const;
void AddCommand(cmCommand* command);
void RemoveUnscriptableCommands();
void RenameCommand(std::string const& oldName, std::string const& newName);
void RemoveUserDefinedCommands();
std::vector<std::string> GetCommandNames() const;
void SetGlobalProperty(const std::string& prop, const char *value);
void AppendGlobalProperty(const std::string& prop,
const char *value,bool asString=false);
const char *GetGlobalProperty(const std::string& prop);
bool GetGlobalPropertyAsBool(const std::string& prop);
private: private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
std::map<std::string, cmCommand*> Commands;
cmPropertyMap GlobalProperties;
cmake* CMakeInstance; cmake* CMakeInstance;
bool IsInTryCompile;
}; };
#endif #endif

View File

@ -264,20 +264,6 @@ cmTarget::cmTarget()
this->LinkImplementationLanguageIsContextDependent = true; this->LinkImplementationLanguageIsContextDependent = true;
} }
//----------------------------------------------------------------------------
void cmTarget::DefineProperties(cmake *cm)
{
cm->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_LINK", cmProperty::TARGET,
"", "", true);
cm->DefineProperty
("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
"", "", true);
}
void cmTarget::SetType(TargetType type, const std::string& name) void cmTarget::SetType(TargetType type, const std::string& name)
{ {
this->Name = name; this->Name = name;

View File

@ -489,9 +489,6 @@ public:
const char** imp, const char** imp,
std::string& suffix) const; std::string& suffix) const;
// Define the properties
static void DefineProperties(cmake *cm);
/** Get the macro to define when building sources in this target. /** Get the macro to define when building sources in this target.
If no macro should be defined null is returned. */ If no macro should be defined null is returned. */
const char* GetExportMacro() const; const char* GetExportMacro() const;

View File

@ -136,8 +136,6 @@ cmake::cmake()
this->Policies = new cmPolicies(); this->Policies = new cmPolicies();
this->State = new cmState(this); this->State = new cmState(this);
this->InitializeProperties();
#ifdef __APPLE__ #ifdef __APPLE__
struct rlimit rlp; struct rlimit rlp;
if(!getrlimit(RLIMIT_STACK, &rlp)) if(!getrlimit(RLIMIT_STACK, &rlp))
@ -151,7 +149,6 @@ cmake::cmake()
#endif #endif
this->Verbose = false; this->Verbose = false;
this->InTryCompile = false;
this->CacheManager = new cmCacheManager(this); this->CacheManager = new cmCacheManager(this);
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
this->ProgressCallback = 0; this->ProgressCallback = 0;
@ -180,7 +177,6 @@ cmake::~cmake()
delete this->GlobalGenerator; delete this->GlobalGenerator;
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
} }
cmDeleteAll(this->Commands);
cmDeleteAll(this->Generators); cmDeleteAll(this->Generators);
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
delete this->VariableWatch; delete this->VariableWatch;
@ -188,128 +184,10 @@ cmake::~cmake()
delete this->FileComparison; delete this->FileComparison;
} }
void cmake::InitializeProperties()
{
this->Properties.clear();
this->PropertyDefinitions.clear();
// initialize properties
cmTarget::DefineProperties(this);
cmMakefile::DefineProperties(this);
}
void cmake::CleanupCommandsAndMacros() void cmake::CleanupCommandsAndMacros()
{ {
this->InitializeProperties(); this->State->Initialize();
std::vector<cmCommand*> commands; this->State->RemoveUserDefinedCommands();
for(RegisteredCommandsMap::iterator j = this->Commands.begin();
j != this->Commands.end(); ++j)
{
if ( !j->second->IsA("cmMacroHelperCommand") &&
!j->second->IsA("cmFunctionHelperCommand"))
{
commands.push_back(j->second);
}
else
{
delete j->second;
}
}
this->Commands.clear();
std::vector<cmCommand*>::iterator it;
for ( it = commands.begin(); it != commands.end();
++ it )
{
this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it;
}
}
bool cmake::CommandExists(const std::string& name) const
{
return this->GetCommand(name) ? true : false;
}
cmCommand *cmake::GetCommand(const std::string& name) const
{
cmCommand* command = 0;
std::string sName = cmSystemTools::LowerCase(name);
RegisteredCommandsMap::const_iterator pos = this->Commands.find(sName);
if (pos != this->Commands.end())
{
command = (*pos).second;
}
return command;
}
void cmake::RenameCommand(const std::string& oldName,
const std::string& newName)
{
// if the command already exists, free the old one
std::string sOldName = cmSystemTools::LowerCase(oldName);
RegisteredCommandsMap::iterator pos = this->Commands.find(sOldName);
if ( pos == this->Commands.end() )
{
return;
}
std::string sNewName = cmSystemTools::LowerCase(newName);
cmCommand* cmd = pos->second;
pos = this->Commands.find(sNewName);
if (pos != this->Commands.end())
{
delete pos->second;
this->Commands.erase(pos);
}
this->Commands.insert(std::make_pair(sNewName, cmd));
pos = this->Commands.find(sOldName);
this->Commands.erase(pos);
}
void cmake::RemoveCommand(const std::string& name)
{
std::string sName = cmSystemTools::LowerCase(name);
RegisteredCommandsMap::iterator pos = this->Commands.find(sName);
if ( pos != this->Commands.end() )
{
delete pos->second;
this->Commands.erase(pos);
}
}
void cmake::AddCommand(cmCommand* command)
{
std::string name = cmSystemTools::LowerCase(command->GetName());
// if the command already exists, free the old one
RegisteredCommandsMap::iterator pos = this->Commands.find(name);
if (pos != this->Commands.end())
{
delete pos->second;
this->Commands.erase(pos);
}
this->Commands.insert(std::make_pair(name, command));
}
void cmake::RemoveUnscriptableCommands()
{
std::vector<std::string> unscriptableCommands;
for (cmake::RegisteredCommandsMap::const_iterator
pos = this->Commands.begin();
pos != this->Commands.end();
++pos)
{
if (!pos->second->IsScriptable())
{
unscriptableCommands.push_back(pos->first);
}
}
for(std::vector<std::string>::const_iterator it=unscriptableCommands.begin();
it != unscriptableCommands.end();
++it)
{
this->RemoveCommand(*it);
}
} }
// Parse the args // Parse the args
@ -1274,8 +1152,9 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
std::vector<std::string> argsSplit; std::vector<std::string> argsSplit;
cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true); cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
// erase the property to avoid infinite recursion // erase the property to avoid infinite recursion
this->SetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); this->State
if(this->GetIsInTryCompile()) ->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
if(this->State->GetIsInTryCompile())
{ {
return 0; return 0;
} }
@ -1351,8 +1230,8 @@ int cmake::Configure()
} }
} }
int ret = this->ActualConfigure(); int ret = this->ActualConfigure();
const char* delCacheVars = const char* delCacheVars = this->State
this->GetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
if(delCacheVars && delCacheVars[0] != 0) if(delCacheVars && delCacheVars[0] != 0)
{ {
return this->HandleDeleteCacheVariables(delCacheVars); return this->HandleDeleteCacheVariables(delCacheVars);
@ -1558,7 +1437,7 @@ int cmake::ActualConfigure()
// reset any system configuration information, except for when we are // reset any system configuration information, except for when we are
// InTryCompile. With TryCompile the system info is taken from the parent's // InTryCompile. With TryCompile the system info is taken from the parent's
// info to save time // info to save time
if (!this->InTryCompile) if (!this->State->GetIsInTryCompile())
{ {
this->GlobalGenerator->ClearEnabledLanguages(); this->GlobalGenerator->ClearEnabledLanguages();
@ -1627,7 +1506,7 @@ int cmake::ActualConfigure()
cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
if (mf->IsOn("CTEST_USE_LAUNCHERS") if (mf->IsOn("CTEST_USE_LAUNCHERS")
&& !this->GetProperty("RULE_LAUNCH_COMPILE", cmProperty::GLOBAL)) && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE"))
{ {
cmSystemTools::Error("CTEST_USE_LAUNCHERS is enabled, but the " cmSystemTools::Error("CTEST_USE_LAUNCHERS is enabled, but the "
"RULE_LAUNCH_COMPILE global property is not defined.\n" "RULE_LAUNCH_COMPILE global property is not defined.\n"
@ -1845,7 +1724,7 @@ void cmake::AddDefaultCommands()
for(std::vector<cmCommand*>::iterator i = commands.begin(); for(std::vector<cmCommand*>::iterator i = commands.begin();
i != commands.end(); ++i) i != commands.end(); ++i)
{ {
this->AddCommand(*i); this->State->AddCommand(*i);
} }
} }
@ -1961,7 +1840,7 @@ void cmake::SetProgressCallback(ProgressCallbackType f, void *cd)
void cmake::UpdateProgress(const char *msg, float prog) void cmake::UpdateProgress(const char *msg, float prog)
{ {
if(this->ProgressCallback && !this->InTryCompile) if(this->ProgressCallback && !this->State->GetIsInTryCompile())
{ {
(*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData); (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData);
return; return;
@ -1970,12 +1849,12 @@ void cmake::UpdateProgress(const char *msg, float prog)
bool cmake::GetIsInTryCompile() const bool cmake::GetIsInTryCompile() const
{ {
return this->InTryCompile; return this->State->GetIsInTryCompile();
} }
void cmake::SetIsInTryCompile(bool b) void cmake::SetIsInTryCompile(bool b)
{ {
this->InTryCompile = b; this->State->SetIsInTryCompile(b);
} }
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
@ -2298,114 +2177,25 @@ void cmake::GenerateGraphViz(const char* fileName) const
#endif #endif
} }
void cmake::DefineProperty(const std::string& name,
cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
{
this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
FullDescription,
chained);
}
cmPropertyDefinition *cmake
::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
{
return &(this->PropertyDefinitions[scope][name]);
}
return 0;
}
bool cmake::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
bool cmake::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}
void cmake::SetProperty(const std::string& prop, const char* value) void cmake::SetProperty(const std::string& prop, const char* value)
{ {
this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); this->State->SetGlobalProperty(prop, value);
} }
void cmake::AppendProperty(const std::string& prop, void cmake::AppendProperty(const std::string& prop,
const char* value, bool asString) const char* value, bool asString)
{ {
this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); this->State->AppendGlobalProperty(prop, value, asString);
} }
const char *cmake::GetProperty(const std::string& prop) const char *cmake::GetProperty(const std::string& prop)
{ {
return this->GetProperty(prop, cmProperty::GLOBAL); return this->State->GetGlobalProperty(prop);
}
const char *cmake::GetProperty(const std::string& prop,
cmProperty::ScopeType scope)
{
// watch for special properties
std::string output = "";
if ( prop == "CACHE_VARIABLES" )
{
std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
this->SetProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
}
else if ( prop == "COMMANDS" )
{
cmake::RegisteredCommandsMap::iterator cmds
= this->Commands.begin();
for (unsigned int cc=0 ; cmds != this->Commands.end(); ++ cmds )
{
if ( cc > 0 )
{
output += ";";
}
output += cmds->first.c_str();
cc++;
}
this->SetProperty("COMMANDS",output.c_str());
}
else if ( prop == "IN_TRY_COMPILE" )
{
this->SetProperty("IN_TRY_COMPILE",
this->GetIsInTryCompile()? "1":"0");
}
else if ( prop == "ENABLED_LANGUAGES" )
{
std::string lang;
if(this->GlobalGenerator)
{
std::vector<std::string> enLangs;
this->GlobalGenerator->GetEnabledLanguages(enLangs);
lang = cmJoin(enLangs, ";");
}
this->SetProperty("ENABLED_LANGUAGES", lang.c_str());
}
#define STRING_LIST_ELEMENT(F) ";" #F
if (prop == "CMAKE_C_KNOWN_FEATURES")
{
return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
}
if (prop == "CMAKE_CXX_KNOWN_FEATURES")
{
return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
}
#undef STRING_LIST_ELEMENT
bool dummy = false;
return this->Properties.GetPropertyValue(prop, scope, dummy);
} }
bool cmake::GetPropertyAsBool(const std::string& prop) bool cmake::GetPropertyAsBool(const std::string& prop)
{ {
return cmSystemTools::IsOn(this->GetProperty(prop)); return this->State->GetGlobalPropertyAsBool(prop);
} }
cmInstalledFile *cmake::GetOrCreateInstalledFile( cmInstalledFile *cmake::GetOrCreateInstalledFile(
@ -2801,7 +2591,8 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
std::vector<std::string> cmake::GetDebugConfigs() std::vector<std::string> cmake::GetDebugConfigs()
{ {
std::vector<std::string> configs; std::vector<std::string> configs;
if(const char* config_list = this->GetProperty("DEBUG_CONFIGURATIONS")) if(const char* config_list =
this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS"))
{ {
// Expand the specified list and convert to upper-case. // Expand the specified list and convert to upper-case.
cmSystemTools::ExpandListArgument(config_list, configs); cmSystemTools::ExpandListArgument(config_list, configs);

View File

@ -15,8 +15,6 @@
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmPropertyDefinitionMap.h"
#include "cmPropertyMap.h"
#include "cmInstalledFile.h" #include "cmInstalledFile.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmState.h" #include "cmState.h"
@ -25,7 +23,6 @@ class cmGlobalGeneratorFactory;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmLocalGenerator; class cmLocalGenerator;
class cmMakefile; class cmMakefile;
class cmCommand;
class cmVariableWatch; class cmVariableWatch;
class cmFileTimeComparison; class cmFileTimeComparison;
class cmExternalMakefileProjectGenerator; class cmExternalMakefileProjectGenerator;
@ -94,7 +91,6 @@ class cmake
*/ */
FIND_PACKAGE_MODE FIND_PACKAGE_MODE
}; };
typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
typedef std::map<std::string, cmInstalledFile> InstalledFilesMap; typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
/// Default constructor /// Default constructor
@ -218,22 +214,6 @@ class cmake
*/ */
int GetSystemInformation(std::vector<std::string>&); int GetSystemInformation(std::vector<std::string>&);
/**
* Add a command to this cmake instance
*/
void AddCommand(cmCommand* );
void RenameCommand(const std::string& oldName, const std::string& newName);
void RemoveCommand(const std::string& name);
void RemoveUnscriptableCommands();
/**
* Get a command by its name
*/
cmCommand *GetCommand(const std::string& name) const;
/** Check if a command exists. */
bool CommandExists(const std::string& name) const;
///! Parse command line arguments ///! Parse command line arguments
void SetArgs(const std::vector<std::string>&, void SetArgs(const std::vector<std::string>&,
bool directoriesSetBefore = false); bool directoriesSetBefore = false);
@ -272,8 +252,6 @@ class cmake
void AppendProperty(const std::string& prop, void AppendProperty(const std::string& prop,
const char *value,bool asString=false); const char *value,bool asString=false);
const char *GetProperty(const std::string& prop); const char *GetProperty(const std::string& prop);
const char *GetProperty(const std::string& prop,
cmProperty::ScopeType scope);
bool GetPropertyAsBool(const std::string& prop); bool GetPropertyAsBool(const std::string& prop);
///! Get or create an cmInstalledFile instance and return a pointer to it ///! Get or create an cmInstalledFile instance and return a pointer to it
@ -323,20 +301,6 @@ class cmake
void MarkCliAsUsed(const std::string& variable); void MarkCliAsUsed(const std::string& variable);
// Define a property
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
(const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
/** Get the list of configurations (in upper case) considered to be /** Get the list of configurations (in upper case) considered to be
debugging configurations.*/ debugging configurations.*/
std::vector<std::string> GetDebugConfigs(); std::vector<std::string> GetDebugConfigs();
@ -371,17 +335,12 @@ protected:
void RunCheckForUnusedVariables(); void RunCheckForUnusedVariables();
void InitializeProperties(); void InitializeProperties();
int HandleDeleteCacheVariables(const std::string& var); int HandleDeleteCacheVariables(const std::string& var);
cmPropertyMap Properties;
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>
PropertyDefinitions;
typedef typedef
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
typedef std::map<std::string, typedef std::map<std::string,
CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap; CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector; typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
RegisteredCommandsMap Commands;
RegisteredGeneratorsVector Generators; RegisteredGeneratorsVector Generators;
RegisteredExtraGeneratorsMap ExtraGenerators; RegisteredExtraGeneratorsMap ExtraGenerators;
void AddDefaultCommands(); void AddDefaultCommands();