[Cmake-commits] [cmake-commits] king committed cmGlobalGenerator.cxx 1.250 1.251 cmGlobalGenerator.h 1.118 1.119 cmMakefile.cxx 1.504 1.505

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Feb 27 11:23:16 EST 2009


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

Modified Files:
	cmGlobalGenerator.cxx cmGlobalGenerator.h cmMakefile.cxx 
Log Message:
ENH: Enforce unique binary directories

The second argument of add_subdirectory must name a unique binary
directory or the build files will clobber each other.  This enforces
uniqueness with an error message.


Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -C 2 -d -r1.118 -r1.119
*** cmGlobalGenerator.h	10 Feb 2009 13:50:21 -0000	1.118
--- cmGlobalGenerator.h	27 Feb 2009 16:23:14 -0000	1.119
***************
*** 254,257 ****
--- 254,263 ----
                     std::string const& content);
  
+   /** Return whether the given binary directory is unused.  */
+   bool BinaryDirectoryIsNew(const char* dir)
+     {
+     return this->BinaryDirectories.insert(dir).second;
+     }
+ 
  protected:
    // for a project collect all its targets by following depend
***************
*** 351,354 ****
--- 357,363 ----
    };
    std::map<cmStdString, DirectoryContent> DirectoryContentMap;
+ 
+   // Set of binary directories on disk.
+   std::set<cmStdString> BinaryDirectories;
  };
  

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.250
retrieving revision 1.251
diff -C 2 -d -r1.250 -r1.251
*** cmGlobalGenerator.cxx	12 Feb 2009 18:25:15 -0000	1.250
--- cmGlobalGenerator.cxx	27 Feb 2009 16:23:14 -0000	1.251
***************
*** 733,736 ****
--- 733,737 ----
    this->RuleHashes.clear();
    this->DirectoryContentMap.clear();
+   this->BinaryDirectories.clear();
  
    // start with this directory
***************
*** 739,742 ****
--- 740,744 ----
  
    // set the Start directories
+   cmMakefile* mf = lg->GetMakefile();
    lg->GetMakefile()->SetStartDirectory
      (this->CMakeInstance->GetStartDirectory());
***************
*** 745,748 ****
--- 747,752 ----
    lg->GetMakefile()->MakeStartDirectoriesCurrent();
  
+   this->BinaryDirectories.insert(mf->GetStartOutputDirectory());
+ 
    // now do it
    lg->Configure();

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.504
retrieving revision 1.505
diff -C 2 -d -r1.504 -r1.505
*** cmMakefile.cxx	10 Feb 2009 13:51:13 -0000	1.504
--- cmMakefile.cxx	27 Feb 2009 16:23:14 -0000	1.505
***************
*** 1537,1540 ****
--- 1537,1555 ----
      }
  
+   // Make sure the binary directory is unique.
+   cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
+   if(!gg->BinaryDirectoryIsNew(binPath))
+     {
+     cmOStringStream e;
+     e << "The binary directory\n"
+       << "  " << binPath << "\n"
+       << "is already used to build another source directory, so it cannot "
+       << "be used to build source directory\n"
+       << "  " << srcPath << "\n"
+       << "Specify a unique binary directory name.";
+     this->IssueMessage(cmake::FATAL_ERROR, e.str());
+     return;
+     }
+ 
    // create a new local generator and set its parent
    cmLocalGenerator *lg2 =



More information about the Cmake-commits mailing list