[Cmake-commits] [cmake-commits] alex committed cmExtraEclipseCDT4Generator.h 1.7 1.8 cmExtraEclipseCDT4Generator.cxx 1.20 1.21

cmake-commits at cmake.org cmake-commits at cmake.org
Sun Jan 11 12:18:47 EST 2009


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

Modified Files:
	cmExtraEclipseCDT4Generator.h cmExtraEclipseCDT4Generator.cxx 
Log Message:
ENH: patch from Miguel,
As it is today the generator creates linked resources to
LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH if they are not a
subdirectory of the binary dir, so that the IDE can detect the
Binaries (this was addressed previously as a result of a bug report).

Reduces code redundancy by encapsulating common behaviour for
LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH in AppendLinkedResource.

Addresses the two new variable names for these locations, 
CMAKE_LIBRARY_OUTPUT_DIRECTORY and CMAKE_RUNTIME_OUTPUT_DIRECTORY respectively.

Finally, it is addressing a bug in the current code for relative paths
in these variables. If it is a relative path to the binary dir, the
IsSubdirectory call returns false and so it creates the linked
resource. The created linked resource produces an error in the Eclipse
IDE because the IDE expects it to be a full path. The patch now
addresses this by concatenating the binary dir if it is a relative
path.


Index: cmExtraEclipseCDT4Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExtraEclipseCDT4Generator.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmExtraEclipseCDT4Generator.h	10 Jan 2009 01:35:21 -0000	1.7
--- cmExtraEclipseCDT4Generator.h	11 Jan 2009 17:18:44 -0000	1.8
***************
*** 108,111 ****
--- 108,115 ----
                                      const std::string&     path);
  
+   bool AppendOutLinkedResource(cmGeneratedFileStream& fout,
+                                const std::string&     defname,
+                                const std::string&     altdefname);
+ 
    std::vector<std::string> SrcLinkedResources;
    std::vector<std::string> OutLinkedResources;

Index: cmExtraEclipseCDT4Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExtraEclipseCDT4Generator.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmExtraEclipseCDT4Generator.cxx	10 Jan 2009 01:09:54 -0000	1.20
--- cmExtraEclipseCDT4Generator.cxx	11 Jan 2009 17:18:44 -0000	1.21
***************
*** 381,420 ****
        }
      // for EXECUTABLE_OUTPUT_PATH when not in binary dir
!     std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
!     if (!outputPath.empty() && !cmSystemTools::IsSubDirectory(
!                         outputPath.c_str(), this->HomeOutputDirectory.c_str()))
!       {
!       std::string name = this->GetPathBasename(outputPath);
! 
!       // make sure linked resource name is unique
!       while (this->GlobalGenerator->GetProjectMap().find(name)
!              != this->GlobalGenerator->GetProjectMap().end())
!         {
!         name += "_";
!         }
!         this->AppendLinkedResource(fout, name,
!                                    this->GetEclipsePath(outputPath));
!         this->OutLinkedResources.push_back(name);
!       }
      // for LIBRARY_OUTPUT_PATH when not in binary dir
!     if (outputPath != mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH"))
!       {
!       outputPath = mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
!       if (!outputPath.empty() && !cmSystemTools::IsSubDirectory(
!                         outputPath.c_str(), this->HomeOutputDirectory.c_str()))
!         {
!         std::string name = this->GetPathBasename(outputPath);
  
-         // make sure linked resource name is unique
-         while (this->GlobalGenerator->GetProjectMap().find(name)
-                != this->GlobalGenerator->GetProjectMap().end())
-           {
-           name += "_";
-           }
-         this->AppendLinkedResource(fout, name,
-                                    this->GetEclipsePath(outputPath));
-         this->OutLinkedResources.push_back(name);
-         }
-       }
      fout << "\t</linkedResources>\n";
      }
--- 381,392 ----
        }
      // for EXECUTABLE_OUTPUT_PATH when not in binary dir
!     this->AppendOutLinkedResource(fout,
!       mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"),
!       mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"));
      // for LIBRARY_OUTPUT_PATH when not in binary dir
!     this->AppendOutLinkedResource(fout,
!       mf->GetSafeDefinition("CMAKE_LIBRARY_OUTPUT_DIRECTORY"),
!       mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH"));
  
      fout << "\t</linkedResources>\n";
      }
***************
*** 937,938 ****
--- 909,958 ----
      ;
  }
+ 
+ bool cmExtraEclipseCDT4Generator
+ ::AppendOutLinkedResource(cmGeneratedFileStream& fout,
+                           const std::string&     defname,
+                           const std::string&     altdefname)
+ {
+   if (defname.empty() && altdefname.empty())
+     {
+     return false;
+     }
+ 
+   std::string outputPath = (defname.empty() ? altdefname : defname);
+ 
+   if (!cmSystemTools::FileIsFullPath(outputPath.c_str()))
+     {
+     outputPath = this->HomeOutputDirectory + "/" + outputPath;
+     }
+   if (cmSystemTools::IsSubDirectory(outputPath.c_str(),
+                                     this->HomeOutputDirectory.c_str()))
+     {
+     return false;
+     }
+ 
+   std::string name = this->GetPathBasename(outputPath);
+ 
+   // make sure linked resource name is unique
+   while (this->GlobalGenerator->GetProjectMap().find(name)
+       != this->GlobalGenerator->GetProjectMap().end())
+     {
+     name += "_";
+     }
+ 
+   if (std::find(this->OutLinkedResources.begin(),
+                 this->OutLinkedResources.end(),
+                 name)
+       != this->OutLinkedResources.end())
+     {
+     return false;
+     }
+   else
+     {
+     this->AppendLinkedResource(fout, name,
+                                this->GetEclipsePath(outputPath));
+     this->OutLinkedResources.push_back(name);
+     return true;
+     }
+ }
+ 



More information about the Cmake-commits mailing list