Răsfoiți Sursa

ENH: Enabling ability for CMAKE_MINIMUM_REQUIRED version to include patch level. Submitted by Alexander Neundorf.

Brad King 20 ani în urmă
părinte
comite
65e2c18d73
3 a modificat fișierele cu 13 adăugiri și 1 ștergeri
  1. 11 1
      Source/cmCMakeMinimumRequired.cxx
  2. 1 0
      Source/cmMakefile.h
  3. 1 0
      Source/cmVersion.h

+ 11 - 1
Source/cmCMakeMinimumRequired.cxx

@@ -30,8 +30,18 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args)
     }
     }
   float version = float(m_Makefile->GetMajorVersion());
   float version = float(m_Makefile->GetMajorVersion());
   version += (float(m_Makefile->GetMinorVersion()) * (float).1);
   version += (float(m_Makefile->GetMinorVersion()) * (float).1);
+  version += (float(m_Makefile->GetPatchVersion()) * (float).01);
   float reqVersion = 0;
   float reqVersion = 0;
-  sscanf(args[1].c_str(), "%f", &reqVersion);
+  int major=0;
+  int minor=0;
+  int patch=0;
+
+  int res=sscanf(args[1].c_str(), "%d.%d.%d", &major, &minor, &patch);
+  if (res==3)
+     reqVersion=float(major)+0.1*float(minor)+0.01*float(patch);
+  else if (res==2)
+     reqVersion=float(major)+0.1*float(minor);
+
   if(reqVersion > version)
   if(reqVersion > version)
     {
     {
     cmOStringStream str;
     cmOStringStream str;

+ 1 - 0
Source/cmMakefile.h

@@ -50,6 +50,7 @@ public:
    */
    */
   static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
   static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
   static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
   static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
+  static unsigned int GetPatchVersion() { return CMake_VERSION_PATCH; }
   static const char* GetReleaseVersion();
   static const char* GetReleaseVersion();
   
   
   /**
   /**

+ 1 - 0
Source/cmVersion.h

@@ -32,6 +32,7 @@ public:
    */
    */
   static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
   static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
   static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
   static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
+  static unsigned int GetPatchVersion() { return CMake_VERSION_PATCH; }
   static std::string GetReleaseVersion();
   static std::string GetReleaseVersion();
   static std::string GetCMakeVersion();
   static std::string GetCMakeVersion();
 };
 };