[Cmake-commits] [cmake-commits] alex committed cmFindPackageCommand.h 1.22 1.23 cmFindPackageCommand.cxx 1.41 1.42

cmake-commits at cmake.org cmake-commits at cmake.org
Sat Sep 6 19:10:04 EDT 2008


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

Modified Files:
	cmFindPackageCommand.h cmFindPackageCommand.cxx 
Log Message:
ENH: provide the xxx_FIND_QUIETLY, xxx_FIND_REQUIRED and xxx_FIND_VERSION_ variables
also in Config mode, so the xxxConfig.cmake files can e.g. test the QUIETLY
parameter and print something or not

Alex


Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C 2 -d -r1.22 -r1.23
*** cmFindPackageCommand.h	12 Aug 2008 23:01:04 -0000	1.22
--- cmFindPackageCommand.h	6 Sep 2008 23:10:02 -0000	1.23
***************
*** 74,77 ****
--- 74,78 ----
    void AppendSuccessInformation();
    void AppendToProperty(const char* propertyName);
+   bool SetModuleVariables(const std::string& components);
    bool FindModule(bool& found);
    bool HandlePackageMode();

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmFindPackageCommand.cxx	12 Aug 2008 23:01:04 -0000	1.41
--- cmFindPackageCommand.cxx	6 Sep 2008 23:10:02 -0000	1.42
***************
*** 412,416 ****
        // Set a variable telling the find script this component
        // is required.
!       std::string req_var = Name + "_FIND_REQUIRED_" + args[i];
        this->Makefile->AddDefinition(req_var.c_str(), "1");
  
--- 412,416 ----
        // Set a variable telling the find script this component
        // is required.
!       std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
        this->Makefile->AddDefinition(req_var.c_str(), "1");
  
***************
*** 481,487 ****
      }
  
!   // Store the list of components.
!   std::string components_var = Name + "_FIND_COMPONENTS";
!   this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
  
    // See if there is a Find<package>.cmake module.
--- 481,485 ----
      }
  
!   this->SetModuleVariables(components);
  
    // See if there is a Find<package>.cmake module.
***************
*** 534,599 ****
  }
  
  //----------------------------------------------------------------------------
! bool cmFindPackageCommand::FindModule(bool& found)
  {
!   std::string module = "Find";
!   module += this->Name;
!   module += ".cmake";
!   std::string mfile = this->Makefile->GetModulesFile(module.c_str());
!   if ( mfile.size() )
      {
!     if(this->Quiet)
!       {
!       // Tell the module that is about to be read that it should find
!       // quietly.
!       std::string quietly = this->Name;
!       quietly += "_FIND_QUIETLY";
!       this->Makefile->AddDefinition(quietly.c_str(), "1");
!       }
  
!     if(this->Required)
!       {
!       // Tell the module that is about to be read that it should report
!       // a fatal error if the package is not found.
!       std::string req = this->Name;
!       req += "_FIND_REQUIRED";
!       this->Makefile->AddDefinition(req.c_str(), "1");
!       }
  
!     if(!this->Version.empty())
        {
!       // Tell the module that is about to be read what version of the
!       // package has been requested.
!       std::string ver = this->Name;
!       ver += "_FIND_VERSION";
!       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.
!       std::string exact = this->Name;
!       exact += "_FIND_VERSION_EXACT";
!       this->Makefile->AddDefinition(exact.c_str(),
!                                     this->VersionExact? "1":"0");
        }
  
      // Load the module we found.
      found = true;
--- 532,607 ----
  }
  
+ 
  //----------------------------------------------------------------------------
! bool cmFindPackageCommand::SetModuleVariables(const std::string& components)
  {
!   // Store the list of components.
!   std::string components_var = this->Name + "_FIND_COMPONENTS";
!   this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
!    
!   if(this->Quiet)
      {
!     // Tell the module that is about to be read that it should find
!     // quietly.
!     std::string quietly = this->Name;
!     quietly += "_FIND_QUIETLY";
!     this->Makefile->AddDefinition(quietly.c_str(), "1");
!     }
  
!   if(this->Required)
!     {
!     // Tell the module that is about to be read that it should report
!     // a fatal error if the package is not found.
!     std::string req = this->Name;
!     req += "_FIND_REQUIRED";
!     this->Makefile->AddDefinition(req.c_str(), "1");
!     }
  
!   if(!this->Version.empty())
!     {
!     // Tell the module that is about to be read what version of the
!     // package has been requested.
!     std::string ver = this->Name;
!     ver += "_FIND_VERSION";
!     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.
+     std::string exact = this->Name;
+     exact += "_FIND_VERSION_EXACT";
+     this->Makefile->AddDefinition(exact.c_str(),
+                                   this->VersionExact? "1":"0");
+    }
+ }
+ 
+ 
+ //----------------------------------------------------------------------------
+ bool cmFindPackageCommand::FindModule(bool& found)
+ {
+   std::string module = "Find";
+   module += this->Name;
+   module += ".cmake";
+   std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+   if ( mfile.size() )
+     {
      // Load the module we found.
      found = true;



More information about the Cmake-commits mailing list