Pārlūkot izejas kodu

ENH: some code cleanup

Ken Martin 18 gadi atpakaļ
vecāks
revīzija
b99129d2d8

+ 3 - 3
Source/cmAddExecutableCommand.cxx

@@ -31,7 +31,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
   ++s;
   bool use_win32 = false;
   bool use_macbundle = false;
-  bool in_all = true;
+  bool excludeFromAll = false;
   while ( s != args.end() )
     {
     if (*s == "WIN32")
@@ -47,7 +47,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
     else if(*s == "EXCLUDE_FROM_ALL")
       {
       ++s;
-      in_all = false;
+      excludeFromAll = true;
       }
     else
       {
@@ -64,7 +64,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
 
   std::vector<std::string> srclists(s, args.end());
   cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
-                                                in_all);
+                                                excludeFromAll);
   if ( use_win32 )
     {
     tgt->SetProperty("WIN32_EXECUTABLE", "ON");

+ 3 - 3
Source/cmAddLibraryCommand.cxx

@@ -28,7 +28,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
   // otherwise it defaults to static library.
   int shared = 
     !cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"));
-  bool in_all = true;
+  bool excludeFromAll = false;
   
   std::vector<std::string>::const_iterator s = args.begin();
 
@@ -60,7 +60,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
     else if(*s == "EXCLUDE_FROM_ALL")
       {
       ++s;
-      in_all = false;
+      excludeFromAll = true;
       }
     else
       {
@@ -85,7 +85,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
     }
 
   this->Makefile->AddLibrary(this->LibName.c_str(), shared, srclists,
-                             in_all);
+                             excludeFromAll);
   
   return true;
 }

+ 3 - 3
Source/cmAddSubDirectoryCommand.cxx

@@ -30,7 +30,7 @@ bool cmAddSubDirectoryCommand::InitialPass
   std::string srcArg = args[0];
   std::string binArg;
   
-  bool intoplevel = true;
+  bool excludeFromAll = false;
 
   // process the rest of the arguments looking for optional args
   std::vector<std::string>::const_iterator i = args.begin();
@@ -39,7 +39,7 @@ bool cmAddSubDirectoryCommand::InitialPass
     {
     if(*i == "EXCLUDE_FROM_ALL")
       {
-      intoplevel = false;
+      excludeFromAll = true;
       continue;
       }
     else if (!binArg.size())
@@ -122,7 +122,7 @@ bool cmAddSubDirectoryCommand::InitialPass
 
   // Add the subdirectory using the computed full paths.
   this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
-                                  intoplevel, false, true);
+                                  excludeFromAll, false, true);
 
   return true;
 }

+ 3 - 3
Source/cmGlobalGenerator.cxx

@@ -1006,13 +1006,13 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
   cmLocalGenerator* cur = gen->GetParent();
   while(cur && cur != root)
     {
-    if(cur->GetExcludeAll())
+    if(cur->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
       {
       return true;
       }
     cur = cur->GetParent();
     }
-  return gen->GetExcludeAll();
+  return gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL");
 }
 
 
@@ -1359,7 +1359,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
   cmTarget target;
   target.GetProperties().SetCMakeInstance(this->CMakeInstance);
   target.SetType(cmTarget::GLOBAL_TARGET, name);
-  target.SetInAll(false);
+  target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
 
   std::vector<std::string> no_outputs;
   std::vector<std::string> no_depends;

+ 5 - 5
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -229,7 +229,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
     cmLocalGenerator *lg3 = lg;
     while (lg3)
       {
-      if (lg3->GetExcludeAll())
+      if (lg3->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
         {
         exclude = true;
         break;
@@ -478,7 +478,7 @@ cmGlobalUnixMakefileGenerator3
        (l->second.GetType() == cmTarget::UTILITY))
       {
       // Add this to the list of depends rules in this directory.
-      if((!check_all || l->second.IsInAll()) &&
+      if((!check_all || !l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
          (!check_relink || l->second.NeedRelinkBeforeInstall()))
         {
         std::string tname = lg->GetRelativeTargetDirectory(l->second);
@@ -790,7 +790,7 @@ cmGlobalUnixMakefileGenerator3
                           localName.c_str(), depends, commands, true);
         
         // add the all/all dependency
-        if (!exclude && t->second.IsInAll())
+        if (!exclude && !t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
           {
           depends.clear();
           depends.push_back(localName);
@@ -937,7 +937,7 @@ GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg)
            (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
            (t->second.GetType() == cmTarget::UTILITY))
           {
-          if (t->second.IsInAll())
+          if (!t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
             {
             std::vector<int> &progFiles = lg3->ProgressFiles[t->first];
             result += static_cast<unsigned long>(progFiles.size());
@@ -966,7 +966,7 @@ GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg)
            (l->second.GetType() == cmTarget::UTILITY))
           {
           // Add this to the list of depends rules in this directory.
-          if (l->second.IsInAll() && 
+          if (!l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL") && 
               targets.find(&l->second) == targets.end())
             {
             std::deque<cmTarget *> activeTgts;

+ 1 - 1
Source/cmGlobalVisualStudio6Generator.cxx

@@ -247,7 +247,7 @@ void cmGlobalVisualStudio6Generator
             for(cmTargets::iterator al = atgts.begin();
                 al != atgts.end(); ++al)
               {
-              if (al->second.IsInAll())
+              if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
                 {
                 if (al->second.GetType() == cmTarget::UTILITY ||
                     al->second.GetType() == cmTarget::GLOBAL_TARGET)

+ 1 - 1
Source/cmGlobalVisualStudio71Generator.cxx

@@ -109,7 +109,7 @@ void cmGlobalVisualStudio71Generator
             for(cmTargets::iterator al = atgts.begin();
                 al != atgts.end(); ++al)
               {
-              if (al->second.IsInAll())
+              if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
                 {
                 if (al->second.GetType() == cmTarget::UTILITY ||
                     al->second.GetType() == cmTarget::GLOBAL_TARGET)

+ 1 - 1
Source/cmGlobalVisualStudio7Generator.cxx

@@ -339,7 +339,7 @@ void cmGlobalVisualStudio7Generator
             for(cmTargets::iterator al = atgts.begin();
                 al != atgts.end(); ++al)
               {
-              if (al->second.IsInAll())
+              if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
                 {
                 if (al->second.GetType() == cmTarget::UTILITY ||
                     al->second.GetType() == cmTarget::GLOBAL_TARGET)

+ 1 - 1
Source/cmIncludeExternalMSProjectCommand.cxx

@@ -52,7 +52,7 @@ bool cmIncludeExternalMSProjectCommand
     // Create a target instance for this utility.
     cmTarget target;
     target.SetType(cmTarget::UTILITY, utility_name.c_str());
-    target.SetInAll(true);
+    target.SetProperty("EXCLUDE_FROM_ALL","FALSE");
     target.SetMakefile(this->Makefile);
     std::vector<std::string> no_outputs;
     cmCustomCommandLines commandLines;

+ 1 - 1
Source/cmInstallFilesCommand.cxx

@@ -38,7 +38,7 @@ bool cmInstallFilesCommand
   cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
   target.SetType(cmTarget::INSTALL_FILES, this->TargetName.c_str());
   target.SetMakefile(this->Makefile);
-  target.SetInAll(false);
+  target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
   target.SetInstallPath(args[0].c_str());
   
   if((args.size() > 1) && (args[1] == "FILES"))

+ 1 - 1
Source/cmInstallProgramsCommand.cxx

@@ -35,7 +35,7 @@ bool cmInstallProgramsCommand
   cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
   target.SetType(cmTarget::INSTALL_PROGRAMS, this->TargetName.c_str());
   target.SetMakefile(this->Makefile);
-  target.SetInAll(false);
+  target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
   target.SetInstallPath(args[0].c_str());
 
   std::vector<std::string>::const_iterator s = args.begin();

+ 1 - 11
Source/cmLocalGenerator.cxx

@@ -409,7 +409,7 @@ void cmLocalGenerator::GenerateInstallRules()
     for(std::vector<cmLocalGenerator*>::const_iterator
           ci = this->Children.begin(); ci != this->Children.end(); ++ci)
       {
-      if(!(*ci)->GetExcludeAll())
+      if(!(*ci)->GetMakefile()->GetProperty("EXCLUDE_FROM_ALL"))
         {
         std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory();
         cmSystemTools::ConvertToUnixSlashes(odir);
@@ -2610,13 +2610,3 @@ std::string cmLocalGenerator::GetSourceObjectName(cmSourceFile& sf)
 {
   return sf.GetSourceName();
 }
-
-bool cmLocalGenerator::GetExcludeAll()
-{
-  return this->Makefile->GetPropertyAsBool("EXCLUDE_FROM_ALL"); 
-}
-
-void cmLocalGenerator::SetExcludeAll(bool b)
-{
-  this->Makefile->SetProperty("EXCLUDE_FROM_ALL", b?"TRUE":"FALSE");
-}

+ 0 - 4
Source/cmLocalGenerator.h

@@ -110,10 +110,6 @@ public:
    */
   std::string ConvertToOptionallyRelativeOutputPath(const char* remote);
 
-  // flag to determine if this project should be included in a parent project
-  bool GetExcludeAll();
-  void SetExcludeAll(bool b);
-  
   ///! set/get the parent generator 
   cmLocalGenerator* GetParent(){return this->Parent;}
   void SetParent(cmLocalGenerator* g) { this->Parent = g; g->AddChild(this); }

+ 12 - 9
Source/cmMakefile.cxx

@@ -818,7 +818,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
   cmTarget target;
   target.SetMakefile(this);
   target.SetType(cmTarget::UTILITY, utilityName);
-  target.SetInAll(all);
+  target.SetProperty("EXCLUDE_FROM_ALL", (all) ?"FALSE" : "TRUE");
 
   if(!comment)
     {
@@ -1066,7 +1066,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
 }
 
 void cmMakefile::AddSubDirectory(const char* sub, 
-                                 bool topLevel, bool preorder)
+                                 bool excludeFromAll, bool preorder)
 {
   // the source path must be made full if it isn't already
   std::string srcPath = sub;
@@ -1088,12 +1088,12 @@ void cmMakefile::AddSubDirectory(const char* sub,
   
   
   this->AddSubDirectory(srcPath.c_str(), binPath.c_str(), 
-                        topLevel, preorder, false);
+                        excludeFromAll, preorder, false);
 }
 
                         
 void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
-                                 bool topLevel, bool preorder, 
+                                 bool excludeFromAll, bool preorder, 
                                  bool immediate)
 {
   std::vector<cmLocalGenerator *>& children = 
@@ -1120,7 +1120,8 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
   // set the subdirs start dirs
   lg2->GetMakefile()->SetStartDirectory(srcPath);
   lg2->GetMakefile()->SetStartOutputDirectory(binPath);
-  lg2->SetExcludeAll(!topLevel);
+  lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL",
+                                  (excludeFromAll) ? "TRUE" : "FALSE");
   lg2->GetMakefile()->SetPreOrder(preorder);
   
   if (immediate)
@@ -1318,7 +1319,7 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
 
 void cmMakefile::AddLibrary(const char* lname, int shared,
                             const std::vector<std::string> &srcs,
-                            bool in_all)
+                            bool excludeFromAll)
 {
   cmTarget target;
   switch (shared)
@@ -1341,7 +1342,8 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
   // over changes in CMakeLists.txt, making the information stale and
   // hence useless.
   target.ClearDependencyInformation( *this, lname );
-  target.SetInAll(in_all);
+  target.SetProperty("EXCLUDE_FROM_ALL", 
+                     (excludeFromAll) ? "TRUE" : "FALSE");
   target.GetSourceLists() = srcs;
   this->AddGlobalLinkInformation(lname, target);
   cmTargets::iterator it = 
@@ -1351,12 +1353,13 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
 
 cmTarget* cmMakefile::AddExecutable(const char *exeName, 
                                     const std::vector<std::string> &srcs,
-                                    bool in_all)
+                                    bool excludeFromAll)
 {
   cmTarget target;
   target.SetType(cmTarget::EXECUTABLE, exeName);
   target.SetMakefile(this);
-  target.SetInAll(in_all);
+  target.SetProperty("EXCLUDE_FROM_ALL", 
+                     (excludeFromAll) ?"TRUE" : "FALSE");
   target.GetSourceLists() = srcs;
   this->AddGlobalLinkInformation(exeName, target);
   cmTargets::iterator it = 

+ 4 - 4
Source/cmMakefile.h

@@ -170,7 +170,7 @@ public:
    */
   cmTarget* AddExecutable(const char *exename, 
                           const std::vector<std::string> &srcs,
-                          bool in_all = true);
+                          bool excludeFromAll = false);
 
   /**
    * Add a utility to the build.  A utiltity target is a command that
@@ -224,10 +224,10 @@ public:
   /**
    * Add a subdirectory to the build.
    */
-  void AddSubDirectory(const char*, bool includeTopLevel=true, 
+  void AddSubDirectory(const char*, bool excludeFromAll=false, 
                        bool preorder = false);
   void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, 
-                       bool includeTopLevel, bool preorder,
+                       bool excludeFromAll, bool preorder,
                        bool immediate);
 
   /**
@@ -281,7 +281,7 @@ public:
    */
   void AddLibrary(const char *libname, int shared,
                   const std::vector<std::string> &srcs,
-                  bool in_all = true);
+                  bool excludeFromAll = false);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**

+ 4 - 4
Source/cmSubdirCommand.cxx

@@ -25,7 +25,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
     return false;
     }
   bool res = true;
-  bool intoplevel = true;
+  bool excludeFromAll = false;
   bool preorder = false;
 
   for(std::vector<std::string>::const_iterator i = args.begin();
@@ -33,7 +33,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
     {
     if(*i == "EXCLUDE_FROM_ALL")
       {
-      intoplevel = false;
+      excludeFromAll = true;
       continue;
       }
     if(*i == "PREORDER")
@@ -52,7 +52,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
         std::string(this->Makefile->GetCurrentOutputDirectory()) + 
         "/" + i->c_str();
       this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
-                                  intoplevel, preorder, false);
+                                  excludeFromAll, preorder, false);
       }
     // otherwise it is a full path
     else if ( cmSystemTools::FileIsDirectory(i->c_str()) )
@@ -63,7 +63,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
         std::string(this->Makefile->GetCurrentOutputDirectory()) + 
         "/" + cmSystemTools::GetFilenameName(i->c_str());
       this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
-                                  intoplevel, preorder, false);
+                                  excludeFromAll, preorder, false);
       }
     else
       {

+ 0 - 8
Source/cmTarget.h

@@ -57,14 +57,6 @@ public:
   ///! Set/Get the name of the target
   const char* GetName() {return this->Name.c_str();}
 
-  /**
-   * Indicate whether the target is part of the all target
-   */
-  bool IsInAll() { return !this->GetPropertyAsBool("EXCLUDE_FROM_ALL"); }
-  bool GetInAll() { return !this->GetPropertyAsBool("EXCLUDE_FROM_ALL"); }
-  void SetInAll(bool f) { 
-    this->SetProperty("EXCLUDE_FROM_ALL", (f) ?"FALSE" : "TRUE"); }
-
   ///! Set the cmMakefile that owns this target
   void SetMakefile(cmMakefile *mf);
   cmMakefile *GetMakefile() { return this->Makefile;};