[Cmake-commits] [cmake-commits] king committed cmGlobalGenerator.cxx 1.260 1.261 cmGlobalGenerator.h 1.127 1.128 cmGlobalVisualStudio6Generator.cxx 1.81 1.82 cmGlobalVisualStudio7Generator.cxx 1.111 1.112 cmGlobalVisualStudio7Generator.h 1.53 1.54

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Oct 6 13:30:03 EDT 2009


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

Modified Files:
	cmGlobalGenerator.cxx cmGlobalGenerator.h 
	cmGlobalVisualStudio6Generator.cxx 
	cmGlobalVisualStudio7Generator.cxx 
	cmGlobalVisualStudio7Generator.h 
Log Message:
Avoid non-root copies of root-only targets

In cmGlobalGenerator::GetTargetSets we collect targets from all local
generators in a tree or subtree corresponding to a project() command.
Some targets, such as ALL_BUILD, are duplicated in each subdirectory
with a project() command.  For such targets we should keep only the copy
for the top-most (root) local generator.

Previously this filtering was done in each VS IDE generator, but it is
easier to do it in one place when the targets are first encountered.
This also fixes bad ALL_BUILD dependencies generated for VS 7.0 because
the cmGlobalVisualStudio7Generator::WriteTargetDepends method was not
filtering out duplicates.  Now we avoid duplicates from the start.


Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.127
retrieving revision 1.128
diff -C 2 -d -r1.127 -r1.128
*** cmGlobalGenerator.h	1 Oct 2009 14:26:54 -0000	1.127
--- cmGlobalGenerator.h	6 Oct 2009 17:29:59 -0000	1.128
***************
*** 266,269 ****
--- 266,270 ----
                               TargetDependSet& originalTargets,
                               cmLocalGenerator* root, GeneratorVector const&);
+   virtual bool IsRootOnlyTarget(cmTarget* target);
    void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets);
    void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);

Index: cmGlobalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio6Generator.cxx,v
retrieving revision 1.81
retrieving revision 1.82
diff -C 2 -d -r1.81 -r1.82
*** cmGlobalVisualStudio6Generator.cxx	1 Oct 2009 14:26:54 -0000	1.81
--- cmGlobalVisualStudio6Generator.cxx	6 Oct 2009 17:30:00 -0000	1.82
***************
*** 214,238 ****
      else
        {
!       bool skip = false;
!       // if it is a global target or the check build system target
!       // or the all_build target
!       // then only use the one that is for the root
!       if(target->GetType() == cmTarget::GLOBAL_TARGET
!          || !strcmp(target->GetName(), this->GetAllTargetName()))
!         {
!         if(target->GetMakefile() != root->GetMakefile())
!           {
!           skip = true;
!           }
!         }
!       // if not skipping the project then write it into the
!       // solution
!       if(!skip)
!         {
!         std::string dspname = GetVS6TargetName(target->GetName());
!         std::string dir = target->GetMakefile()->GetStartOutputDirectory();
!         dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT);
!         this->WriteProject(fout, dspname.c_str(), dir.c_str(), *target);
!         }
        }
      }
--- 214,221 ----
      else
        {
!       std::string dspname = GetVS6TargetName(target->GetName());
!       std::string dir = target->GetMakefile()->GetStartOutputDirectory();
!       dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT);
!       this->WriteProject(fout, dspname.c_str(), dir.c_str(), *target);
        }
      }

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.260
retrieving revision 1.261
diff -C 2 -d -r1.260 -r1.261
*** cmGlobalGenerator.cxx	1 Oct 2009 14:26:54 -0000	1.260
--- cmGlobalGenerator.cxx	6 Oct 2009 17:29:56 -0000	1.261
***************
*** 1954,1957 ****
--- 1954,1962 ----
        {
        cmTarget* target = &l->second;
+       if(this->IsRootOnlyTarget(target) &&
+          target->GetMakefile() != root->GetMakefile())
+         {
+         continue;
+         }
        // put the target in the set of original targets
        originalTargets.insert(target);
***************
*** 1963,1966 ****
--- 1968,1978 ----
  
  //----------------------------------------------------------------------------
+ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target)
+ {
+   return (target->GetType() == cmTarget::GLOBAL_TARGET ||
+           strcmp(target->GetName(), this->GetAllTargetName()) == 0);
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
                                           TargetDependSet& projectTargets)

Index: cmGlobalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.cxx,v
retrieving revision 1.111
retrieving revision 1.112
diff -C 2 -d -r1.111 -r1.112
*** cmGlobalVisualStudio7Generator.cxx	1 Oct 2009 14:26:54 -0000	1.111
--- cmGlobalVisualStudio7Generator.cxx	6 Oct 2009 17:30:00 -0000	1.112
***************
*** 290,321 ****
      else
        {
!       bool skip = false;
!       // if it is a global target or the check build system target
!       // or the all_build target
!       // then only use the one that is for the root
!       if(target->GetType() == cmTarget::GLOBAL_TARGET
!          || !strcmp(target->GetName(), CMAKE_CHECK_BUILD_SYSTEM_TARGET)
!          || !strcmp(target->GetName(), this->GetAllTargetName()))
          {
!         if(target->GetMakefile() != root->GetMakefile())
!           {
!           skip = true;
!           }
!         }
!       // if not skipping the project then write it into the 
!       // solution
!       if(!skip)
!         { 
!         const char *vcprojName = 
!           target->GetProperty("GENERATOR_FILE_NAME");
!         if(vcprojName)
!           {
!           cmMakefile* tmf = target->GetMakefile();
!           std::string dir = tmf->GetStartOutputDirectory();
!           dir = root->Convert(dir.c_str(), 
!                               cmLocalGenerator::START_OUTPUT);
!           this->WriteProject(fout, vcprojName, dir.c_str(),
!                              *target);
!           }
          }
        }
--- 290,303 ----
      else
        {
!       const char *vcprojName =
!         target->GetProperty("GENERATOR_FILE_NAME");
!       if(vcprojName)
          {
!         cmMakefile* tmf = target->GetMakefile();
!         std::string dir = tmf->GetStartOutputDirectory();
!         dir = root->Convert(dir.c_str(),
!                             cmLocalGenerator::START_OUTPUT);
!         this->WriteProject(fout, vcprojName, dir.c_str(),
!                            *target);
          }
        }
***************
*** 634,637 ****
--- 616,626 ----
  }
  
+ //----------------------------------------------------------------------------
+ bool cmGlobalVisualStudio7Generator::IsRootOnlyTarget(cmTarget* target)
+ {
+   return (this->cmGlobalVisualStudioGenerator::IsRootOnlyTarget(target) ||
+           strcmp(target->GetName(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) == 0);
+ }
+ 
  bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
                                                            cmTarget* target)

Index: cmGlobalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -C 2 -d -r1.53 -r1.54
*** cmGlobalVisualStudio7Generator.h	30 Sep 2009 20:02:58 -0000	1.53
--- cmGlobalVisualStudio7Generator.h	6 Oct 2009 17:30:00 -0000	1.54
***************
*** 134,137 ****
--- 134,138 ----
    std::string ConvertToSolutionPath(const char* path);
  
+   virtual bool IsRootOnlyTarget(cmTarget* target);
    bool IsPartOfDefaultBuild(const char* project,
                              cmTarget* target);



More information about the Cmake-commits mailing list