[Cmake-commits] [cmake-commits] king committed cmFindPackageCommand.cxx 1.65 1.66 cmFindPackageCommand.h 1.30 1.31

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Oct 7 14:37:32 EDT 2009


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

Modified Files:
	cmFindPackageCommand.cxx cmFindPackageCommand.h 
Log Message:
Fix find_package() when <pkg>_DIR is wrong

When <pkg>_DIR is set to an incorrect version we search again and store
the result in the variable, even if it is <pkg>_DIR-NOTFOUND.

There was a bug in the case when the new search does not find anything
and the old value came from a cache entry with UNINITALIZED type.  The
command used to try to load a package configuration file from the last
place searched, and would leave the old wrong value in the entry.  This
commit fixes the behavior to avoid trying to load a missing file and to
set the value to <pkg>_DIR-NOTFOUND as expected.


Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -C 2 -d -r1.30 -r1.31
*** cmFindPackageCommand.h	28 Sep 2009 15:42:40 -0000	1.30
--- cmFindPackageCommand.h	7 Oct 2009 18:37:30 -0000	1.31
***************
*** 74,78 ****
    void RestoreFindDefinitions();
    bool HandlePackageMode();
!   void FindConfig();
    bool FindPrefixedConfig();
    bool FindFrameworkConfig();
--- 74,78 ----
    void RestoreFindDefinitions();
    bool HandlePackageMode();
!   bool FindConfig();
    bool FindPrefixedConfig();
    bool FindFrameworkConfig();

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.65
retrieving revision 1.66
diff -C 2 -d -r1.65 -r1.66
*** cmFindPackageCommand.cxx	30 Sep 2009 17:45:13 -0000	1.65
--- cmFindPackageCommand.cxx	7 Oct 2009 18:37:30 -0000	1.66
***************
*** 737,741 ****
  
    // Try to load the config file if the directory is known
!   bool cachedDirectoryOk = false;
    if(!cmSystemTools::IsOff(def))
      {
--- 737,741 ----
  
    // Try to load the config file if the directory is known
!   bool fileFound = false;
    if(!cmSystemTools::IsOff(def))
      {
***************
*** 755,759 ****
        {
        this->FileFound = file;
!       cachedDirectoryOk = true;
        }
      def = this->Makefile->GetDefinition(this->Variable.c_str());
--- 755,759 ----
        {
        this->FileFound = file;
!       fileFound = true;
        }
      def = this->Makefile->GetDefinition(this->Variable.c_str());
***************
*** 761,777 ****
  
    // Search for the config file if it is not already found.
!   if(cmSystemTools::IsOff(def) || !cachedDirectoryOk)
      {
!     this->FindConfig();
      def = this->Makefile->GetDefinition(this->Variable.c_str());
      }
  
    // If the directory for the config file was found, try to read the file.
    bool result = true;
    bool found = false;
!   // in the following test FileFound should never be empty if def is valid
!   // but I don't want to put an assert() in there now, in case this still
!   // makes it into 2.6.3
!   if(!cmSystemTools::IsOff(def) && (!this->FileFound.empty()))
      {
      // Set the version variables before loading the config file.
--- 761,782 ----
  
    // Search for the config file if it is not already found.
!   if(cmSystemTools::IsOff(def) || !fileFound)
      {
!     fileFound = this->FindConfig();
      def = this->Makefile->GetDefinition(this->Variable.c_str());
      }
  
+   // Sanity check.
+   if(fileFound && this->FileFound.empty())
+     {
+     this->Makefile->IssueMessage(
+       cmake::INTERNAL_ERROR, "fileFound is true but FileFound is empty!");
+     fileFound = false;
+     }
+ 
    // If the directory for the config file was found, try to read the file.
    bool result = true;
    bool found = false;
!   if(fileFound)
      {
      // Set the version variables before loading the config file.
***************
*** 887,891 ****
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::FindConfig()
  {
    // Compute the set of search prefixes.
--- 892,896 ----
  
  //----------------------------------------------------------------------------
! bool cmFindPackageCommand::FindConfig()
  {
    // Compute the set of search prefixes.
***************
*** 939,945 ****
    help += this->Name;
    help += ".";
    this->Makefile->AddCacheDefinition(this->Variable.c_str(),
                                       init.c_str(), help.c_str(),
!                                      cmCacheManager::PATH);
  }
  
--- 944,952 ----
    help += this->Name;
    help += ".";
+   // We force the value since we do not get here if it was already set.
    this->Makefile->AddCacheDefinition(this->Variable.c_str(),
                                       init.c_str(), help.c_str(),
!                                      cmCacheManager::PATH, true);
!   return found;
  }
  



More information about the Cmake-commits mailing list