[cmake-commits] king committed cmLocalGenerator.cxx 1.244 1.245 cmLocalGenerator.h 1.90 1.91 cmStandardIncludes.h 1.70 1.71

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Dec 28 23:07:16 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv27097/Source

Modified Files:
	cmLocalGenerator.cxx cmLocalGenerator.h cmStandardIncludes.h 
Log Message:
ENH: Added method cmLocalGenerator::GetBackwardsCompatibility to reduce parsing of CMAKE_BACKWARDS_COMPATIBILITY variable.  Add cmLocalGenerator::NeedBackwardsCompatibility to simplify checks for compatibility requirements.


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -d -r1.244 -r1.245
--- cmLocalGenerator.cxx	20 Dec 2007 14:27:59 -0000	1.244
+++ cmLocalGenerator.cxx	29 Dec 2007 04:07:14 -0000	1.245
@@ -56,6 +56,8 @@
   this->IsMakefileGenerator = false;
   this->RelativePathsConfigured = false;
   this->PathConversionsSetup = false;
+  this->BackwardsCompatibility = 0;
+  this->BackwardsCompatibilityFinal = false;
 }
 
 cmLocalGenerator::~cmLocalGenerator()
@@ -2860,3 +2862,42 @@
   cmSystemTools::Error("GetTargetObjectFileDirectories"
                        " called on cmLocalGenerator");
 }
+
+//----------------------------------------------------------------------------
+unsigned int cmLocalGenerator::GetBackwardsCompatibility()
+{
+  // The computed version may change until the project is fully
+  // configured.
+  if(!this->BackwardsCompatibilityFinal)
+    {
+    unsigned int major = 0;
+    unsigned int minor = 0;
+    unsigned int patch = 0;
+    if(const char* value
+       = this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
+      {
+      switch(sscanf(value, "%u.%u.%u", &major, &minor, &patch))
+        {
+        case 2: patch = 0; break;
+        case 1: minor = 0; patch = 0; break;
+        default: break;
+        }
+      }
+    this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch);
+    this->BackwardsCompatibilityFinal = this->Configured;
+    }
+
+  return this->BackwardsCompatibility;
+}
+
+//----------------------------------------------------------------------------
+bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major,
+                                                  unsigned int minor,
+                                                  unsigned int patch)
+{
+  // Compatibility is needed if CMAKE_BACKWARDS_COMPATIBILITY is set
+  // equal to or lower than the given version.
+  unsigned int actual_compat = this->GetBackwardsCompatibility();
+  return (actual_compat &&
+          actual_compat <= CMake_VERSION_ENCODE(major, minor, patch));
+}

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- cmLocalGenerator.h	19 Dec 2007 22:15:41 -0000	1.90
+++ cmLocalGenerator.h	29 Dec 2007 04:07:14 -0000	1.91
@@ -251,6 +251,24 @@
   
   bool IsChrpathAvailable(const cmTarget& target);
 
+  /**
+   * Get the level of backwards compatibility requested by the project
+   * in this directory.  This is the value of the CMake variable
+   * CMAKE_BACKWARDS_COMPATIBILITY whose format is
+   * "major.minor[.patch]".  The returned integer is encoded as
+   *
+   *   CMake_VERSION_ENCODE(major, minor, patch)
+   *
+   * and is monotonically increasing with the CMake version.
+   */
+  unsigned int GetBackwardsCompatibility();
+
+  /**
+   * Test whether compatibility is set to a given version or lower.
+   */
+  bool NeedBackwardsCompatibility(unsigned int major,
+                                  unsigned int minor,
+                                  unsigned int patch = 0xFFu);
 protected:
 
   /** Construct a comment for a custom command.  */
@@ -343,6 +361,9 @@
   std::string RelativePathTopBinary;
   bool RelativePathsConfigured;
   bool PathConversionsSetup;
+
+  unsigned int BackwardsCompatibility;
+  bool BackwardsCompatibilityFinal;
 };
 
 #endif

Index: cmStandardIncludes.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmStandardIncludes.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- cmStandardIncludes.h	22 Oct 2007 16:48:39 -0000	1.70
+++ cmStandardIncludes.h	29 Dec 2007 04:07:14 -0000	1.71
@@ -38,6 +38,9 @@
   CMAKE_TO_STRING(CMake_VERSION_MINOR) "." \
   CMAKE_TO_STRING(CMake_VERSION_PATCH)
 
+#define CMake_VERSION_ENCODE(major, minor, patch) \
+  ((major)*0x10000u + (minor)*0x100u + (patch))
+
 #ifdef _MSC_VER
 #pragma warning ( disable : 4786 )
 #pragma warning ( disable : 4503 )



More information about the Cmake-commits mailing list