Browse Source

Adding new options to LoadCache.

Berk Geveci 24 years ago
parent
commit
3b9f97f32d
4 changed files with 56 additions and 11 deletions
  1. 15 5
      Source/cmCacheManager.cxx
  2. 2 1
      Source/cmCacheManager.h
  3. 33 3
      Source/cmLoadCacheCommand.cxx
  4. 6 2
      Source/cmLoadCacheCommand.h

+ 15 - 5
Source/cmCacheManager.cxx

@@ -111,12 +111,13 @@ bool cmCacheManager::LoadCache(const char* path,
 			       bool internal)
 {
   std::set<std::string> emptySet;
-  return this->LoadCache(path, internal, emptySet);
+  return this->LoadCache(path, internal, emptySet, emptySet);
 }
 
 bool cmCacheManager::LoadCache(const char* path,
 			       bool internal,
-			       std::set<std::string>& excludes)
+			       std::set<std::string>& excludes,
+			       std::set<std::string>& includes)
 {
   std::string cacheFile = path;
   cacheFile += "/CMakeCache.txt";
@@ -164,8 +165,12 @@ bool cmCacheManager::LoadCache(const char* path,
       if ( excludes.find(entryKey) == excludes.end() )
 	{
 	e.m_Type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
-	// only load internal values if internal is set
-	if (internal || e.m_Type != INTERNAL)
+	// Load internal values if internal is set.
+	// If the entry is not internal to the cache being loaded
+	// or if it is in the list of internal entries to be
+	// imported, load it.
+	if ( internal || (e.m_Type != INTERNAL) || 
+	     (includes.find(entryKey) != includes.end()) )
 	  {
 	  // If we are loading the cache from another project,
 	  // make all loaded entries internal so that it is
@@ -186,7 +191,12 @@ bool cmCacheManager::LoadCache(const char* path,
 	{
 	e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
 	// only load internal values if internal is set
-	if (internal || e.m_Type != INTERNAL)
+	// Load internal values if internal is set.
+	// If the entry is not internal to the cache being loaded
+	// or if it is in the list of internal entries to be
+	// imported, load it.
+	if ( internal || (e.m_Type != INTERNAL) || 
+	     (includes.find(entryKey) != includes.end()) )
 	  {
 	  // If we are loading the cache from another project,
 	  // make all loaded entries internal so that it is

+ 2 - 1
Source/cmCacheManager.h

@@ -79,7 +79,8 @@ public:
   bool LoadCache(const char* path);
   bool LoadCache(const char* path, bool internal);
   bool LoadCache(const char* path, bool internal, 
-		 std::set<std::string>& excludes);
+		 std::set<std::string>& excludes,
+		 std::set<std::string>& includes);
 
   ///! Put cache definitions into makefile
   void DefineCache(cmMakefile*); 

+ 33 - 3
Source/cmLoadCacheCommand.cxx

@@ -24,8 +24,10 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string>& args)
     this->SetError("called with wrong number of arguments.");
     }
   
+  // Cache entries to be excluded from the import list.
+  // If this set is empty, all cache entries are brought in
+  // and they can not be overridden.
   bool excludeFiles=false;
-  unsigned int excludeIndex=0;
   unsigned int i;
   std::set<std::string> excludes;
 
@@ -40,16 +42,44 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string>& args)
       {
       excludeFiles=true;
       }
+    if (excludeFiles && (args[i] == "INCLUDE_INTERNALS"))
+      {
+      break;
+      }
     }
 
+  // Internal cache entries to be imported.
+  // If this set is empty, no internal cache entries are
+  // brought in.
+  bool includeFiles=false;
+  std::set<std::string> includes;
+
   for(i=0; i<args.size(); i++)
     {
-    if (args[i] == "EXCLUDE")
+    if (includeFiles)
+      {
+      m_Makefile->ExpandVariablesInString(args[i]);
+      includes.insert(args[i]);
+      }
+    if (args[i] == "INCLUDE_INTERNALS")
+      {
+      includeFiles=true;
+      }
+    if (includeFiles && (args[i] == "EXCLUDE"))
+      {
+      break;
+      }
+    }
+
+  for(i=0; i<args.size(); i++)
+    {
+    if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS"))
       {
       break;
       }
     m_Makefile->ExpandVariablesInString(args[i]);
-    cmCacheManager::GetInstance()->LoadCache(args[i].c_str(),false,excludes);
+    cmCacheManager::GetInstance()->LoadCache(args[i].c_str(), false,
+					     excludes, includes);
     cmCacheManager::GetInstance()->DefineCache(m_Makefile);
     }
 

+ 6 - 2
Source/cmLoadCacheCommand.h

@@ -88,8 +88,12 @@ public:
   virtual const char* GetFullDocumentation()
     {
     return
-      "LOAD_CACHE(pathToCacheFile)\n"
-      "Load in the values from another cache. This is useful for a project that depends on another project built in a different tree.";
+      "LOAD_CACHE(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...])\n"
+      "Load in the values from another cache. This is useful for a project "
+      "that depends on another project built in a different tree."
+      "EXCLUDE option can be used to provide a list of entries to be included."
+      "INCLUDE_INTERNALS can be used to provide a list of internal entries"
+      "to be included. Normally, no internal entries are brougt in.";
     }
   
   cmTypeMacro(cmLoadCacheCommand, cmCommand);