[cmake-commits] martink committed CMakeLists.txt 1.396 1.397
cmAddCustomTargetCommand.cxx 1.30 1.31 cmBootstrapCommands.cxx
1.26 1.27 cmCommand.h 1.26 1.27 cmIncludeDirectoryCommand.cxx
1.27 1.28 cmMakefile.cxx 1.438 1.439 cmMakefile.h 1.225 1.226
cmake.cxx 1.361 1.362 cmake.h 1.100 1.101
cmake-commits at cmake.org
cmake-commits at cmake.org
Sat Mar 1 15:20:37 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv29280/Source
Modified Files:
CMakeLists.txt cmAddCustomTargetCommand.cxx
cmBootstrapCommands.cxx cmCommand.h
cmIncludeDirectoryCommand.cxx cmMakefile.cxx cmMakefile.h
cmake.cxx cmake.h
Log Message:
ENH: add first cut and policies still need to add the doc support
Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- cmake.h 12 Feb 2008 14:49:42 -0000 1.100
+++ cmake.h 1 Mar 2008 20:20:35 -0000 1.101
@@ -53,6 +53,7 @@
class cmFileTimeComparison;
class cmExternalMakefileProjectGenerator;
class cmDocumentationSection;
+class cmPolicies;
class cmake
{
@@ -238,6 +239,8 @@
///! this is called by generators to update the progress
void UpdateProgress(const char *msg, float prog);
+ ///! get the cmake policies instance
+ cmPolicies *GetPolicies() {return this->Policies;} ;
///! Get the variable watch object
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
@@ -358,6 +361,7 @@
void AddExtraGenerator(const char* name,
CreateExtraGeneratorFunctionType newFunction);
+ cmPolicies *Policies;
cmGlobalGenerator *GlobalGenerator;
cmCacheManager *CacheManager;
std::string cmHomeDirectory;
Index: cmAddCustomTargetCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomTargetCommand.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cmAddCustomTargetCommand.cxx 14 Feb 2008 21:42:29 -0000 1.30
+++ cmAddCustomTargetCommand.cxx 1 Mar 2008 20:20:35 -0000 1.31
@@ -28,27 +28,33 @@
// Check the target name.
if(args[0].find_first_of("/\\") != args[0].npos)
+ {
+ // slashes are not allowed anymore in taret names CMP_0001
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP_0001))
{
- int major = 0;
- int minor = 0;
- if(const char* versionValue =
- this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
- {
- sscanf(versionValue, "%d.%d", &major, &minor);
- }
- if(!major || major > 3 || (major == 2 && minor > 2))
- {
- cmOStringStream e;
- e << "called with invalid target name \"" << args[0]
- << "\". Target names may not contain a slash. "
- << "Use ADD_CUSTOM_COMMAND to generate files. "
- << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 "
- << "or lower to skip this check.";
- this->SetError(e.str().c_str());
- return false;
- }
+ case cmPolicies::WARN:
+ cmSystemTools::Message(
+ this->Makefile->GetPolicies()->GetPolicyWarning
+ (cmPolicies::CMP_0001).c_str(),"Warning");
+ case cmPolicies::OLD:
+// if (this->Makefile->IsBWCompatibilityLessThan(2,2))
+// {
+// break;
+// }
+ case cmPolicies::NEW:
+ this->SetError("You included a / or \\ in your target name and "
+ "this is not allowed according to policy CMP_0001. Run "
+ "cmake --help-policy CMP_0001 for more information.");
+ return false;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ this->SetError(
+ this->Makefile->GetPolicies()->GetRequiredPolicyError
+ (cmPolicies::CMP_0001).c_str());
+ return false;
}
-
+ }
+
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
Index: cmIncludeDirectoryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeDirectoryCommand.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmIncludeDirectoryCommand.cxx 23 Jan 2008 15:27:59 -0000 1.27
+++ cmIncludeDirectoryCommand.cxx 1 Mar 2008 20:20:35 -0000 1.28
@@ -61,7 +61,7 @@
else
{
this->SetError(errorMessage);
- return 0;
+ return false;
}
}
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.361
retrieving revision 1.362
diff -u -d -r1.361 -r1.362
--- cmake.cxx 18 Feb 2008 18:03:40 -0000 1.361
+++ cmake.cxx 1 Mar 2008 20:20:35 -0000 1.362
@@ -143,6 +143,8 @@
this->ClearBuildSystem = false;
this->FileComparison = new cmFileTimeComparison;
+ this->Policies = new cmPolicies();
+
this->Properties.SetCMakeInstance(this);
// initialize properties
@@ -181,7 +183,7 @@
this->ProgressCallback = 0;
this->ProgressCallbackClientData = 0;
this->ScriptMode = false;
-
+
#ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch = new cmVariableWatch;
this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN",
@@ -203,6 +205,7 @@
cmake::~cmake()
{
delete this->CacheManager;
+ delete this->Policies;
if (this->GlobalGenerator)
{
delete this->GlobalGenerator;
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- cmMakefile.h 14 Feb 2008 21:42:29 -0000 1.225
+++ cmMakefile.h 1 Mar 2008 20:20:35 -0000 1.226
@@ -21,6 +21,7 @@
#include "cmData.h"
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
+#include "cmPolicies.h"
#include "cmPropertyMap.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
@@ -322,7 +323,24 @@
const char* regex=0);
#endif
-
+
+ //@{
+ /**
+ * Set, Push, Pop policy values for CMake.
+ */
+ bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
+ bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
+ cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
+ bool PushPolicy();
+ bool PopPolicy();
+ bool SetPolicyVersion(const char *version);
+ //@}
+
+ /**
+ * Get the Policies Instance
+ */
+ cmPolicies *GetPolicies();
+
/**
* Add an auxiliary directory to the build.
*/
@@ -861,6 +879,11 @@
cmTarget* FindBasicTarget(const char* name);
std::vector<cmTarget*> ImportedTargetsOwned;
std::map<cmStdString, cmTarget*> ImportedTargets;
+
+ // stack of policy settings
+ typedef std::map<cmPolicies::PolicyID,
+ cmPolicies::PolicyStatus> PolicyMap;
+ std::vector<PolicyMap> PolicyStack;
};
Index: cmCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCommand.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmCommand.h 23 Jan 2008 15:27:59 -0000 1.26
+++ cmCommand.h 1 Mar 2008 20:20:35 -0000 1.27
@@ -97,14 +97,6 @@
}
/**
- * This determines if the method is deprecated or not.
- */
- virtual bool IsDeprecated(int /*major*/, int /*minor*/)
- {
- return false;
- }
-
- /**
* This determines if usage of the method is discouraged or not.
* This is currently only used for generating the documentation.
*/
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
retrieving revision 1.396
retrieving revision 1.397
diff -u -d -r1.396 -r1.397
--- CMakeLists.txt 27 Feb 2008 21:26:35 -0000 1.396
+++ CMakeLists.txt 1 Mar 2008 20:20:35 -0000 1.397
@@ -184,6 +184,8 @@
cmMakefileUtilityTargetGenerator.cxx
cmOrderDirectories.cxx
cmOrderDirectories.h
+ cmPolicies.h
+ cmPolicies.cxx
cmProperty.cxx
cmProperty.h
cmPropertyDefinition.cxx
Index: cmBootstrapCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmBootstrapCommands.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmBootstrapCommands.cxx 16 Feb 2008 18:05:03 -0000 1.26
+++ cmBootstrapCommands.cxx 1 Mar 2008 20:20:35 -0000 1.27
@@ -30,6 +30,7 @@
#include "cmBreakCommand.cxx"
#include "cmBuildCommand.cxx"
#include "cmCMakeMinimumRequired.cxx"
+#include "cmCMakePolicyCommand.cxx"
#include "cmCommandArgumentsHelper.cxx"
#include "cmConfigureFileCommand.cxx"
#include "cmCoreTryCompile.cxx"
@@ -105,6 +106,7 @@
commands.push_back(new cmBreakCommand);
commands.push_back(new cmBuildCommand);
commands.push_back(new cmCMakeMinimumRequired);
+ commands.push_back(new cmCMakePolicyCommand);
commands.push_back(new cmConfigureFileCommand);
commands.push_back(new cmCreateTestSourceList);
commands.push_back(new cmDefinePropertyCommand);
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.438
retrieving revision 1.439
diff -u -d -r1.438 -r1.439
--- cmMakefile.cxx 29 Feb 2008 17:18:11 -0000 1.438
+++ cmMakefile.cxx 1 Mar 2008 20:20:35 -0000 1.439
@@ -291,24 +291,14 @@
this->GetCMakeInstance()->GetCommand(name.c_str());
if(rm)
{
- const char* versionValue
- = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
- int major = 0;
- int minor = 0;
- if ( versionValue )
- {
- sscanf(versionValue, "%d.%d", &major, &minor);
- }
- if ( rm->IsDeprecated(major, minor) )
- {
- cmOStringStream error;
- error << "Error in cmake code at\n"
- << lff.FilePath << ":" << lff.Line << ":\n"
- << rm->GetError() << std::endl
- << " Called from: " << this->GetListFileStack().c_str();
- cmSystemTools::Error(error.str().c_str());
- return false;
- }
+ // const char* versionValue
+ // = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
+ // int major = 0;
+ // int minor = 0;
+ // if ( versionValue )
+ // {
+ // sscanf(versionValue, "%d.%d", &major, &minor);
+ // }
cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this);
bool keepCommand = false;
@@ -3148,8 +3138,24 @@
msg = e.str();
return false;
}
- else if(!this->NeedBackwardsCompatibility(2, 4))
+ else
{
+ // target names must be globally unique
+ switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
+ {
+ case cmPolicies::WARN:
+ msg = this->GetPolicies()->
+ GetPolicyWarning(cmPolicies::CMP_0002);
+ case cmPolicies::OLD:
+ return true;
+ case cmPolicies::REQUIRED_IF_USED:
+ msg = this->GetPolicies()->
+ GetRequiredPolicyError(cmPolicies::CMP_0002);
+ return false;
+ case cmPolicies::NEW:
+ break;
+ }
+
// The conflict is with a non-imported target.
// Allow this if the user has requested support.
cmake* cm =
@@ -3225,3 +3231,107 @@
}
return true;
}
+
+cmPolicies::PolicyStatus cmMakefile
+::GetPolicyStatus(cmPolicies::PolicyID id)
+{
+ cmPolicies::PolicyStatus status;
+ PolicyMap::iterator mappos;
+ unsigned int vecpos;
+ bool done = false;
+ // check our policy stack first
+ for (vecpos = this->PolicyStack.size(); vecpos >= 0 && !done; vecpos--)
+ {
+ mappos = this->PolicyStack[vecpos].find(id);
+ if (mappos != this->PolicyStack[vecpos].end())
+ {
+ status = mappos->second;
+ done = true;
+ }
+ }
+
+ // if not found then
+ if (!done)
+ {
+ // pass the buck to our parent if we have one
+ if (this->LocalGenerator->GetParent())
+ {
+ cmMakefile *parent =
+ this->LocalGenerator->GetParent()->GetMakefile();
+ return parent->GetPolicyStatus(id);
+ }
+ // otherwise use the default
+ else
+ {
+ status = this->GetPolicies()->GetPolicyStatus(id);
+ }
+ }
+
+ // warn if we see a REQUIRED_IF_USED above a OLD or WARN
+ if (!this->GetPolicies()->IsValidUsedPolicyStatus(id,status))
+ {
+ return cmPolicies::REQUIRED_IF_USED;
+ }
+
+ return status;
+}
+
+bool cmMakefile::SetPolicy(const char *id,
+ cmPolicies::PolicyStatus status)
+{
+ cmPolicies::PolicyID pid;
+ if (!this->GetPolicies()->GetPolicyID(id, /* out */ pid))
+ {
+ cmSystemTools::Error("Invalid policy string used. Invalid string was "
+ , id);
+ return false;
+ }
+ return this->SetPolicy(pid,status);
+}
+
+bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
+ cmPolicies::PolicyStatus status)
+{
+ // setting a REQUIRED_ALWAYS policy to WARN or OLD is an insta error
+ if (this->GetPolicies()->
+ IsValidPolicyStatus(id,status))
+ {
+ this->PolicyStack.back()[id] = status;
+ return true;
+ }
+ return false;
+}
+
+bool cmMakefile::PushPolicy()
+{
+ // Allocate a new stack entry.
+ this->PolicyStack.push_back(PolicyMap());
+ return true;
+}
+
+bool cmMakefile::PopPolicy()
+{
+ if (PolicyStack.size() == 0)
+ {
+ cmSystemTools::Error("Attempt to pop the policy stack past "
+ "it's beginning.");
+ return false;
+ }
+ this->PolicyStack.pop_back();
+ return true;
+}
+
+bool cmMakefile::SetPolicyVersion(const char *version)
+{
+ return this->GetCMakeInstance()->GetPolicies()->
+ ApplyPolicyVersion(this,version);
+}
+
+cmPolicies *cmMakefile::GetPolicies()
+{
+ if (!this->GetCMakeInstance())
+ {
+ return 0;
+ }
+ return this->GetCMakeInstance()->GetPolicies();
+}
More information about the Cmake-commits
mailing list