[Cmake-commits] [cmake-commits] king committed cmFindPackageCommand.cxx 1.44 1.45 cmFindPackageCommand.h 1.24 1.25

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Sep 10 10:11:50 EDT 2008


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

Modified Files:
	cmFindPackageCommand.cxx cmFindPackageCommand.h 
Log Message:
ENH: Improve find_package version numbering

Make the number of version components specified explicitly available.
Set variables for unspecified version components to "0" instead of
leaving them unset.  This simplifies version number handling for find-
and config-modules.  Also support a fourth "tweak" version component
since some packages use them.


Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** cmFindPackageCommand.h	7 Sep 2008 10:52:06 -0000	1.24
--- cmFindPackageCommand.h	10 Sep 2008 14:11:48 -0000	1.25
***************
*** 112,115 ****
--- 112,116 ----
    unsigned int VersionMinor;
    unsigned int VersionPatch;
+   unsigned int VersionTweak;
    unsigned int VersionCount;
    bool VersionExact;
***************
*** 119,122 ****
--- 120,124 ----
    unsigned int VersionFoundMinor;
    unsigned int VersionFoundPatch;
+   unsigned int VersionFoundTweak;
    unsigned int VersionFoundCount;
    bool Quiet;

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.44
retrieving revision 1.45
diff -C 2 -d -r1.44 -r1.45
*** cmFindPackageCommand.cxx	8 Sep 2008 14:08:33 -0000	1.44
--- cmFindPackageCommand.cxx	10 Sep 2008 14:11:47 -0000	1.45
***************
*** 68,71 ****
--- 68,72 ----
    this->VersionMinor = 0;
    this->VersionPatch = 0;
+   this->VersionTweak = 0;
    this->VersionCount = 0;
    this->VersionExact = false;
***************
*** 73,79 ****
    this->VersionFoundMinor = 0;
    this->VersionFoundPatch = 0;
    this->VersionFoundCount = 0;
    this->CommandDocumentation =
!     "  find_package(<package> [major[.minor[.patch]]] [EXACT] [QUIET]\n"
      "               [[REQUIRED|COMPONENTS] [components...]])\n"
      "Finds and loads settings from an external project.  "
--- 74,81 ----
    this->VersionFoundMinor = 0;
    this->VersionFoundPatch = 0;
+   this->VersionFoundTweak = 0;
    this->VersionFoundCount = 0;
    this->CommandDocumentation =
!     "  find_package(<package> [version] [EXACT] [QUIET]\n"
      "               [[REQUIRED|COMPONENTS] [components...]])\n"
      "Finds and loads settings from an external project.  "
***************
*** 87,92 ****
      "REQUIRED option or after the COMPONENTS option if no REQUIRED "
      "option is given.  "
!     "The \"[major[.minor[.patch]]]\" version argument specifies a desired "
!     "version with which the package found should be compatible.  "
      "The EXACT option requests that the version be matched exactly.  "
      "Version support is currently provided only on a package-by-package "
--- 89,94 ----
      "REQUIRED option or after the COMPONENTS option if no REQUIRED "
      "option is given.  "
!     "The [version] argument requests a version with which the package found "
!     "should be compatible (format is major[.minor[.patch[.tweak]]]).  "
      "The EXACT option requests that the version be matched exactly.  "
      "Version support is currently provided only on a package-by-package "
***************
*** 110,114 ****
      "If no module is found the command proceeds to Config mode.\n"
      "The complete Config mode command signature is:\n"
!     "  find_package(<package> [major[.minor[.patch]]] [EXACT] [QUIET]\n"
      "               [[REQUIRED|COMPONENTS] [components...]] [NO_MODULE]\n"
      "               [NAMES name1 [name2 ...]]\n"
--- 112,116 ----
      "If no module is found the command proceeds to Config mode.\n"
      "The complete Config mode command signature is:\n"
!     "  find_package(<package> [version] [EXACT] [QUIET]\n"
      "               [[REQUIRED|COMPONENTS] [components...]] [NO_MODULE]\n"
      "               [NAMES name1 [name2 ...]]\n"
***************
*** 154,160 ****
      "intervention is required."
      "\n"
!     "When the \"[major[.minor[.patch]]]\" version argument is specified "
!     "Config mode will only find a version of the package that claims "
!     "compatibility with the requested version.  "
      "If the EXACT option is given only a version of the package claiming "
      "an exact match of the requested version may be found.  "
--- 156,162 ----
      "intervention is required."
      "\n"
!     "When the [version] argument is given Config mode will only find a "
!     "version of the package that claims compatibility with the requested "
!     "version (format is major[.minor[.patch[.tweak]]]).  "
      "If the EXACT option is given only a version of the package claiming "
      "an exact match of the requested version may be found.  "
***************
*** 174,183 ****
      "  PACKAGE_FIND_NAME          = the <package> name\n"
      "  PACKAGE_FIND_VERSION       = full requested version string\n"
!     "  PACKAGE_FIND_VERSION_MAJOR = requested major version, if any\n"
!     "  PACKAGE_FIND_VERSION_MINOR = requested minor version, if any\n"
!     "  PACKAGE_FIND_VERSION_PATCH = requested patch version, if any\n"
      "The version file checks whether it satisfies the requested version "
      "and sets these variables:\n"
!     "  PACKAGE_VERSION            = package version (major[.minor[.patch]])\n"
      "  PACKAGE_VERSION_EXACT      = true if version is exact match\n"
      "  PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n"
--- 176,187 ----
      "  PACKAGE_FIND_NAME          = the <package> name\n"
      "  PACKAGE_FIND_VERSION       = full requested version string\n"
!     "  PACKAGE_FIND_VERSION_MAJOR = major version if requested, else 0\n"
!     "  PACKAGE_FIND_VERSION_MINOR = minor version if requested, else 0\n"
!     "  PACKAGE_FIND_VERSION_PATCH = patch version if requested, else 0\n"
!     "  PACKAGE_FIND_VERSION_TWEAK = tweak version if requested, else 0\n"
!     "  PACKAGE_FIND_VERSION_COUNT = number of version components, 0 to 4\n"
      "The version file checks whether it satisfies the requested version "
      "and sets these variables:\n"
!     "  PACKAGE_VERSION            = full provided version string\n"
      "  PACKAGE_VERSION_EXACT      = true if version is exact match\n"
      "  PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n"
***************
*** 186,193 ****
      "They are not available after the find_package call returns.  "
      "If the version is acceptable the following variables are set:\n"
!     "  <package>_VERSION       = package version (major[.minor[.patch]])\n"
!     "  <package>_VERSION_MAJOR = major from major[.minor[.patch]], if any\n"
!     "  <package>_VERSION_MINOR = minor from major[.minor[.patch]], if any\n"
!     "  <package>_VERSION_PATCH = patch from major[.minor[.patch]], if any\n"
      "and the corresponding package configuration file is loaded.  "
      "When multiple package configuration files are available whose version "
--- 190,199 ----
      "They are not available after the find_package call returns.  "
      "If the version is acceptable the following variables are set:\n"
!     "  <package>_VERSION       = full provided version string\n"
!     "  <package>_VERSION_MAJOR = major version if provided, else 0\n"
!     "  <package>_VERSION_MINOR = minor version if provided, else 0\n"
!     "  <package>_VERSION_PATCH = patch version if provided, else 0\n"
!     "  <package>_VERSION_TWEAK = tweak version if provided, else 0\n"
!     "  <package>_VERSION_COUNT = number of version components, 0 to 4\n"
      "and the corresponding package configuration file is loaded.  "
      "When multiple package configuration files are available whose version "
***************
*** 470,477 ****
      unsigned int parsed_minor;
      unsigned int parsed_patch;
!     this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u",
!                                 &parsed_major, &parsed_minor, &parsed_patch);
      switch(this->VersionCount)
        {
        case 3: this->VersionPatch = parsed_patch; // no break!
        case 2: this->VersionMinor = parsed_minor; // no break!
--- 476,486 ----
      unsigned int parsed_minor;
      unsigned int parsed_patch;
!     unsigned int parsed_tweak;
!     this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u.%u",
!                                 &parsed_major, &parsed_minor,
!                                 &parsed_patch, &parsed_tweak);
      switch(this->VersionCount)
        {
+       case 4: this->VersionTweak = parsed_tweak; // no break!
        case 3: this->VersionPatch = parsed_patch; // no break!
        case 2: this->VersionMinor = parsed_minor; // no break!
***************
*** 566,588 ****
      this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
      char buf[64];
!     switch(this->VersionCount)
!       {
!       case 3:
!         {
!         sprintf(buf, "%u", this->VersionPatch);
!         this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
!         } // no break
!       case 2:
!         {
!         sprintf(buf, "%u", this->VersionMinor);
!         this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
!         } // no break
!       case 1:
!         {
!         sprintf(buf, "%u", this->VersionMajor);
!         this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
!         } // no break
!       default: break;
!       }
  
      // Tell the module whether an exact version has been requested.
--- 575,588 ----
      this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
      char buf[64];
!     sprintf(buf, "%u", this->VersionMajor);
!     this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
!     sprintf(buf, "%u", this->VersionMinor);
!     this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
!     sprintf(buf, "%u", this->VersionPatch);
!     this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
!     sprintf(buf, "%u", this->VersionTweak);
!     this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf);
!     sprintf(buf, "%u", this->VersionCount);
!     this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf);
  
      // Tell the module whether an exact version has been requested.
***************
*** 1235,1268 ****
    this->Makefile->AddDefinition("PACKAGE_FIND_VERSION",
                                  this->Version.c_str());
!   if(this->VersionCount >= 3)
!     {
!     char buf[64];
!     sprintf(buf, "%u", this->VersionPatch);
!     this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf);
!     }
!   else
!     {
!     this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_PATCH");
!     }
!   if(this->VersionCount >= 2)
!     {
!     char buf[64];
!     sprintf(buf, "%u", this->VersionMinor);
!     this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf);
!     }
!   else
!     {
!     this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_MINOR");
!     }
!   if(this->VersionCount >= 1)
!     {
!     char buf[64];
!     sprintf(buf, "%u", this->VersionMajor);
!     this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf);
!     }
!   else
!     {
!     this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_MAJOR");
!     }
  
    // Load the version check file.
--- 1235,1249 ----
    this->Makefile->AddDefinition("PACKAGE_FIND_VERSION",
                                  this->Version.c_str());
!   char buf[64];
!   sprintf(buf, "%u", this->VersionMajor);
!   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf);
!   sprintf(buf, "%u", this->VersionMinor);
!   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf);
!   sprintf(buf, "%u", this->VersionPatch);
!   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf);
!   sprintf(buf, "%u", this->VersionTweak);
!   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_TWEAK", buf);
!   sprintf(buf, "%u", this->VersionCount);
!   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
  
    // Load the version check file.
***************
*** 1287,1295 ****
        unsigned int parsed_minor;
        unsigned int parsed_patch;
        this->VersionFoundCount =
!         sscanf(this->VersionFound.c_str(), "%u.%u.%u",
!                &parsed_major, &parsed_minor, &parsed_patch);
        switch(this->VersionFoundCount)
          {
          case 3: this->VersionFoundPatch = parsed_patch; // no break!
          case 2: this->VersionFoundMinor = parsed_minor; // no break!
--- 1268,1279 ----
        unsigned int parsed_minor;
        unsigned int parsed_patch;
+       unsigned int parsed_tweak;
        this->VersionFoundCount =
!         sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u",
!                &parsed_major, &parsed_minor,
!                &parsed_patch, &parsed_tweak);
        switch(this->VersionFoundCount)
          {
+         case 4: this->VersionFoundTweak = parsed_tweak; // no break!
          case 3: this->VersionFoundPatch = parsed_patch; // no break!
          case 2: this->VersionFoundMinor = parsed_minor; // no break!
***************
*** 1322,1346 ****
      }
  
!   // Store the portions that could be parsed.
    char buf[64];
!   switch(this->VersionFoundCount)
!     {
!     case 3:
!       {
!       sprintf(buf, "%u", this->VersionFoundPatch);
!       this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
!       } // no break
!     case 2:
!       {
!       sprintf(buf, "%u", this->VersionFoundMinor);
!       this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
!       } // no break
!     case 1:
!       {
!       sprintf(buf, "%u", this->VersionFoundMajor);
!       this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
!       } // no break
!     default: break;
!     }
  }
  
--- 1306,1321 ----
      }
  
!   // Store the version components.
    char buf[64];
!   sprintf(buf, "%u", this->VersionFoundMajor);
!   this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
!   sprintf(buf, "%u", this->VersionFoundMinor);
!   this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
!   sprintf(buf, "%u", this->VersionFoundPatch);
!   this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
!   sprintf(buf, "%u", this->VersionFoundTweak);
!   this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf);
!   sprintf(buf, "%u", this->VersionFoundCount);
!   this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf);
  }
  



More information about the Cmake-commits mailing list