[cmake-commits] king committed CMakeLists.txt 1.364 1.364.2.1 cmAuxSourceDirectoryCommand.cxx 1.23 1.23.8.1 cmCommands.cxx 1.113 1.113.2.1 cmCreateTestSourceList.cxx 1.42 1.42.8.1 cmFLTKWrapUICommand.cxx 1.36 1.36.2.1 cmGlobalGenerator.cxx 1.184 1.184.2.1 cmGlobalGenerator.h 1.80 1.80.2.1 cmLocalGenerator.cxx 1.227 1.227.2.1 cmLocalGenerator.h 1.82 1.82.2.1 cmLocalVisualStudio7Generator.cxx 1.194 1.194.2.1 cmLocalVisualStudio7Generator.h 1.40 1.40.2.1 cmLocalXCodeGenerator.cxx 1.4 1.4.8.1 cmLocalXCodeGenerator.h 1.3 1.3.8.1 cmMakeDepend.cxx 1.44 1.44.10.1 cmMakefile.cxx 1.397 1.397.2.1 cmMakefile.h 1.206 1.206.2.1 cmMakefileLibraryTargetGenerator.cxx 1.42 1.42.2.1 cmMakefileTargetGenerator.cxx 1.64 1.64.2.1 cmOutputRequiredFilesCommand.cxx 1.14 1.14.8.1 cmQTWrapCPPCommand.cxx 1.24 1.24.2.1 cmQTWrapCPPCommand.h 1.11 1.11.8.1 cmQTWrapUICommand.cxx 1.24 1.24.2.1 cmQTWrapUICommand.h 1.10 1.10.10.1 cmSourceFile.cxx 1.35 1.35.8.1 cmSourceFile.h 1.21 1.21.2.1 cmSourceFileLocation.cxx NONE 1.1.2.1 cmSourceFileLocation.h NONE 1.1.2.1 cmTarget.cxx 1.149 1.149.2.1 cmTarget.h 1.86 1.86.2.1

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jun 11 18:23:36 EDT 2007


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

Modified Files:
      Tag: CMake-SourceFile2-b
	CMakeLists.txt cmAuxSourceDirectoryCommand.cxx cmCommands.cxx 
	cmCreateTestSourceList.cxx cmFLTKWrapUICommand.cxx 
	cmGlobalGenerator.cxx cmGlobalGenerator.h cmLocalGenerator.cxx 
	cmLocalGenerator.h cmLocalVisualStudio7Generator.cxx 
	cmLocalVisualStudio7Generator.h cmLocalXCodeGenerator.cxx 
	cmLocalXCodeGenerator.h cmMakeDepend.cxx cmMakefile.cxx 
	cmMakefile.h cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmOutputRequiredFilesCommand.cxx 
	cmQTWrapCPPCommand.cxx cmQTWrapCPPCommand.h 
	cmQTWrapUICommand.cxx cmQTWrapUICommand.h cmSourceFile.cxx 
	cmSourceFile.h cmTarget.cxx cmTarget.h 
Added Files:
      Tag: CMake-SourceFile2-b
	cmSourceFileLocation.cxx cmSourceFileLocation.h 
Log Message:
ENH: Initial sweep for new-sytle creation of cmSourceFile instances.  Committing on branch CMake-SourceFile2-b.


--- NEW FILE: cmSourceFileLocation.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmSourceFileLocation.cxx,v $
  Language:  C++
  Date:      $Date: 2007/06/11 22:23:34 $
  Version:   $Revision: 1.1.2.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmSourceFileLocation.h"

#include "cmMakefile.h"
#include "cmSystemTools.h"

//----------------------------------------------------------------------------
cmSourceFileLocation
::cmSourceFileLocation(cmMakefile* mf, const char* name): Makefile(mf)
{
  this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name);
  this->AmbiguousExtension = true;
  this->Directory = cmSystemTools::GetFilenamePath(name);
  this->Name = cmSystemTools::GetFilenameName(name);
  this->UpdateExtension(name);
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::Update(const char* name)
{
  if(this->AmbiguousDirectory)
    {
    this->UpdateDirectory(name);
    }
  if(this->AmbiguousExtension)
    {
    this->UpdateExtension(name);
    }
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
{
  if(this->AmbiguousDirectory && !loc.AmbiguousDirectory)
    {
    this->Directory = loc.Directory;
    }
  if(this->AmbiguousExtension && !loc.AmbiguousExtension)
    {
    this->Name = loc.Name;
    }
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseSource()
{
  if(this->AmbiguousDirectory)
    {
    this->Directory =
      cmSystemTools::CollapseFullPath(
        this->Directory.c_str(), this->Makefile->GetCurrentDirectory());
    this->AmbiguousDirectory = false;
    }
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseBinary()
{
  if(this->AmbiguousDirectory)
    {
    this->Directory =
      cmSystemTools::CollapseFullPath(
        this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory());
    this->AmbiguousDirectory = false;
    }
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::UpdateExtension(const char* name)
{
  // Check the extension.
  std::string ext = cmSystemTools::GetFilenameLastExtension(name);
  if(!ext.empty()) { ext = ext.substr(1); }

  // TODO: Let enable-language specify extensions for each language.
  cmMakefile const* mf = this->Makefile;
  const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
  if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
     std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
    {
    // This is a known extension.  Use the given filename with extension.
    this->Name = cmSystemTools::GetFilenameName(name);
    this->AmbiguousExtension = false;
    }
}

//----------------------------------------------------------------------------
void cmSourceFileLocation::UpdateDirectory(const char* name)
{
  // If a full path was given we know the directory.
  if(cmSystemTools::FileIsFullPath(name))
    {
    this->Directory = cmSystemTools::GetFilenamePath(name);
    this->AmbiguousDirectory = false;
    }
}

//----------------------------------------------------------------------------
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
{
  if(this->AmbiguousExtension || loc.AmbiguousExtension)
    {
    // Need to compare without the file extension.
    std::string thisName;
    if(this->AmbiguousExtension)
      {
      thisName = this->Name;
      }
    else
      {
      thisName = cmSystemTools::GetFilenameWithoutLastExtension(this->Name);
      }
    std::string locName;
    if(loc.AmbiguousExtension)
      {
      locName = loc.Name;
      }
    else
      {
      locName = cmSystemTools::GetFilenameWithoutLastExtension(loc.Name);
      }
    if(thisName != locName)
      {
      return false;
      }
    }
  else
    {
    // Compare with extension.
    if(this->Name != loc.Name)
      {
      return false;
      }
    }

  if(!this->AmbiguousDirectory && !loc.AmbiguousDirectory)
    {
    // Both sides have absolute directories.
    if(this->Directory != loc.Directory)
      {
      return false;
      }
    }
  else if(this->AmbiguousDirectory && loc.AmbiguousDirectory &&
          this->Makefile == loc.Makefile)
    {
    // Both sides have directories relative to the same location.
    if(this->Directory != loc.Directory)
      {
      return false;
      }
    }
  else if(this->AmbiguousDirectory && loc.AmbiguousDirectory)
    {
    // Each side has a directory relative to a different location.
    // This can occur when referencing a source file from a different
    // directory.  This is not yet allowed.
    abort();
    }
  else if(this->AmbiguousDirectory)
    {
    // Compare possible directory combinations.
    std::string srcDir =
      cmSystemTools::CollapseFullPath(
        this->Directory.c_str(), this->Makefile->GetCurrentDirectory());
    std::string binDir =
      cmSystemTools::CollapseFullPath(
        this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory());
    if(srcDir != loc.Directory &&
       binDir != loc.Directory)
      {
      return false;
      }
    }
  else if(loc.AmbiguousDirectory)
    {
    // Compare possible directory combinations.
    std::string srcDir =
      cmSystemTools::CollapseFullPath(
        loc.Directory.c_str(), loc.Makefile->GetCurrentDirectory());
    std::string binDir =
      cmSystemTools::CollapseFullPath(
        loc.Directory.c_str(), loc.Makefile->GetCurrentOutputDirectory());
    if(srcDir != this->Directory &&
       binDir != this->Directory)
      {
      return false;
      }
    }

  // File locations match.
  this->Update(loc);
  return true;
}

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.40
retrieving revision 1.40.2.1
diff -u -d -r1.40 -r1.40.2.1
--- cmLocalVisualStudio7Generator.h	11 Jun 2007 16:40:41 -0000	1.40
+++ cmLocalVisualStudio7Generator.h	11 Jun 2007 22:23:34 -0000	1.40.2.1
@@ -62,8 +62,6 @@
   void GetTargetObjectFileDirectories(cmTarget* target,
                                       std::vector<std::string>& 
                                       dirs); 
-  // return the source name for the object file
-  virtual std::string GetSourceObjectName(cmSourceFile& );
 
   void SetExtraFlagTable(cmVS7FlagTable const* table)
     { this->ExtraFlagTable = table; }

Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.194
retrieving revision 1.194.2.1
diff -u -d -r1.194 -r1.194.2.1
--- cmLocalVisualStudio7Generator.cxx	28 May 2007 15:00:26 -0000	1.194
+++ cmLocalVisualStudio7Generator.cxx	11 Jun 2007 22:23:34 -0000	1.194.2.1
@@ -1902,18 +1902,3 @@
   std::cerr << dir << "\n";
   dirs.push_back(dir);
 }
-
-  
-  // return the source name for the object file
-std::string 
-cmLocalVisualStudio7Generator::GetSourceObjectName(cmSourceFile& sf )
-{
-  std::string ret = sf.GetSourceName();
-  std::string::size_type pos = ret.find("/");
-  if(pos == ret.npos)
-    {
-    return ret;
-    }
-  return ret.substr(pos+1);
-}
-  

Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.80
retrieving revision 1.80.2.1
diff -u -d -r1.80 -r1.80.2.1
--- cmGlobalGenerator.h	11 Jun 2007 19:31:42 -0000	1.80
+++ cmGlobalGenerator.h	11 Jun 2007 22:23:34 -0000	1.80.2.1
@@ -146,10 +146,8 @@
   bool IgnoreFile(const char* ext);
   ///! What is the preference for linkers and this language (None or Prefered)
   const char* GetLinkerPreference(const char* lang);
-  ///! What is the output extension for a given language.
-  const char* GetLanguageOutputExtensionForLanguage(const char* lang);
-  ///! What is the output extension for a given source file extension.
-  const char* GetLanguageOutputExtensionFromExtension(const char* lang);
+  ///! What is the object file extension for a given source file?
+  const char* GetLanguageOutputExtension(cmSourceFile const&);
 
   ///! What is the configurations directory variable called?
   virtual const char* GetCMakeCFGInitDirectory()  { return "."; }

--- NEW FILE: cmSourceFileLocation.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmSourceFileLocation.h,v $
  Language:  C++
  Date:      $Date: 2007/06/11 22:23:34 $
  Version:   $Revision: 1.1.2.1 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmSourceFileLocation_h
#define cmSourceFileLocation_h

#include "cmStandardIncludes.h"

class cmMakefile;

/** \class cmSourceFileLocation
 * \brief
 *
 * cmSourceFileLocation
 */
class cmSourceFileLocation
{
public:
  cmSourceFileLocation(cmMakefile* mf, const char* name);
  bool Matches(cmSourceFileLocation const& loc);

  void DirectoryUseSource();
  void DirectoryUseBinary();
  bool DirectoryIsAmbiguous() const { return this->AmbiguousDirectory; }
  bool ExtensionIsAmbiguous() const { return this->AmbiguousExtension; }
  const char* GetDirectory() const { return this->Directory.c_str(); }
  const char* GetName() const { return this->Name.c_str(); }
  cmMakefile* GetMakefile() const { return this->Makefile; }
private:
  cmMakefile* Makefile;
  bool AmbiguousDirectory;
  bool AmbiguousExtension;
  std::string Directory;
  std::string Name;

  void Update(cmSourceFileLocation const& loc);
  void Update(const char* name);
  void UpdateExtension(const char* name);
  void UpdateDirectory(const char* name);
};

#endif

Index: cmQTWrapCPPCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmQTWrapCPPCommand.cxx,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -u -d -r1.24 -r1.24.2.1
--- cmQTWrapCPPCommand.cxx	28 May 2007 14:11:44 -0000	1.24
+++ cmQTWrapCPPCommand.cxx	11 Jun 2007 22:23:34 -0000	1.24.2.1
@@ -24,120 +24,96 @@
     this->SetError("called with incorrect number of arguments");
     return false;
     }
+
+  // This command supports source list inputs for compatibility.
   std::vector<std::string> args;
   this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
 
-  // what is the current source dir
-  std::string cdir = this->Makefile->GetCurrentDirectory();
-
-  // keep the library name
-  this->LibraryName = args[0];
-  this->SourceList = args[1];
-  
-  std::string sourceListValue;
+  // Get the moc executable to run in the custom command.
+  const char* moc_exe =
+    this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
 
-  // was the list already populated
-  const char *def = this->Makefile->GetDefinition(this->SourceList.c_str());  
-  if (def)
-    {
-    sourceListValue = def;
-    }
+  // Get the variable holding the list of sources.
+  std::string const& sourceList = args[1];
+  std::string sourceListValue =
+    this->Makefile->GetSafeDefinition(sourceList.c_str());
 
-  // get the list of classes for this library
+  // Create a rule for all sources listed.
   for(std::vector<std::string>::iterator j = (args.begin() + 2);
       j != args.end(); ++j)
-    {   
+    {
     cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
-    
     // if we should wrap the class
-    if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
+    if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
       {
-      cmSourceFile file;
+      // Compute the name of the file to generate.
+      std::string srcName =
+        cmSystemTools::GetFilenameWithoutLastExtension(*j);
+      std::string newName = this->Makefile->GetCurrentOutputDirectory();
+      newName += "/moc_";
+      newName += srcName;
+      newName += ".cxx";
+      cmSourceFile* sf =
+        this->Makefile->GetOrCreateSource(newName.c_str(), true);
       if (curr)
         {
-        file.SetProperty("ABSTRACT",curr->GetProperty("ABSTRACT"));
+        sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
         }
-      std::string srcName = 
-        cmSystemTools::GetFilenameWithoutLastExtension(*j);
-      std::string newName = "moc_" + srcName;
-      file.SetName(newName.c_str(), 
-                   this->Makefile->GetCurrentOutputDirectory(),
-                   "cxx",false);
+
+      // Compute the name of the header from which to generate the file.
       std::string hname;
-      if ( (*j)[0] == '/' || (*j)[1] == ':' )
+      if(cmSystemTools::FileIsFullPath(j->c_str()))
         {
         hname = *j;
         }
       else
         {
-        if ( curr && curr->GetPropertyAsBool("GENERATED") )
+        if(curr && curr->GetPropertyAsBool("GENERATED"))
           {
-          hname = std::string(this->Makefile->GetCurrentOutputDirectory()) 
-            + "/" + *j;
+          hname = this->Makefile->GetCurrentOutputDirectory();
           }
         else
           {
-          hname = cdir + "/" + *j;
+          hname = this->Makefile->GetCurrentDirectory();
           }
+        hname += "/";
+        hname += *j;
         }
-      this->WrapHeaders.push_back(hname);
-      // add starting depends
-      file.AddDepend(hname.c_str());
-      this->WrapClasses.push_back(file);
-      if (sourceListValue.size() > 0)
+
+      // Append the generated source file to the list.
+      if(!sourceListValue.empty())
         {
         sourceListValue += ";";
         }
-      sourceListValue += newName + ".cxx";
-      }
-    }
-  
-  this->Makefile->AddDefinition(this->SourceList.c_str(), 
-                                sourceListValue.c_str());
-  return true;
-}
-
-void cmQTWrapCPPCommand::FinalPass() 
-{
-
-  // first we add the rules for all the .h to Moc files
-  size_t lastClass = this->WrapClasses.size();
-  std::vector<std::string> depends;
-  const char* moc_exe = 
-    this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
-
-  // wrap all the .h files
-  depends.push_back(moc_exe);
-
-  for(size_t classNum = 0; classNum < lastClass; classNum++)
-    {
-    // Add output to build list
-    this->Makefile->AddSource(this->WrapClasses[classNum]);
-
-    // set up moc command
-    std::string res = this->Makefile->GetCurrentOutputDirectory();
-    res += "/";
-    res += this->WrapClasses[classNum].GetSourceName() + ".cxx";
+      sourceListValue += newName;
 
-    cmCustomCommandLine commandLine;
-    commandLine.push_back(moc_exe);
-    commandLine.push_back("-o");
-    commandLine.push_back(res);
-    commandLine.push_back(this->WrapHeaders[classNum]);
+      // Create the custom command to generate the file.
+      cmCustomCommandLine commandLine;
+      commandLine.push_back(moc_exe);
+      commandLine.push_back("-o");
+      commandLine.push_back(newName);
+      commandLine.push_back(hname);
 
-    cmCustomCommandLines commandLines;
-    commandLines.push_back(commandLine);
+      cmCustomCommandLines commandLines;
+      commandLines.push_back(commandLine);
 
-    std::vector<std::string> realdepends = depends;
-    realdepends.push_back(this->WrapHeaders[classNum]);
+      std::vector<std::string> depends;
+      depends.push_back(moc_exe);
+      depends.push_back(hname);
 
-    const char* no_main_dependency = 0;
-    const char* no_working_dir = 0;
-    this->Makefile->AddCustomCommandToOutput(res.c_str(),
-                                         realdepends,
-                                         no_main_dependency,
-                                         commandLines,
-                                         "QT Wrapped File",
-                                         no_working_dir);
+      const char* no_main_dependency = 0;
+      const char* no_working_dir = 0;
+      this->Makefile->AddCustomCommandToOutput(newName.c_str(),
+                                               depends,
+                                               no_main_dependency,
+                                               commandLines,
+                                               "QT Wrapped File",
+                                               no_working_dir);
+      }
     }
+
+  // Store the final list of source files.
+  this->Makefile->AddDefinition(sourceList.c_str(),
+                                sourceListValue.c_str());
+  return true;
 }

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.42
retrieving revision 1.42.2.1
diff -u -d -r1.42 -r1.42.2.1
--- cmMakefileLibraryTargetGenerator.cxx	4 Jun 2007 21:17:53 -0000	1.42
+++ cmMakefileLibraryTargetGenerator.cxx	11 Jun 2007 22:23:34 -0000	1.42.2.1
@@ -147,13 +147,14 @@
     for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
         i != sources.end(); ++i)
       {
-      if((*i)->GetSourceExtension() == "def")
+      cmSourceFile* sf = *i;
+      if(sf->GetExtension() == "def")
         {
         extraFlags += " ";
         extraFlags += 
           this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
         extraFlags += 
-          this->Convert((*i)->GetFullPath().c_str(),
+          this->Convert(sf->GetFullPath(),
                         cmLocalGenerator::START_OUTPUT,
                         cmLocalGenerator::SHELL);
         }
@@ -290,13 +291,7 @@
     cmCustomCommandLine line;
     cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
     std::string dest = outpath + "Headers/";
-    dest += sf->GetSourceName();
-    std::string ext = sf->GetSourceExtension();
-    if(ext.size())
-      {
-      dest += ".";
-      dest += sf->GetSourceExtension();
-      }
+    dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
     line.push_back("$(CMAKE_COMMAND)");
     line.push_back("-E");
     line.push_back("copy_if_different");
@@ -347,13 +342,7 @@
       continue;
       }
     std::string dest = outpath + "Resources/";
-    dest += sf->GetSourceName();
-    std::string ext = sf->GetSourceExtension();
-    if(ext.size())
-      {
-      dest += ".";
-      dest += sf->GetSourceExtension();
-      }
+    dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
     line.push_back("$(CMAKE_COMMAND)");
     line.push_back("-E");
     line.push_back("copy_if_different");

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.86
retrieving revision 1.86.2.1
diff -u -d -r1.86 -r1.86.2.1
--- cmTarget.h	28 May 2007 14:25:03 -0000	1.86
+++ cmTarget.h	11 Jun 2007 22:23:34 -0000	1.86.2.1
@@ -73,16 +73,6 @@
   std::vector<cmCustomCommand> &GetPostBuildCommands() 
     {return this->PostBuildCommands;}
 
-  /**
-   * Get the list of the source lists used by this target
-   */
-  std::vector<std::string> const& GetSourceLists() {return this->SourceLists;}
-
-  void AddSourceListEntry(const char* src)
-    { this->SourceLists.push_back(src); }
-  void SetSourceList(std::vector<std::string> const& srcs)
-    { this->SourceLists = srcs; }
-
   ///! Return the list of frameworks being linked to this target
   std::vector<std::string> &GetFrameworks() {return this->Frameworks;}
   
@@ -94,6 +84,12 @@
   void AddSourceFile(cmSourceFile* sf) { this->SourceFiles.push_back(sf); }
 
   /**
+   * Add sources to the target.
+   */
+  void AddSources(std::vector<std::string> const& srcs);
+  cmSourceFile* AddSource(const char* src);
+
+  /**
    * Get the list of the source files used by this target
    */
   enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
@@ -149,12 +145,6 @@
   bool GetHaveInstallRule() { return this->HaveInstallRule; }
   void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; }
 
-  /**
-   * Generate the SourceFilesList from the SourceLists. This should only be
-   * done once to be safe.  
-   */
-  void GenerateSourceFilesFromSourceLists(cmMakefile &mf);
-
   /** Add a utility on which this project depends. A utility is an executable
    * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
    * commands. It is not a full path nor does it have an extension.  
@@ -193,7 +183,7 @@
    * Trace through the source files in this target and add al source files
    * that they depend on, used by all generators
    */
-  void TraceVSDependencies(std::string projName, cmMakefile *mf);  
+  void TraceDependencies(const char* vsProjectFile);
 
   ///! Return the prefered linker language for this target
   const char* GetLinkerLanguage(cmGlobalGenerator*);
@@ -302,14 +292,6 @@
                          const LibraryID& lib,
                          const LibraryID& dep);
 
-  /*
-   * Check custom commands for known targets and add a target-level
-   * dependency.
-   */
-  void CheckForTargetsAsCommand(const cmCustomCommand& cc);
-  void CheckForTargetsAsCommand(const std::vector<cmCustomCommand>& commands);
-  
-  
   /**
    * Emits the library \a lib and all its dependencies into link_line.
    * \a emitted keeps track of the libraries that have been emitted to
@@ -379,7 +361,6 @@
   std::vector<cmCustomCommand> PreBuildCommands;
   std::vector<cmCustomCommand> PreLinkCommands;
   std::vector<cmCustomCommand> PostBuildCommands;
-  std::vector<std::string> SourceLists;
   TargetType TargetTypeValue;
   std::vector<cmSourceFile*> SourceFiles;
   LinkLibraryVectorType LinkLibraries;

Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
retrieving revision 1.364
retrieving revision 1.364.2.1
diff -u -d -r1.364 -r1.364.2.1
--- CMakeLists.txt	11 May 2007 13:02:17 -0000	1.364
+++ CMakeLists.txt	11 Jun 2007 22:23:34 -0000	1.364.2.1
@@ -148,6 +148,8 @@
   cmPropertyMap.h
   cmSourceFile.cxx
   cmSourceFile.h
+  cmSourceFileLocation.cxx
+  cmSourceFileLocation.h
   cmSourceGroup.cxx
   cmSourceGroup.h
   cmSystemTools.cxx

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.64
retrieving revision 1.64.2.1
diff -u -d -r1.64 -r1.64.2.1
--- cmMakefileTargetGenerator.cxx	22 May 2007 14:24:59 -0000	1.64
+++ cmMakefileTargetGenerator.cxx	11 Jun 2007 22:23:34 -0000	1.64.2.1
@@ -152,7 +152,7 @@
     else if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY"))
       {
       if(!this->GlobalGenerator->IgnoreFile
-         ((*source)->GetSourceExtension().c_str()))
+         ((*source)->GetExtension().c_str()))
         {
         // Generate this object file's rule file.
         this->WriteObjectRuleFiles(*(*source));
@@ -307,8 +307,7 @@
     {
     cmOStringStream err;
     err << "Warning: Source file \""
-        << source.GetSourceName().c_str() << "."
-        << source.GetSourceExtension().c_str()
+        << source.GetFullPath()
         << "\" is listed multiple times for target \""
         << this->Target->GetName()
         << "\".";

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.149
retrieving revision 1.149.2.1
diff -u -d -r1.149 -r1.149.2.1
--- cmTarget.cxx	28 May 2007 16:05:28 -0000	1.149
+++ cmTarget.cxx	11 Jun 2007 22:23:34 -0000	1.149.2.1
@@ -281,6 +281,7 @@
      "An internal property used by some generators to record the name of "
      "project or dsp file associated with this target.");
 
+#if 0
   cm->DefineProperty
     ("OBJECT_FILES", cmProperty::TARGET, 
      "Used to get the resulting list of object files that make up a "
@@ -289,6 +290,7 @@
      "into another library. It is a read only property.  It "
      "converts the source list for the target into a list of full "
      "paths to object names that will be produced by the target.");
+#endif
 
 #define CM_TARGET_FILE_TYPES_DOC                                            \
      "There are three kinds of target files that may be built: "            \
@@ -414,288 +416,269 @@
     }
 }
 
+//----------------------------------------------------------------------------
+class cmTargetTraceDependencies
+{
+public:
+  cmTargetTraceDependencies(cmTarget* target, const char* vsProjectFile);
+  void Trace();
+private:
+  cmTarget* Target;
+  cmMakefile* Makefile;
+  cmGlobalGenerator* GlobalGenerator;
+  std::queue<cmStdString> DependencyQueue;
+  std::set<cmStdString> DependenciesQueued;
+  std::set<cmSourceFile*> TargetSources;
+
+  void QueueOnce(std::string const& name);
+  void QueueOnce(std::vector<std::string> const& names);
+  void QueueDependencies(cmSourceFile* sf);
+  bool IsUtility(std::string const& dep);
+  void CheckCustomCommand(cmCustomCommand const& cc);
+  void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
+};
 
-void cmTarget::CheckForTargetsAsCommand(const cmCustomCommand& cc)
+//----------------------------------------------------------------------------
+cmTargetTraceDependencies
+::cmTargetTraceDependencies(cmTarget* target, const char* vsProjectFile):
+  Target(target)
 {
-  for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
-      cit != cc.GetCommandLines().end(); ++cit )
+  // Convenience.
+  this->Makefile = this->Target->GetMakefile();
+  this->GlobalGenerator =
+    this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+
+  // Queue all the source files already specified for the target.
+  std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles();
+  for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+      si != sources.end(); ++si)
     {
-    std::string const& command = *cit->begin();
-    // Look for a non-imported target with this name.
-    if(cmTarget* t = this->Makefile->GetLocalGenerator()->
-       GetGlobalGenerator()->FindTarget(0, command.c_str(), false))
+    // Queue the source file itself in case it is generated.
+    this->QueueOnce((*si)->GetFullPath());
+
+    // Queue the dependencies of the source file in case they are
+    // generated.
+    this->QueueDependencies(*si);
+
+    // Track the sources already known to the target.
+    this->TargetSources.insert(*si);
+    }
+
+  // Queue the VS project file to check dependencies on the rule to
+  // generate it.
+  if(vsProjectFile)
+    {
+    this->QueueOnce(vsProjectFile);
+    }
+
+  // Queue pre-build, pre-link, and post-build rule dependencies.
+  this->CheckCustomCommands(this->Target->GetPreBuildCommands());
+  this->CheckCustomCommands(this->Target->GetPreLinkCommands());
+  this->CheckCustomCommands(this->Target->GetPostBuildCommands());
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::Trace()
+{
+  // Process one dependency at a time until the queue is empty.
+  while(!this->DependencyQueue.empty())
+    {
+    // Get the next dependency in from queue.
+    std::string dep = this->DependencyQueue.front();
+    this->DependencyQueue.pop();
+
+    // Check if we know how to generate this dependency.
+    if(cmSourceFile* sf =
+       this->Makefile->GetSourceFileWithOutput(dep.c_str()))
       {
-      if(t->GetType() == cmTarget::EXECUTABLE)
+      // Queue dependencies needed to generate this file.
+      this->QueueDependencies(sf);
+
+      // Make sure this file is in the target.
+      if(this->TargetSources.insert(sf).second)
         {
-        // The command refers to an executable target built in
-        // this project.  Add the target-level dependency to make
-        // sure the executable is up to date before this custom
-        // command possibly runs.
-        this->AddUtility(command.c_str());
+        this->Target->AddSourceFile(sf);
         }
       }
     }
 }
 
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::QueueOnce(std::string const& name)
+{
+  if(this->DependenciesQueued.insert(name).second)
+    {
+    this->DependencyQueue.push(name);
+    }
+}
+
+//----------------------------------------------------------------------------
 void
-cmTarget
-::CheckForTargetsAsCommand(const std::vector<cmCustomCommand>& commands)
+cmTargetTraceDependencies::QueueOnce(std::vector<std::string> const& names)
 {
-  for ( std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
-        cli != commands.end();
-        ++cli )
+  for(std::vector<std::string>::const_iterator i = names.begin();
+      i != names.end(); ++i)
     {
-    this->CheckForTargetsAsCommand(*cli);
+    this->QueueOnce(*i);
     }
 }
 
+//----------------------------------------------------------------------------
+bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
+{
+  // Dependencies on targets (utilities) are supposed to be named by
+  // just the target name.  However for compatibility we support
+  // naming the output file generated by the target (assuming there is
+  // no output-name property which old code would not have set).  In
+  // that case the target name will be the file basename of the
+  // dependency.
+  std::string util = cmSystemTools::GetFilenameName(dep);
+  if(cmSystemTools::GetFilenameLastExtension(util) == ".exe")
+    {
+    util = cmSystemTools::GetFilenameWithoutLastExtension(util);
+    }
 
-void cmTarget::TraceVSDependencies(std::string projFile, 
-                                   cmMakefile *makefile)
-{ 
-  // get the classes from the source lists then add them to the groups
-  std::vector<cmSourceFile*> & classes = this->SourceFiles;
-  // use a deck to keep track of processed source files
-  std::queue<std::string> srcFilesToProcess;
-  std::set<cmStdString> srcFilesQueued;
-  std::string name;
-  std::vector<cmSourceFile*> newClasses;
-  for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); 
-      i != classes.end(); ++i)
+  // Check for a non-imported target with this name.
+  if(cmTarget* t =
+     this->GlobalGenerator->FindTarget(0, util.c_str(), false))
     {
-    name = (*i)->GetSourceName();
-    if ((*i)->GetSourceExtension() != "rule")
-      {
-      name += ".";
-      name += (*i)->GetSourceExtension();
-      }
-    srcFilesToProcess.push(name);
-    srcFilesQueued.insert(name);
-    // does this sourcefile have object depends on it?
-    // If so then add them as well
-    const char* additionalDeps = (*i)->GetProperty("OBJECT_DEPENDS");
-    std::vector<std::string> depends = (*i)->GetDepends();
-    if (additionalDeps || depends.size())
+    // If we find the target and the dep was given as a full path,
+    // then make sure it was not a full path to something else, and
+    // the fact that the name matched a target was just a coincidence.
+    if(cmSystemTools::FileIsFullPath(dep.c_str()))
       {
-      if(additionalDeps)
-        {
-        cmSystemTools::ExpandListArgument(additionalDeps, depends);
-        }
-      for(std::vector<std::string>::iterator id = depends.begin();
-          id != depends.end(); ++id)
+      // This is really only for compatibility so we do not need to
+      // worry about configuration names and output names.
+      std::string tLocation = t->GetLocation(0);
+      tLocation = cmSystemTools::GetFilenamePath(tLocation);
+      std::string depLocation = cmSystemTools::GetFilenamePath(dep);
+      depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
+      tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
+      if(depLocation == tLocation)
         {
-        // if there is a custom rule to generate that dependency
-        // then add it to the list
-        cmSourceFile* outsf = 
-          makefile->GetSourceFileWithOutput(id->c_str());
-        // if a source file was found then add it
-        if (outsf && 
-            (std::find(classes.begin(),classes.end(),outsf) == classes.end())
-            &&
-            (std::find(newClasses.begin(),newClasses.end(),outsf)
-             == newClasses.end()))
-          {
-          // then add the source to this target and add it to the queue
-          newClasses.push_back(outsf);
-          name = outsf->GetSourceName();
-          if (outsf->GetSourceExtension() != "rule")
-            {
-            name += ".";
-            name += outsf->GetSourceExtension();
-            }
-          std::string temp = 
-            cmSystemTools::GetFilenamePath(outsf->GetFullPath());
-          temp += "/";
-          temp += name;
-          // if it hasn't been processed
-          if (srcFilesQueued.find(temp) == srcFilesQueued.end())
-            {
-            srcFilesToProcess.push(temp);
-            srcFilesQueued.insert(temp);
-            }
-          }
+        this->Target->AddUtility(util.c_str());
+        return true;
         }
       }
+    else
+      {
+      // The original name of the dependency was not a full path.  It
+      // must name a target, so add the target-level dependency.
+      this->Target->AddUtility(util.c_str());
+      return true;
+      }
     }
-  for(std::vector<cmSourceFile*>::const_iterator i = newClasses.begin(); 
-      i != newClasses.end(); ++i)
+
+  // The dependency does not name a target built in this project.
+  return false;
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::QueueDependencies(cmSourceFile* sf)
+{
+  // Queue dependency added explicitly by the user.
+  if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS"))
     {
-    classes.push_back(*i);
+    std::vector<std::string> objDeps;
+    cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
+    this->QueueOnce(objDeps);
     }
-  
-  // add in the project file itself
-  if (projFile.size())
+
+  // Queue dependencies added programatically by commands.
+  this->QueueOnce(sf->GetDepends());
+
+  // Queue custom command dependencies.
+  if(cmCustomCommand const* cc = sf->GetCustomCommand())
     {
-    srcFilesToProcess.push(projFile);
-    srcFilesQueued.insert(projFile);
+    this->CheckCustomCommand(*cc);
     }
-  // add in the library depends for custom targets
-  if (this->GetType() == cmTarget::UTILITY || 
-      this->GetType() == cmTarget::GLOBAL_TARGET)
+
+}
+
+//----------------------------------------------------------------------------
+void
+cmTargetTraceDependencies
+::CheckCustomCommand(cmCustomCommand const& cc)
+{
+  // Transform command names that reference targets built in this
+  // project to corresponding target-level dependencies.
+  for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
+      cit != cc.GetCommandLines().end(); ++cit)
     {
-    for (std::vector<cmCustomCommand>::iterator ic = 
-           this->GetPostBuildCommands().begin();
-         ic != this->GetPostBuildCommands().end(); ++ic)
+    std::string const& command = *cit->begin();
+    // Look for a non-imported target with this name.
+    if(cmTarget* t =
+       this->GlobalGenerator->FindTarget(0, command.c_str(), false))
       {
-      cmCustomCommand &c = *ic;
-      for (std::vector<std::string>::const_iterator i 
-             = c.GetDepends().begin(); i != c.GetDepends().end(); ++i)
+      if(t->GetType() == cmTarget::EXECUTABLE)
         {
-        srcFilesToProcess.push(*i);
-        srcFilesQueued.insert(*i);
+        // The command refers to an executable target built in
+        // this project.  Add the target-level dependency to make
+        // sure the executable is up to date before this custom
+        // command possibly runs.
+        this->Target->AddUtility(command.c_str());
         }
       }
     }
 
-  this->CheckForTargetsAsCommand(this->GetPreBuildCommands());
-  this->CheckForTargetsAsCommand(this->GetPreLinkCommands());
-  this->CheckForTargetsAsCommand(this->GetPostBuildCommands());
-
-  while (!srcFilesToProcess.empty())
+  // Queue the custom command dependencies.
+  std::vector<std::string> const& depends = cc.GetDepends();
+  for(std::vector<std::string>::const_iterator di = depends.begin();
+      di != depends.end(); ++di)
     {
-    // is this source the output of a custom command
-    cmSourceFile* outsf = 
-      makefile->GetSourceFileWithOutput(srcFilesToProcess.front().c_str());
-    if (outsf)
+    std::string const& dep = *di;
+    if(!this->IsUtility(dep))
       {
-      // is it not already in the target?
-      if (std::find(classes.begin(),classes.end(),outsf) == classes.end())
-        {
-        // then add the source to this target and add it to the queue
-        classes.push_back(outsf);
-        name = outsf->GetSourceName();
-        if (outsf->GetSourceExtension() != "rule")
-          {
-          name += ".";
-          name += outsf->GetSourceExtension();
-          }
-        std::string temp = 
-          cmSystemTools::GetFilenamePath(outsf->GetFullPath());
-        temp += "/";
-        temp += name;
-        // if it hasn't been processed
-        if (srcFilesQueued.find(temp) == srcFilesQueued.end())
-          {
-          srcFilesToProcess.push(temp);
-          srcFilesQueued.insert(temp);
-          }
-        }
-
-      // Add target-level dependencies for the commands.
-      this->CheckForTargetsAsCommand(*outsf->GetCustomCommand());
-
-      // add its dependencies to the list to check
-      for (unsigned int i = 0; 
-           i < outsf->GetCustomCommand()->GetDepends().size(); 
-           ++i)
-        {
-        const std::string& fullName 
-          = outsf->GetCustomCommand()->GetDepends()[i];
-        std::string dep = cmSystemTools::GetFilenameName(fullName);
-        if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe")
-          {
-          dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
-          }
-        bool isUtility = false;
-        // Check for a non-imported target with this name.
-        if(cmTarget* t =  this->Makefile->GetLocalGenerator()->
-           GetGlobalGenerator()->FindTarget(0, dep.c_str(), false))
-          {
-          // if we find the target and the dep was given as a full
-          // path, then make sure it was not a full path to something
-          // else, and the fact that the name matched a target was 
-          // just a coincident 
-          if(cmSystemTools::FileIsFullPath(fullName.c_str()))
-            {
-            std::string tLocation = t->GetLocation(0);
-            tLocation = cmSystemTools::GetFilenamePath(tLocation);
-            std::string depLocation = cmSystemTools::GetFilenamePath(
-              std::string(fullName));
-            depLocation = 
-              cmSystemTools::CollapseFullPath(depLocation.c_str());
-            tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
-            if(depLocation == tLocation)
-              {
-              isUtility = true;
-              }
-            }
-          // if it was not a full path then it must be a target
-          else
-            {
-            isUtility = true;
-            }
-          }
-        if(isUtility)
-          {
-          // The dependency refers to a target built in this project.
-          // Add the target-level dependency to make sure the target
-          // is up to date before this custom command possibly runs.
-          this->AddUtility(dep.c_str());
-          }
-        else
-          {
-          if (srcFilesQueued.find(outsf->GetCustomCommand()->GetDepends()[i]) 
-          == srcFilesQueued.end())
-            {
-            srcFilesToProcess.push
-              (outsf->GetCustomCommand()->GetDepends()[i]);
-            srcFilesQueued.insert(outsf->GetCustomCommand()->GetDepends()[i]);
-            }
-          }
-        }
-
+      // The dependency does not name a target and may be a file we
+      // know how to generate.  Queue it.
+      this->QueueOnce(dep);
       }
-    // finished with this SF move to the next
-    srcFilesToProcess.pop();
     }
 }
 
-void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
+//----------------------------------------------------------------------------
+void
+cmTargetTraceDependencies
+::CheckCustomCommands(const std::vector<cmCustomCommand>& commands)
 {
-  // only allow this to be called once
-  // there is a lazy evaluation of this in ComputeObjectFiles,
-  // that could break backwards compatibility with projects that
-  // use old style source lists.  
-  if(this->SourceFiles.size() != 0)
+  for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
+      cli != commands.end(); ++cli)
     {
-    return;
+    this->CheckCustomCommand(*cli);
     }
-  // for each src lists add the classes
-  for (std::vector<std::string>::const_iterator s = this->SourceLists.begin();
-       s != this->SourceLists.end(); ++s)
-    {
-    int done = 0;
-    // replace any variables
-    std::string temps = *s;
-    mf.ExpandVariablesInString(temps);
+}
 
-    // Next if one wasn't found then assume it is a single class
-    // check to see if it is an existing source file
-    if (!done)
-      {
-      cmSourceFile* sourceFile = mf.GetSource(temps.c_str());
-      if ( sourceFile )
-        {
-        this->SourceFiles.push_back(sourceFile);
-        done = 1;
-        }
-      }
-      
-    // if we still are not done, try to create the SourceFile structure
-    if (!done)
-      {
-      cmSourceFile file;
-      file.GetProperties().
-        SetCMakeInstance(this->Makefile->GetCMakeInstance());
-      file.SetProperty("ABSTRACT","0");
-      file.SetName(temps.c_str(), mf.GetCurrentDirectory(),
-                   mf.GetSourceExtensions(),
-                   mf.GetHeaderExtensions(), this->Name.c_str());
-      this->SourceFiles.push_back(mf.AddSource(file));
-      }
+//----------------------------------------------------------------------------
+void cmTarget::TraceDependencies(const char* vsProjectFile)
+{
+  // Use a helper object to trace the dependencies.
+  cmTargetTraceDependencies tracer(this, vsProjectFile);
+  tracer.Trace();
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::AddSources(std::vector<std::string> const& srcs)
+{
+  for(std::vector<std::string>::const_iterator i = srcs.begin();
+      i != srcs.end(); ++i)
+    {
+    this->AddSource(i->c_str());
     }
 }
 
+cmSourceFile* cmTarget::AddSource(const char* s)
+{
+  std::string src = s;
+
+  // For backwards compatibility replace varibles in source names.
+  // This should eventually be removed.
+  this->Makefile->ExpandVariablesInString(src);
+
+  cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str());
+  this->AddSourceFile(sf);
+  return sf;
+}
+
 void cmTarget::MergeLinkLibraries( cmMakefile& mf,
                                    const char *selfname,
                                    const LinkLibraryVectorType& libs )
@@ -1328,9 +1311,7 @@
     {
     return;
     }
-
-  // Force the SourceFiles vector to be populated
-  this->GenerateSourceFilesFromSourceLists(*this->Makefile);
+#if 0
   std::vector<std::string> dirs;
   this->Makefile->GetLocalGenerator()->
     GetTargetObjectFileDirectories(this,
@@ -1346,10 +1327,7 @@
         s != this->SourceFiles.end(); ++s)
       {
       cmSourceFile* sf = *s;
-      const char* lang = this->Makefile->GetLocalGenerator()->
-        GetGlobalGenerator()->
-        GetLanguageFromExtension(sf->GetSourceExtension().c_str());
-      if (lang)
+      if(const char* lang = sf->GetLanguage())
         {
         std::string lookupObj = objExtensionLookup1 + lang;
         lookupObj += objExtensionLookup2;
@@ -1371,6 +1349,7 @@
       }
     }
   this->SetProperty("OBJECT_FILES", objectFiles.c_str());
+#endif
 }
 
 
@@ -1487,9 +1466,7 @@
         = this->SourceFiles.begin();
       i != this->SourceFiles.end(); ++i)
     {
-    const char* lang = 
-      gg->GetLanguageFromExtension((*i)->GetSourceExtension().c_str());
-    if(lang)
+    if(const char* lang = (*i)->GetLanguage())
       {
       languages.insert(lang);
       }

Index: cmOutputRequiredFilesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmOutputRequiredFilesCommand.cxx,v
retrieving revision 1.14
retrieving revision 1.14.8.1
diff -u -d -r1.14 -r1.14.8.1
--- cmOutputRequiredFilesCommand.cxx	12 May 2006 17:39:34 -0000	1.14
+++ cmOutputRequiredFilesCommand.cxx	11 Jun 2007 22:23:34 -0000	1.14.8.1
@@ -223,13 +223,6 @@
 
 void cmOutputRequiredFilesCommand::FinalPass()
 {
-  
-  cmTargets &tgts = this->Makefile->GetTargets();
-  for (cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
-    {
-    l->second.GenerateSourceFilesFromSourceLists(*this->Makefile);
-    }
-
   // compute the list of files
   cmLBDepend md;
   md.SetMakefile(this->Makefile);

Index: cmFLTKWrapUICommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFLTKWrapUICommand.cxx,v
retrieving revision 1.36
retrieving revision 1.36.2.1
diff -u -d -r1.36 -r1.36.2.1
--- cmFLTKWrapUICommand.cxx	28 May 2007 14:25:03 -0000	1.36
+++ cmFLTKWrapUICommand.cxx	11 Jun 2007 22:23:34 -0000	1.36.2.1
@@ -53,20 +53,17 @@
     // to generate .cxx and .h files
     if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
       {
-      cmSourceFile header_file;
-      header_file.SetMakefile(this->Makefile);
-      std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*i);
-      const bool headerFileOnly = true;
-      header_file.SetName(srcName.c_str(), 
-                  outputDirectory.c_str(), "h",headerFileOnly);
+      std::string outName = outputDirectory;
+      outName += "/";
+      outName += cmSystemTools::GetFilenameWithoutExtension(*i);
+      std::string hname = outName;
+      hname += ".h";
       std::string origname = cdir + "/" + *i;
-      std::string hname   = header_file.GetFullPath();
       // add starting depends
       std::vector<std::string> depends;
       depends.push_back(origname);
       depends.push_back(fluid_exe);
-      std::string cxxres = outputDirectory.c_str();
-      cxxres += "/" + srcName;
+      std::string cxxres = outName;
       cxxres += ".cxx";
 
       cmCustomCommandLine commandLine;
@@ -123,12 +120,12 @@
   // people should add the srcs to the target themselves, but the old command
   // didn't support that, so check and see if they added the files in and if
   // they didn;t then print a warning and add then anyhow
-  std::vector<std::string> const& srcs = 
-    this->Makefile->GetTargets()[this->Target].GetSourceLists();
+  std::vector<cmSourceFile*> const& srcs = 
+    this->Makefile->GetTargets()[this->Target].GetSourceFiles();
   bool found = false;
   for (unsigned int i = 0; i < srcs.size(); ++i)
     {
-    if (srcs[i] == 
+    if (srcs[i]->GetFullPath() == 
         this->GeneratedSourcesClasses[0]->GetFullPath())
       {
       found = true;

Index: cmLocalXCodeGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalXCodeGenerator.h,v
retrieving revision 1.3
retrieving revision 1.3.8.1
diff -u -d -r1.3 -r1.3.8.1
--- cmLocalXCodeGenerator.h	16 Feb 2007 21:12:16 -0000	1.3
+++ cmLocalXCodeGenerator.h	11 Jun 2007 22:23:34 -0000	1.3.8.1
@@ -35,8 +35,6 @@
   void GetTargetObjectFileDirectories(cmTarget* target,
                                       std::vector<std::string>& 
                                       dirs);
-  // return the source name for the object file
-  virtual std::string GetSourceObjectName(cmSourceFile& );
 private:
 
 };

Index: cmSourceFile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.h,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- cmSourceFile.h	28 May 2007 17:32:17 -0000	1.21
+++ cmSourceFile.h	11 Jun 2007 22:23:34 -0000	1.21.2.1
@@ -17,11 +17,11 @@
 #ifndef cmSourceFile_h
 #define cmSourceFile_h
 
+#include "cmSourceFileLocation.h"
 #include "cmCustomCommand.h"
 #include "cmPropertyMap.h"
 
 class cmake;
-class cmMakefile;
 
 /** \class cmSourceFile
  * \brief Represent a class loaded from a makefile.
@@ -33,67 +33,39 @@
 {
 public:
   /**
-   * Construct instance as a concrete class with both a
-   * .h and .cxx file.
-   */
-  cmSourceFile();
-  ~cmSourceFile()
-    {
-      this->SetCustomCommand(0);
-    }
-  
-  /**
-   * Set the name of the file, given the directory the file should be
-   * in.  The various extensions provided are tried on the name
-   * (e.g., cxx, cpp) in the directory to find the actual file.
+   * Construct with the makefile storing the source and the initial
+   * name referencing it.
    */
-  bool SetName(const char* name, const char* dir,
-               const std::vector<std::string>& sourceExts,
-               const std::vector<std::string>& headerExts,
-               const char* target = 0);
+  cmSourceFile(cmMakefile* mf, const char* name);
+
+  ~cmSourceFile();
 
   /**
    * Get the list of the custom commands for this source file
    */
-  const cmCustomCommand *GetCustomCommand() const 
-    {return this->CustomCommand;}
-  cmCustomCommand *GetCustomCommand() {return this->CustomCommand;}
+  cmCustomCommand* GetCustomCommand();
+  cmCustomCommand const* GetCustomCommand() const;
   void SetCustomCommand(cmCustomCommand *cc);
-    
-  /**
-   * Set the name of the file, given the directory the file should be in.  IN
-   * this version the extension is provided in the call. This is useful for
-   * generated files that do not exist prior to the build.  
-   */
-  void SetName(const char* name, const char* dir, const char *ext, 
-               bool headerFileOnly);
-
-  /**
-   * Print the structure to std::cout.
-   */
-  void Print() const;
 
   ///! Set/Get a property of this source file
   void SetProperty(const char *prop, const char *value);
   const char *GetProperty(const char *prop) const;
   bool GetPropertyAsBool(const char *prop) const;
-    
+
   /**
    * The full path to the file.
    */
-  const std::string &GetFullPath() const {return this->FullPath;}
+  const char* GetFullPath() const;
 
   /**
-   * The file name associated with stripped off directory and extension.
-   * (In most cases this is the name of the class.)
+   * Get the file extension of this source file.
    */
-  const std::string &GetSourceName() const {return this->SourceName;}
+  std::string const& GetExtension() const;
 
   /**
-   * The file extension associated with source file
+   * Get the language of the compiler to use for this source file.
    */
-  const std::string &GetSourceExtension() const {
-    return this->SourceExtension;}
+  const char* GetLanguage() const;
 
   /**
    * Return the vector that holds the list of dependencies
@@ -101,11 +73,6 @@
   const std::vector<std::string> &GetDepends() const {return this->Depends;}
   void AddDepend(const char* d) { this->Depends.push_back(d); }
 
-  /**
-   * Get the source name without last extension
-   */
-  const std::string& GetSourceNameWithoutLastExtension();
-
   // Get the properties
   cmPropertyMap &GetProperties() { return this->Properties; };
 
@@ -113,21 +80,27 @@
   static void DefineProperties(cmake *cm);
 
   ///! Set the cmMakefile that owns this target
-  void SetMakefile(cmMakefile *mf);
-  cmMakefile *GetMakefile() { return this->Makefile;};
+  //cmMakefile *GetMakefile() { return this->Makefile;};
+
+  /**
+   * Check whether the given source file location could refer to this
+   * source.
+   */
+  bool Matches(cmSourceFileLocation const&);
 
 private:
+  cmSourceFileLocation Location;
   cmPropertyMap Properties;
-  cmCustomCommand *CustomCommand;
+  cmCustomCommand* CustomCommand;
+  std::string Extension;
+  mutable std::string Language;
   std::string FullPath;
-  std::string SourceName;
-  std::string SourceExtension;
-  std::vector<std::string> Depends;
-  std::string SourceNameWithoutLastExtension;
 
-  // The cmMakefile instance that owns this source file.  This should
-  // always be set.
-  cmMakefile* Makefile;
+  bool FindFullPath();
+  bool TryFullPath(const char* tryPath, const char* ext);
+  void CheckExtension();
+
+  std::vector<std::string> Depends;
 };
 
 #endif

Index: cmLocalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalXCodeGenerator.cxx,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -u -d -r1.4 -r1.4.8.1
--- cmLocalXCodeGenerator.cxx	17 Feb 2007 13:46:24 -0000	1.4
+++ cmLocalXCodeGenerator.cxx	11 Jun 2007 22:23:34 -0000	1.4.8.1
@@ -24,16 +24,3 @@
   g->GetTargetObjectFileDirectories(target,
                                     dirs);
 }
-  
-  // return the source name for the object file
-std::string cmLocalXCodeGenerator::GetSourceObjectName(cmSourceFile& sf )
-{
-  std::string ret = sf.GetSourceName();
-  std::string::size_type pos = ret.find("/");
-  if(pos == ret.npos)
-    {
-    return ret;
-    }
-  return ret.substr(pos+1);
-}
-  

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.397
retrieving revision 1.397.2.1
diff -u -d -r1.397 -r1.397.2.1
--- cmMakefile.cxx	11 Jun 2007 14:25:40 -0000	1.397
+++ cmMakefile.cxx	11 Jun 2007 22:23:34 -0000	1.397.2.1
@@ -18,6 +18,7 @@
 #include "cmVersion.h"
 #include "cmCommand.h"
 #include "cmSourceFile.h"
+#include "cmSourceFileLocation.h"
 #include "cmSystemTools.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
@@ -557,7 +558,6 @@
   for (cmTargets::iterator l = this->Targets.begin();
        l != this->Targets.end(); l++)
     {
-    l->second.GenerateSourceFilesFromSourceLists(*this);
     l->second.AnalyzeLibDependencies(*this);
     }
 }
@@ -772,7 +772,7 @@
       {
       if (this->Targets.find(target) != this->Targets.end())
         {
-        this->Targets[target].AddSourceListEntry(source);
+        this->Targets[target].AddSource(source);
         }
       else
         {
@@ -854,10 +854,10 @@
                                  commandLines, comment,
                                  workingDirectory, no_replace,
                                  escapeOldStyle);
-  target->AddSourceListEntry(force.c_str());
+  cmSourceFile* sf = target->AddSource(force.c_str());
 
   // The output is not actually created so mark it symbolic.
-  if(cmSourceFile* sf = this->GetSource(force.c_str()))
+  if(sf)
     {
     sf->SetProperty("SYMBOLIC", "1");
     }
@@ -1364,7 +1364,7 @@
     {
     target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
     }
-  target->SetSourceList(srcs);
+  target->AddSources(srcs);
   this->AddGlobalLinkInformation(lname, *target);
 }
 
@@ -1377,7 +1377,7 @@
     {
     target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
     }
-  target->SetSourceList(srcs);
+  target->AddSources(srcs);
   this->AddGlobalLinkInformation(exeName, *target);
   return target;
 }
@@ -2116,205 +2116,44 @@
     }
 }
 
-cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
+//----------------------------------------------------------------------------
+cmSourceFile* cmMakefile::GetSource(const char* sourceName)
 {
-  // if the source is provided with a full path use it, otherwise
-  // by default it is in the current source dir
-  std::string path;
-  if (cmSystemTools::FileIsFullPath(sourceName))
-    {
-    path = cmSystemTools::GetFilenamePath(sourceName);
-    }
-  else
-    {
-    path = this->GetCurrentDirectory();
-    // even though it is not a full path, it may still be relative
-    std::string subpath = cmSystemTools::GetFilenamePath(sourceName);
-    if (!subpath.empty())
-      {
-      path += "/";
-      path += cmSystemTools::GetFilenamePath(sourceName);
-      }
-    }
-  path = cmSystemTools::CollapseFullPath(path.c_str());
-
-  std::string sname =
-    cmSystemTools::GetFilenameWithoutLastExtension(sourceName);
-
-  // compute the extension
-  std::string ext
-    = cmSystemTools::GetFilenameLastExtension(sourceName);
-  if ( ext.length() && ext[0] == '.' )
-    {
-    ext = ext.substr(1);
-    }
-
-  for(std::vector<cmSourceFile*>::const_iterator i =
-        this->SourceFiles.begin();
-      i != this->SourceFiles.end(); ++i)
-    {
-    if ((*i)->GetSourceNameWithoutLastExtension() == sname &&
-        cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path &&
-        (ext.size() == 0 || (ext == (*i)->GetSourceExtension())))
-      {
-      return *i;
-      }
-    }
-
-  // geeze, if it wasn't found maybe it is listed under the output dir
-  if (!cmSystemTools::GetFilenamePath(sourceName).empty())
-    {
-    return 0;
-    }
-
-  path = this->GetCurrentOutputDirectory();
-  for(std::vector<cmSourceFile*>::const_iterator i =
-        this->SourceFiles.begin();
-      i != this->SourceFiles.end(); ++i)
+  cmSourceFileLocation sfl(this, sourceName);
+  for(std::vector<cmSourceFile*>::const_iterator
+        sfi = this->SourceFiles.begin();
+      sfi != this->SourceFiles.end(); ++sfi)
     {
-    if ((*i)->GetSourceName() == sname &&
-        cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path &&
-        (ext.size() == 0 || (ext == (*i)->GetSourceExtension())))
+    cmSourceFile* sf = *sfi;
+    if(sf->Matches(sfl))
       {
-      return *i;
+      return sf;
       }
     }
-
   return 0;
 }
 
+//----------------------------------------------------------------------------
 cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
                                             bool generated)
 {
-  // make it a full path first
-  std::string src = sourceName;
-  bool relative = !cmSystemTools::FileIsFullPath(sourceName);
-  std::string srcTreeFile = this->GetCurrentDirectory();
-  srcTreeFile += "/";
-  srcTreeFile += sourceName;
-
-  if(relative)
-    {
-    src = srcTreeFile;
-    }
-
-  // check to see if it exists
-  cmSourceFile* ret = this->GetSource(src.c_str());
-  if (ret)
-    {
-    return ret;
-    }
-
-  // OK a source file object doesn't exist for the source
-  // maybe we made a bad call on assuming it was in the src tree
-  std::string buildTreeFile = this->GetCurrentOutputDirectory();
-  buildTreeFile += "/";
-  buildTreeFile += sourceName;
-
-  if (relative)
-    {
-    src = buildTreeFile;
-    ret = this->GetSource(src.c_str());
-    if (ret)
-      {
-      return ret;
-      }
-    // if it has not been marked generated check to see if it exists in the
-    // src tree
-    if(!generated)
-      {
-      // see if the file is in the source tree, otherwise assume it
-      // is in the binary tree
-      if (cmSystemTools::FileExists(srcTreeFile.c_str()) &&
-          !cmSystemTools::FileIsDirectory(srcTreeFile.c_str()))
-        {
-        src = srcTreeFile;
-        }
-      else
-        {
-        if ( cmSystemTools::GetFilenameLastExtension
-             (srcTreeFile.c_str()).size() == 0)
-          {
-          if (cmSystemTools::DoesFileExistWithExtensions(
-            srcTreeFile.c_str(), this->GetSourceExtensions()))
-            {
-            src = srcTreeFile;
-            }
-          else if (cmSystemTools::DoesFileExistWithExtensions(
-            srcTreeFile.c_str(), this->GetHeaderExtensions()))
-            {
-            src = srcTreeFile;
-            }
-          }
-        }
-      }
-    }
-
-  // a cmSourceFile instance does not exist yet so we must create one
-  // go back to looking in the source directory for it
-
-  // we must create one
-  cmSourceFile file;
-  file.SetMakefile(this);
-  std::string path = cmSystemTools::GetFilenamePath(src);
-  if(generated)
+  if(cmSourceFile* sf = this->GetSource(sourceName))
     {
-    std::string ext = cmSystemTools::GetFilenameLastExtension(src);
-    std::string name_no_ext = cmSystemTools::GetFilenameName(src.c_str());
-    name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
-    if ( ext.length() && ext[0] == '.' )
-      {
-      ext = ext.substr(1);
-      }
-    bool headerFile =
-      !(std::find( this->HeaderFileExtensions.begin(),
-                   this->HeaderFileExtensions.end(), ext ) ==
-        this->HeaderFileExtensions.end());
-    file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), headerFile);
+    return sf;
     }
   else
     {
-    std::string relPath = cmSystemTools::GetFilenamePath(sourceName);
-    if (relative && relPath.size())
-      {
-      // we need to keep the relative part of the filename
-      std::string fullPathLessRel = path;
-      std::string::size_type pos = fullPathLessRel.rfind(relPath);
-      if (pos == std::string::npos)
-        {
-        cmSystemTools::Error(
-          "CMake failed to properly look up relative cmSourceFile: ",
-          sourceName);
-        }
-      fullPathLessRel.erase(pos-1);
-      file.SetName(sourceName, fullPathLessRel.c_str(),
-                   this->GetSourceExtensions(),
-                   this->GetHeaderExtensions());
-      }
-    else
+    cmSourceFile* sf = new cmSourceFile(this, sourceName);
+    if(generated)
       {
-      file.SetName(cmSystemTools::GetFilenameName(src.c_str()).c_str(),
-                   path.c_str(),
-                   this->GetSourceExtensions(),
-                   this->GetHeaderExtensions());
+      sf->SetProperty("GENERATED", "1");
       }
+    this->SourceFiles.push_back(sf);
+    return sf;
     }
-  // add the source file to the makefile
-  this->AddSource(file);
-  src = file.GetFullPath();
-  ret = this->GetSource(src.c_str());
-  if (!ret)
-    {
-    cmSystemTools::Error(
-      "CMake failed to properly look up cmSourceFile: ", sourceName);
-    }
-  else
-    {
-    ret->SetMakefile(this);
-    }
-  return ret;
 }
 
+#if 0
 cmSourceFile* cmMakefile::AddSource(cmSourceFile const&sf)
 {
   // check to see if it exists
@@ -2327,6 +2166,7 @@
   this->SourceFiles.push_back(ret);
   return ret;
 }
+#endif
 
 
 void cmMakefile::EnableLanguage(std::vector<std::string> const &  lang)

Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.227
retrieving revision 1.227.2.1
diff -u -d -r1.227 -r1.227.2.1
--- cmLocalGenerator.cxx	4 Jun 2007 21:08:46 -0000	1.227
+++ cmLocalGenerator.cxx	11 Jun 2007 22:23:34 -0000	1.227.2.1
@@ -147,12 +147,12 @@
     // so don't build a projectfile for it
     if (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
       {
-      std::string projectFilename;
+      const char* projectFilename = 0;
       if (this->IsMakefileGenerator == false)  // only use of this variable
         {
-        projectFilename=t->second.GetName();
+        projectFilename = t->second.GetName();
         }
-      t->second.TraceVSDependencies(projectFilename, this->Makefile);
+      t->second.TraceDependencies(projectFilename);
       }
     }
 }
@@ -549,7 +549,7 @@
   objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
   std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
   std::string sourceFile = 
-    this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
+    this->Convert(source.GetFullPath(),START_OUTPUT,SHELL,true);
   std::string varString = "CMAKE_";
   varString += lang;
   varString += "_COMPILE_OBJECT";
@@ -610,7 +610,7 @@
   this->Makefile->AddCustomCommandToOutput(
     ofname,
     depends,
-    source.GetFullPath().c_str(),
+    source.GetFullPath(),
     commandLines,
     comment.c_str(),
     this->Makefile->GetStartOutputDirectory()
@@ -625,18 +625,21 @@
   std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); ++i)
-    { 
-    if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") && 
-       !(*i)->GetCustomCommand())
+    {
+    cmSourceFile* sf = *i;
+    if(!sf->GetCustomCommand() &&
+       !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+       !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
       {
-      std::string outExt = 
-        this->GlobalGenerator->GetLanguageOutputExtensionFromExtension(
-          (*i)->GetSourceExtension().c_str());
-      if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+      std::string::size_type dir_len = 0;
+      dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
+      dir_len += 1;
+      std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_len);
+      if(!obj.empty())
         {
         std::string ofname = this->Makefile->GetCurrentOutputDirectory();
         ofname += "/";
-        ofname += (*i)->GetSourceName() + outExt;
+        ofname += obj;
         objVector.push_back(ofname);
         this->AddCustomCommandToCreateObject(ofname.c_str(), 
                                              llang, *(*i), target);
@@ -1358,11 +1361,12 @@
         for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
             i != sources.end(); ++i)
           {
-          if((*i)->GetSourceExtension() == "def")
+          cmSourceFile* sf = *i;
+          if(sf->GetExtension() == "def")
             {
             linkFlags += 
               this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
-            linkFlags += this->Convert((*i)->GetFullPath().c_str(),
+            linkFlags += this->Convert(sf->GetFullPath(),
                                        START_OUTPUT, SHELL);
             linkFlags += " ";
             }
@@ -2625,7 +2629,7 @@
 {
   // Construct the object file name using the full path to the source
   // file which is its only unique identification.
-  const char* fullPath = source.GetFullPath().c_str();
+  const char* fullPath = source.GetFullPath();
 
   // Try referencing the source relative to the source tree.
   std::string relFromSource = this->Convert(fullPath, START);
@@ -2672,23 +2676,18 @@
 
   // Replace the original source file extension with the object file
   // extension.
-  std::string::size_type dot_pos = objectName.rfind(".");
-  if(dot_pos != std::string::npos)
-    {
-    objectName = objectName.substr(0, dot_pos);
-    }
-  if ( source.GetPropertyAsBool("KEEP_EXTENSION") )
+  if(!source.GetPropertyAsBool("KEEP_EXTENSION"))
     {
-    if ( !source.GetSourceExtension().empty() )
+    // Remove the original extension.
+    std::string::size_type dot_pos = objectName.rfind(".");
+    if(dot_pos != std::string::npos)
       {
-      objectName += "." + source.GetSourceExtension();
+      objectName = objectName.substr(0, dot_pos);
       }
-    }
-  else
-    {
+
+    // Store the new extension.
     objectName +=
-      this->GlobalGenerator->GetLanguageOutputExtensionFromExtension(
-        source.GetSourceExtension().c_str());
+      this->GlobalGenerator->GetLanguageOutputExtension(source);
     }
 
   // Convert to a safe name.
@@ -2700,15 +2699,7 @@
 cmLocalGenerator
 ::GetSourceFileLanguage(const cmSourceFile& source)
 {
-  // Check for an explicitly assigned language.
-  if(const char* lang = source.GetProperty("LANGUAGE"))
-    {
-    return lang;
-    }
-
-  // Infer the language from the source file extension.
-  return (this->GlobalGenerator
-          ->GetLanguageFromExtension(source.GetSourceExtension().c_str()));
+  return source.GetLanguage();
 }
 
 //----------------------------------------------------------------------------
@@ -2784,8 +2775,3 @@
   cmSystemTools::Error("GetTargetObjectFileDirectories"
                        " called on cmLocalGenerator");
 }
-
-std::string cmLocalGenerator::GetSourceObjectName(cmSourceFile& sf)
-{
-  return sf.GetSourceName();
-}

Index: cmQTWrapUICommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmQTWrapUICommand.cxx,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -u -d -r1.24 -r1.24.2.1
--- cmQTWrapUICommand.cxx	28 May 2007 14:11:44 -0000	1.24
+++ cmQTWrapUICommand.cxx	11 Jun 2007 22:23:34 -0000	1.24.2.1
@@ -24,191 +24,147 @@
     this->SetError("called with incorrect number of arguments");
     return false;
     }
+
+  // This command supports source list inputs for compatibility.
   std::vector<std::string> args;
   this->Makefile->ExpandSourceListArguments(argsIn, args, 3);
 
-  // what is the current source dir
-  std::string cdir = this->Makefile->GetCurrentDirectory();
+  // Get the uic and moc executables to run in the custom commands.
+  const char* uic_exe =
+    this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
+  const char* moc_exe =
+    this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
 
-  // keep the library name
-  this->LibraryName = args[0];
-  this->HeaderList = args[1];
-  this->SourceList = args[2];
-  std::string sourceListValue;
-  std::string headerListValue;
-  const char *def = this->Makefile->GetDefinition(this->SourceList.c_str());  
-  if (def)
-    {
-    sourceListValue = def;
-    }
- 
-  // get the list of classes for this library
+  // Get the variable holding the list of sources.
+  std::string const& headerList = args[1];
+  std::string const& sourceList = args[2];
+  std::string headerListValue =
+    this->Makefile->GetSafeDefinition(headerList.c_str());
+  std::string sourceListValue =
+    this->Makefile->GetSafeDefinition(sourceList.c_str());
+
+  // Create rules for all sources listed.
   for(std::vector<std::string>::iterator j = (args.begin() + 3);
       j != args.end(); ++j)
-    {   
+    {
     cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
-    
     // if we should wrap the class
-    if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
+    if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
       {
-      cmSourceFile header_file;
-      cmSourceFile source_file;
-      cmSourceFile moc_file;
-      std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
-      header_file.SetName(srcName.c_str(), 
-                          this->Makefile->GetCurrentOutputDirectory(),
-                          "h",false);
-      source_file.SetName(srcName.c_str(), 
-                          this->Makefile->GetCurrentOutputDirectory(),
-                          "cxx",false);
-      std::string moc_source_name("moc_");
-      moc_source_name = moc_source_name + srcName;
-      moc_file.SetName(moc_source_name.c_str(), 
-                       this->Makefile->GetCurrentOutputDirectory(),
-                       "cxx",false);
-      std::string origname;
-      if ( (*j)[0] == '/' || (*j)[1] == ':' )
+      // Compute the name of the files to generate.
+      std::string srcName =
+        cmSystemTools::GetFilenameWithoutLastExtension(*j);
+      std::string hName = this->Makefile->GetCurrentOutputDirectory();
+      hName += "/";
+      hName += srcName;
+      hName += ".h";
+      std::string cxxName = this->Makefile->GetCurrentOutputDirectory();
+      cxxName += "/";
+      cxxName += srcName;
+      cxxName += ".cxx";
+      std::string mocName = this->Makefile->GetCurrentOutputDirectory();
+      mocName += "/moc_";
+      mocName += srcName;
+      mocName += ".cxx";
+
+      // Compute the name of the ui file from which to generate others.
+      std::string uiName;
+      if(cmSystemTools::FileIsFullPath(j->c_str()))
         {
-        origname = *j;
+        uiName = *j;
         }
       else
         {
-        if ( curr && curr->GetPropertyAsBool("GENERATED") )
+        if(curr && curr->GetPropertyAsBool("GENERATED"))
           {
-          origname = std::string(this->Makefile->GetCurrentOutputDirectory()) 
-            + "/" + *j;
+          uiName = this->Makefile->GetCurrentOutputDirectory();
           }
         else
           {
-          origname = cdir + "/" + *j;
+          uiName = this->Makefile->GetCurrentDirectory();
           }
+        uiName += "/";
+        uiName += *j;
         }
-      std::string hname = header_file.GetFullPath();
-      this->WrapUserInterface.push_back(origname);
-      // add starting depends
-      moc_file.AddDepend(hname.c_str());
-      source_file.AddDepend(hname.c_str());
-      source_file.AddDepend(origname.c_str());
-      header_file.AddDepend(origname.c_str());
-      this->WrapHeadersClasses.push_back(header_file);
-      this->WrapSourcesClasses.push_back(source_file);
-      this->WrapMocClasses.push_back(moc_file);
-      this->Makefile->AddSource(header_file);
-      this->Makefile->AddSource(source_file);
-      this->Makefile->AddSource(moc_file);
-      
-      // create the list of headers 
-      if (headerListValue.size() > 0)
+
+      // create the list of headers
+      if(!headerListValue.empty())
         {
         headerListValue += ";";
         }
-      headerListValue += header_file.GetFullPath();
-      
+      headerListValue += hName;
+
       // create the list of sources
-      if (sourceListValue.size() > 0)
+      if(!sourceListValue.empty())
         {
         sourceListValue += ";";
         }
-      sourceListValue += source_file.GetFullPath();
+      sourceListValue += cxxName;
       sourceListValue += ";";
-      sourceListValue += moc_file.GetFullPath();
-      }
-    }
-  
-  this->Makefile->AddDefinition(this->SourceList.c_str(),
-                                sourceListValue.c_str());  
-  this->Makefile->AddDefinition(this->HeaderList.c_str(),
-                                headerListValue.c_str());  
-  return true;
-}
-
-void cmQTWrapUICommand::FinalPass() 
-{
-
-  // first we add the rules for all the .ui to .h and .cxx files
-  size_t lastHeadersClass = this->WrapHeadersClasses.size();
-  std::vector<std::string> depends;
-  const char* uic_exe =
-    this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
-  const char* moc_exe =
-    this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
-
-  // wrap all the .h files
-  depends.push_back(uic_exe);
-
-  for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
-    {
-    // set up .ui to .h and .cxx command
-    std::string hres = this->Makefile->GetCurrentOutputDirectory();
-    hres += "/";
-    hres += this->WrapHeadersClasses[classNum].GetSourceName() + "." +
-        this->WrapHeadersClasses[classNum].GetSourceExtension();
-
-    std::string cxxres = this->Makefile->GetCurrentOutputDirectory();
-    cxxres += "/";
-    cxxres += this->WrapSourcesClasses[classNum].GetSourceName() + "." +
-        this->WrapSourcesClasses[classNum].GetSourceExtension();
-
-    std::string mocres = this->Makefile->GetCurrentOutputDirectory();
-    mocres += "/";
-    mocres += this->WrapMocClasses[classNum].GetSourceName() + "." +
-        this->WrapMocClasses[classNum].GetSourceExtension();
-
-    cmCustomCommandLine hCommand;
-    hCommand.push_back(uic_exe);
-    hCommand.push_back("-o");
-    hCommand.push_back(hres);
-    hCommand.push_back(this->WrapUserInterface[classNum]);
-    cmCustomCommandLines hCommandLines;
-    hCommandLines.push_back(hCommand);
-
-    cmCustomCommandLine cxxCommand;
-    cxxCommand.push_back(uic_exe);
-    cxxCommand.push_back("-impl");
-    cxxCommand.push_back(hres);
-    cxxCommand.push_back("-o");
-    cxxCommand.push_back(cxxres);
-    cxxCommand.push_back(this->WrapUserInterface[classNum]);
-    cmCustomCommandLines cxxCommandLines;
-    cxxCommandLines.push_back(cxxCommand);
+      sourceListValue += mocName;
 
-    cmCustomCommandLine mocCommand;
-    mocCommand.push_back(moc_exe);
-    mocCommand.push_back("-o");
-    mocCommand.push_back(mocres);
-    mocCommand.push_back(hres);
-    cmCustomCommandLines mocCommandLines;
-    mocCommandLines.push_back(mocCommand);
+      // set up .ui to .h and .cxx command
+      cmCustomCommandLine hCommand;
+      hCommand.push_back(uic_exe);
+      hCommand.push_back("-o");
+      hCommand.push_back(hName);
+      hCommand.push_back(uiName);
+      cmCustomCommandLines hCommandLines;
+      hCommandLines.push_back(hCommand);
 
-    depends.clear();
-    depends.push_back(this->WrapUserInterface[classNum]);
-    const char* no_main_dependency = 0;
-    const char* no_comment = 0;
-    const char* no_working_dir = 0;
-    this->Makefile->AddCustomCommandToOutput(hres.c_str(),
-                                         depends,
-                                         no_main_dependency,
-                                         hCommandLines,
-                                         no_comment,
-                                         no_working_dir);
+      cmCustomCommandLine cxxCommand;
+      cxxCommand.push_back(uic_exe);
+      cxxCommand.push_back("-impl");
+      cxxCommand.push_back(hName);
+      cxxCommand.push_back("-o");
+      cxxCommand.push_back(cxxName);
+      cxxCommand.push_back(uiName);
+      cmCustomCommandLines cxxCommandLines;
+      cxxCommandLines.push_back(cxxCommand);
 
-    depends.push_back(hres);
+      cmCustomCommandLine mocCommand;
+      mocCommand.push_back(moc_exe);
+      mocCommand.push_back("-o");
+      mocCommand.push_back(mocName);
+      mocCommand.push_back(hName);
+      cmCustomCommandLines mocCommandLines;
+      mocCommandLines.push_back(mocCommand);
 
-    this->Makefile->AddCustomCommandToOutput(cxxres.c_str(),
-                                         depends,
-                                         no_main_dependency,
-                                         cxxCommandLines,
-                                         no_comment,
-                                         no_working_dir);
+      std::vector<std::string> depends;
+      depends.push_back(uiName);
+      const char* no_main_dependency = 0;
+      const char* no_comment = 0;
+      const char* no_working_dir = 0;
+      this->Makefile->AddCustomCommandToOutput(hName.c_str(),
+                                               depends,
+                                               no_main_dependency,
+                                               hCommandLines,
+                                               no_comment,
+                                               no_working_dir);
 
-    depends.clear();
-    depends.push_back(hres);
+      depends.push_back(hName);
+      this->Makefile->AddCustomCommandToOutput(cxxName.c_str(),
+                                               depends,
+                                               no_main_dependency,
+                                               cxxCommandLines,
+                                               no_comment,
+                                               no_working_dir);
 
-    this->Makefile->AddCustomCommandToOutput(mocres.c_str(),
-                                         depends,
-                                         no_main_dependency,
-                                         mocCommandLines,
-                                         no_comment,
-                                         no_working_dir);
+      depends.clear();
+      depends.push_back(hName);
+      this->Makefile->AddCustomCommandToOutput(mocName.c_str(),
+                                               depends,
+                                               no_main_dependency,
+                                               mocCommandLines,
+                                               no_comment,
+                                               no_working_dir);
+      }
     }
+
+  // Store the final list of source files and headers.
+  this->Makefile->AddDefinition(sourceList.c_str(),
+                                sourceListValue.c_str());
+  this->Makefile->AddDefinition(headerList.c_str(),
+                                headerListValue.c_str());
+  return true;
 }

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.184
retrieving revision 1.184.2.1
diff -u -d -r1.184 -r1.184.2.1
--- cmGlobalGenerator.cxx	11 Jun 2007 19:47:35 -0000	1.184
+++ cmGlobalGenerator.cxx	11 Jun 2007 22:23:34 -0000	1.184.2.1
@@ -19,6 +19,7 @@
 #include "cmExternalMakefileProjectGenerator.h"
 #include "cmake.h"
 #include "cmMakefile.h"
+#include "cmSourceFile.h"
 #include "cmVersion.h"
 
 #include <stdlib.h> // required for atof
@@ -483,39 +484,32 @@
     }
 }
 
-const char* cmGlobalGenerator
-::GetLanguageOutputExtensionForLanguage(const char* lang)
-{
-  if(!lang)
-    {
-    return "";
-    }
-  if(this->LanguageToOutputExtension.count(lang) > 0)
-    {
-    return this->LanguageToOutputExtension[lang].c_str();
-    }
-  return "";
-}
-
-const char* cmGlobalGenerator
-::GetLanguageOutputExtensionFromExtension(const char* ext)
+//----------------------------------------------------------------------------
+const char*
+cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source)
 {
-  if(!ext)
+  if(const char* lang = source.GetLanguage())
     {
-    return "";
+    if(this->LanguageToOutputExtension.count(lang) > 0)
+      {
+      return this->LanguageToOutputExtension[lang].c_str();
+      }
     }
-  const char* lang = this->GetLanguageFromExtension(ext);
-  if(!lang || *lang == 0)
+  else
     {
     // if no language is found then check to see if it is already an
     // ouput extension for some language.  In that case it should be ignored
     // and in this map, so it will not be compiled but will just be used.
-    if(this->OutputExtensions.count(ext))
+    std::string const& ext = source.GetExtension();
+    if(!ext.empty())
       {
-      return ext;
+      if(this->OutputExtensions.count(ext))
+        {
+        return ext.c_str();
+        }
       }
     }
-  return this->GetLanguageOutputExtensionForLanguage(lang);
+  return "";
 }
 
 

Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.35
retrieving revision 1.35.8.1
diff -u -d -r1.35 -r1.35.8.1
--- cmSourceFile.cxx	13 Dec 2006 17:19:59 -0000	1.35
+++ cmSourceFile.cxx	11 Jun 2007 22:23:34 -0000	1.35.8.1
@@ -15,120 +15,154 @@
 
 =========================================================================*/
 #include "cmSourceFile.h"
-#include "cmSystemTools.h"
 
-#include "cmake.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
-// Set the name of the class and the full path to the file.
-// The class must be found in dir and end in name.cxx, name.txx, 
-// name.c or it will be considered a header file only class
-// and not included in the build process
-bool cmSourceFile::SetName(const char* name, const char* dir,
-                           const std::vector<std::string>& sourceExts,
-                           const std::vector<std::string>& headerExts,
-                           const char* target)
+//----------------------------------------------------------------------------
+cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name):
+  Location(mf, name)
 {
+  this->CustomCommand = 0;
+  this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
+}
 
-  this->SetProperty("HEADER_FILE_ONLY","1");
-  this->SourceNameWithoutLastExtension = "";
-
-  // Save the original name given.
-  this->SourceName = name;
+//----------------------------------------------------------------------------
+cmSourceFile::~cmSourceFile()
+{
+  this->SetCustomCommand(0);
+}
 
-  // Convert the name to a full path in case the given name is a
-  // relative path.
-  std::string pathname = cmSystemTools::CollapseFullPath(name, dir);
+//----------------------------------------------------------------------------
+std::string const& cmSourceFile::GetExtension() const
+{
+  // Make sure the file location is known.
+  this->GetFullPath();
+  return this->Extension;
+}
 
-  // First try and see whether the listed file can be found
-  // as is without extensions added on.
-  std::string hname = pathname;
-  if(cmSystemTools::FileExists(hname.c_str()))
+//----------------------------------------------------------------------------
+const char* cmSourceFile::GetLanguage() const
+{
+  if(this->Language.empty())
     {
-    this->SourceName = cmSystemTools::GetFilenamePath(name);
-    if ( this->SourceName.size() > 0 )
+    if(const char* lang = this->GetProperty("LANGUAGE"))
       {
-      this->SourceName += "/";
+      this->Language = lang;
       }
-    this->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
-    std::string::size_type pos = hname.rfind('.');
-    if(pos != std::string::npos)
+    else if(this->GetFullPath())
       {
-      this->SourceExtension = hname.substr(pos+1, hname.size()-pos);
-      if ( cmSystemTools::FileIsFullPath(name) )
+      cmLocalGenerator* lg =
+        this->Location.GetMakefile()->GetLocalGenerator();
+      cmGlobalGenerator* gg = lg->GetGlobalGenerator();
+      if(const char* l = gg->GetLanguageFromExtension(this->Extension.c_str()))
         {
-        std::string::size_type pos2 = hname.rfind('/');
-        if(pos2 != std::string::npos)
-          {
-          this->SourceName = hname.substr(pos2+1, pos - pos2-1);
-          }
+        this->Language = l;
         }
       }
+    }
+  if(this->Language.empty())
+    {
+    return 0;
+    }
+  else
+    {
+    return this->Language.c_str();
+    }
+}
 
-    // See if the file is a header file
-    if(std::find( headerExts.begin(), headerExts.end(), 
-                  this->SourceExtension ) == headerExts.end())
+//----------------------------------------------------------------------------
+const char* cmSourceFile::GetFullPath() const
+{
+  if(this->FullPath.empty())
+    {
+    cmSourceFile* self = const_cast<cmSourceFile*>(this);
+    if(self->FindFullPath())
       {
-      this->SetProperty("HEADER_FILE_ONLY","0");
+      self->CheckExtension();
       }
-    this->FullPath = hname;
-
-    // Mark this as an external object file if it has the proper
-    // extension.  THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD.
-    // THESE METHODS SHOULD BE MERGED.
-    if ( this->SourceExtension == "obj" || this->SourceExtension == "o" ||
-      this->SourceExtension == "lo" )
+    else
       {
-      this->SetProperty("EXTERNAL_OBJECT", "1");
+      return 0;
       }
-    return true;
     }
-  
-  // Next, try the various source extensions
-  for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
-       ext != sourceExts.end(); ++ext )
+  return this->FullPath.c_str();
+}
+
+//----------------------------------------------------------------------------
+bool cmSourceFile::FindFullPath()
+{
+  // If the file is generated compute the location without checking on
+  // disk.
+  if(this->GetPropertyAsBool("GENERATED"))
     {
-    hname = pathname;
-    hname += ".";
-    hname += *ext;
-    if(cmSystemTools::FileExists(hname.c_str()))
-      {
-      this->SourceExtension = *ext;
-      this->SetProperty("HEADER_FILE_ONLY","0");
-      this->FullPath = hname;
-      return true;
-      }
+    // The file is either already a full path or is relative to the
+    // build directory for the target.
+    this->Location.DirectoryUseBinary();
+    this->FullPath = this->Location.GetDirectory();
+    this->FullPath += "/";
+    this->FullPath += this->Location.GetName();
+    return true;
     }
 
-  // Finally, try the various header extensions
-  for( std::vector<std::string>::const_iterator ext = headerExts.begin();
-       ext != headerExts.end(); ++ext )
+  // The file is not generated.  It must exist on disk.
+  cmMakefile* mf = this->Location.GetMakefile();
+  const char* tryDirs[3] = {0, 0, 0};
+  if(this->Location.DirectoryIsAmbiguous())
     {
-    hname = pathname;
-    hname += ".";
-    hname += *ext;
-    if(cmSystemTools::FileExists(hname.c_str()))
+    tryDirs[0] = mf->GetCurrentDirectory();
+    tryDirs[1] = mf->GetCurrentOutputDirectory();
+    }
+  else
+    {
+    tryDirs[0] = "";
+    }
+  const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
+  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
+  for(const char* const* di = tryDirs; *di; ++di)
+    {
+    std::string tryPath = this->Location.GetDirectory();
+    if(!tryPath.empty())
+      {
+      tryPath += "/";
+      }
+    tryPath += this->Location.GetName();
+    tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di);
+    if(this->TryFullPath(tryPath.c_str(), 0))
       {
-      this->SourceExtension = *ext;
-      this->FullPath = hname;
       return true;
       }
+    for(std::vector<std::string>::const_iterator ei = srcExts.begin();
+        ei != srcExts.end(); ++ei)
+      {
+      if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+        {
+        return true;
+        }
+      }
+    for(std::vector<std::string>::const_iterator ei = hdrExts.begin();
+        ei != hdrExts.end(); ++ei)
+      {
+      if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+        {
+        return true;
+        }
+      }
     }
 
   cmOStringStream e;
-  e << "Cannot find source file \"" << pathname << "\"";
-  if(target)
-    {
-    e << " for target \"" << target << "\"";
-    }
+  e << "Cannot find source file \"" << this->Location.GetName() << "\"";
   e << "\n\nTried extensions";
-  for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
-       ext != sourceExts.end(); ++ext )
+  for(std::vector<std::string>::const_iterator ext = srcExts.begin();
+      ext != srcExts.end(); ++ext)
     {
     e << " ." << *ext;
     }
-  for( std::vector<std::string>::const_iterator ext = headerExts.begin();
-       ext != headerExts.end(); ++ext )
+  for(std::vector<std::string>::const_iterator ext = hdrExts.begin();
+      ext != hdrExts.end(); ++ext)
     {
     e << " ." << *ext;
     }
@@ -136,40 +170,64 @@
   return false;
 }
 
-void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
-                           bool hfo)
+//----------------------------------------------------------------------------
+bool cmSourceFile::TryFullPath(const char* tp, const char* ext)
 {
-  this->SetProperty("HEADER_FILE_ONLY",(hfo ? "1" : "0"));
-  this->SourceNameWithoutLastExtension = "";
-  this->SourceName = name;
-  std::string fname = this->SourceName;
-  if(ext && strlen(ext))
+  std::string tryPath = tp;
+  if(ext && *ext)
     {
-    fname += ".";
-    fname += ext;
+    tryPath += ".";
+    tryPath += ext;
     }
-  this->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
-  cmSystemTools::ConvertToUnixSlashes(this->FullPath);
-  this->SourceExtension = ext;
+  if(cmSystemTools::FileExists(tryPath.c_str()))
+    {
+    this->FullPath = tryPath;
+    return true;
+    }
+  return false;
+}
 
-  // Mark this as an external object file if it has the proper
-  // extension.  THIS CODE IS DUPLICATED IN THE OTHER SetName METHOD.
-  // THESE METHODS SHOULD BE MERGED.
-  if ( this->SourceExtension == "obj" || this->SourceExtension == "o" ||
-       this->SourceExtension == "lo" )
+//----------------------------------------------------------------------------
+void cmSourceFile::CheckExtension()
+{
+  // Compute the extension.
+  std::string realExt =
+    cmSystemTools::GetFilenameLastExtension(this->FullPath);
+  if(!realExt.empty())
+    {
+    // Store the extension without the leading '.'.
+    this->Extension = realExt.substr(1);
+    }
+
+  // Look for object files.
+  if(this->Extension == "obj" ||
+     this->Extension == "o" ||
+     this->Extension == "lo")
     {
     this->SetProperty("EXTERNAL_OBJECT", "1");
     }
-  return;
+
+  // Look for header files.
+  cmMakefile* mf = this->Location.GetMakefile();
+  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
+  if(std::find(hdrExts.begin(), hdrExts.end(), this->Extension) ==
+     hdrExts.end())
+    {
+    this->SetProperty("HEADER_FILE_ONLY", "0");
+    }
+  else
+    {
+    this->SetProperty("HEADER_FILE_ONLY", "1");
+    }
 }
 
-void cmSourceFile::Print() const
+//----------------------------------------------------------------------------
+bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
 {
-  std::cerr << "this->FullPath: " <<  this->FullPath << "\n";
-  std::cerr << "this->SourceName: " << this->SourceName << std::endl;
-  std::cerr << "this->SourceExtension: " << this->SourceExtension << "\n";
+  return this->Location.Matches(loc);
 }
 
+//----------------------------------------------------------------------------
 void cmSourceFile::SetProperty(const char* prop, const char* value)
 {
   if (!prop)
@@ -184,13 +242,14 @@
   this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
 }
 
-const char *cmSourceFile::GetProperty(const char* prop) const
+//----------------------------------------------------------------------------
+const char* cmSourceFile::GetProperty(const char* prop) const
 {
   // watch for special "computed" properties that are dependent on other
   // properties or variables, always recompute them
   if (!strcmp(prop,"LOCATION"))
     {
-    return this->FullPath.c_str();
+    return this->GetFullPath();
     }
 
   bool chain = false;
@@ -198,53 +257,40 @@
     this->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, chain);
   if (chain)
     {
-    return this->Makefile->GetProperty(prop,cmProperty::SOURCE_FILE);
+    cmMakefile* mf = this->Location.GetMakefile();
+    return mf->GetProperty(prop,cmProperty::SOURCE_FILE);
     }
 
   return retVal;    
 }
 
+//----------------------------------------------------------------------------
 bool cmSourceFile::GetPropertyAsBool(const char* prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
-void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
-{
-  if(this->CustomCommand)
-    {
-    delete this->CustomCommand;
-    }
-  this->CustomCommand = cc;
-}
-
-const std::string& cmSourceFile::GetSourceNameWithoutLastExtension()
+//----------------------------------------------------------------------------
+cmCustomCommand* cmSourceFile::GetCustomCommand()
 {
-  if ( this->SourceNameWithoutLastExtension.empty() )
-    {
-    this->SourceNameWithoutLastExtension = 
-      cmSystemTools::GetFilenameWithoutLastExtension(this->FullPath);
-    }
-  return this->SourceNameWithoutLastExtension;
+  return this->CustomCommand;
 }
 
-cmSourceFile::cmSourceFile()
+//----------------------------------------------------------------------------
+cmCustomCommand const* cmSourceFile::GetCustomCommand() const
 {
-  this->Makefile = 0;
-  this->CustomCommand = 0; 
+  return this->CustomCommand;
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFile::SetMakefile(cmMakefile* mf)
+void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
 {
-  // Set our makefile.
-  this->Makefile = mf;
-
-  // set the cmake instance of the properties
-  this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
+  cmCustomCommand* old = this->CustomCommand;
+  this->CustomCommand = cc;
+  delete old;
 }
 
-// define properties
+//----------------------------------------------------------------------------
 void cmSourceFile::DefineProperties(cmake *cm)
 {
   // define properties

Index: cmQTWrapCPPCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmQTWrapCPPCommand.h,v
retrieving revision 1.11
retrieving revision 1.11.8.1
diff -u -d -r1.11 -r1.11.8.1
--- cmQTWrapCPPCommand.h	15 May 2006 14:19:57 -0000	1.11
+++ cmQTWrapCPPCommand.h	11 Jun 2007 22:23:34 -0000	1.11.8.1
@@ -45,14 +45,6 @@
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args);
-  
-  /**
-   * This is called at the end after all the information
-   * specified by the command is accumulated. Most commands do
-   * not implement this method.  At this point, reading and
-   * writing to the cache can be done.
-   */
-  virtual void FinalPass();
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -79,18 +71,6 @@
       "The moc files will be added to the library using the DestName "
       "source list.";
     }
-  
-private:
-  /**
-   * List of produced files.
-   */
-  std::vector<cmSourceFile> WrapClasses;
-  /**
-   * List of header files that pprovide the source for WrapClasses.
-   */
-  std::vector<std::string> WrapHeaders;
-  std::string LibraryName;
-  std::string SourceList;
 };
 
 

Index: cmMakeDepend.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakeDepend.cxx,v
retrieving revision 1.44
retrieving revision 1.44.10.1
diff -u -d -r1.44 -r1.44.10.1
--- cmMakeDepend.cxx	15 Mar 2006 16:38:47 -0000	1.44
+++ cmMakeDepend.cxx	11 Jun 2007 22:23:34 -0000	1.44.10.1
@@ -278,7 +278,7 @@
       if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY"))
         {
         cmDependInformation* info =
-          this->GetDependInformation((*i)->GetFullPath().c_str(),0);
+          this->GetDependInformation((*i)->GetFullPath(),0);
         this->AddFileToSearchPath(info->FullPath.c_str());
         info->SourceFile = *i;
         this->GenerateDependInformation(info);

Index: cmQTWrapUICommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmQTWrapUICommand.h,v
retrieving revision 1.10
retrieving revision 1.10.10.1
diff -u -d -r1.10 -r1.10.10.1
--- cmQTWrapUICommand.h	15 Mar 2006 16:02:07 -0000	1.10
+++ cmQTWrapUICommand.h	11 Jun 2007 22:23:34 -0000	1.10.10.1
@@ -43,14 +43,6 @@
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args);
-  
-  /**
-   * This is called at the end after all the information
-   * specified by the command is accumulated. Most commands do
-   * not implement this method.  At this point, reading and
-   * writing to the cache can be done.
-   */
-  virtual void FinalPass();
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -80,21 +72,6 @@
       "The .cxx files will be added to the library using the SourcesDestName"
       "source list.";
     }
-  
-private:
-  /**
-   * List of produced files.
-   */
-  std::vector<cmSourceFile> WrapSourcesClasses;
-  std::vector<cmSourceFile> WrapHeadersClasses;
-  std::vector<cmSourceFile> WrapMocClasses;
-  /**
-   * List of header files that pprovide the source for WrapClasses.
-   */
-  std::vector<std::string> WrapUserInterface;
-  std::string LibraryName;
-  std::string HeaderList;
-  std::string SourceList;
 };
 
 

Index: cmCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCommands.cxx,v
retrieving revision 1.113
retrieving revision 1.113.2.1
diff -u -d -r1.113 -r1.113.2.1
--- cmCommands.cxx	8 Jun 2007 15:57:16 -0000	1.113
+++ cmCommands.cxx	11 Jun 2007 22:23:34 -0000	1.113.2.1
@@ -59,8 +59,10 @@
 // This one must be last because it includes windows.h and
 // windows.h #defines GetCurrentDirectory which is a member
 // of cmMakefile
+#if 0
 #include "cmLoadCommandCommand.cxx"
 #endif
+#endif
 
 void GetPredefinedCommands(std::list<cmCommand*>&
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -88,7 +90,9 @@
   commands.push_back(new cmLinkLibrariesCommand);
   commands.push_back(new cmListCommand);
   commands.push_back(new cmLoadCacheCommand);
+#if 0
   commands.push_back(new cmLoadCommandCommand);
+#endif
   commands.push_back(new cmMathCommand);
   commands.push_back(new cmOutputRequiredFilesCommand);
   commands.push_back(new cmQTWrapCPPCommand);

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.82
retrieving revision 1.82.2.1
diff -u -d -r1.82 -r1.82.2.1
--- cmLocalGenerator.h	17 May 2007 14:53:17 -0000	1.82
+++ cmLocalGenerator.h	11 Jun 2007 22:23:34 -0000	1.82.2.1
@@ -221,8 +221,6 @@
   GetTargetObjectFileDirectories(cmTarget* target,
                                  std::vector<std::string>& 
                                  dirs);
-  // return the source name for the object file
-  virtual std::string GetSourceObjectName(cmSourceFile& );
   
   /**
    * Convert the given remote path to a relative path with respect to

Index: cmCreateTestSourceList.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCreateTestSourceList.cxx,v
retrieving revision 1.42
retrieving revision 1.42.8.1
diff -u -d -r1.42 -r1.42.8.1
--- cmCreateTestSourceList.cxx	13 Dec 2006 17:19:58 -0000	1.42
+++ cmCreateTestSourceList.cxx	11 Jun 2007 22:23:34 -0000	1.42.8.1
@@ -170,29 +170,17 @@
     res = false;
     }
 
-  // Create the source list
-  cmSourceFile cfile;
-  cfile.SetMakefile(this->Makefile);
+  // Construct the source list.
   std::string sourceListValue;
-
-  cfile.SetProperty("ABSTRACT","0");
-  cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(),
-                this->Makefile->GetCurrentOutputDirectory(),
-                cmSystemTools::GetFilenameExtension(args[1]).c_str()+1,
-                false);
-  this->Makefile->AddSource(cfile);
+  {
+  cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver.c_str());
+  sf->SetProperty("ABSTRACT","0");
   sourceListValue = args[1];
-
+  }
   for(i = testsBegin; i != tests.end(); ++i)
     {
-    cmSourceFile icfile;
-    icfile.SetMakefile(this->Makefile);
-    icfile.SetProperty("ABSTRACT","0");
-    icfile.SetName(i->c_str(),
-                  this->Makefile->GetCurrentDirectory(),
-                  this->Makefile->GetSourceExtensions(),
-                  this->Makefile->GetHeaderExtensions());
-    this->Makefile->AddSource(icfile);
+    cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
+    sf->SetProperty("ABSTRACT","0");
     sourceListValue += ";";
     sourceListValue += *i;
     }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.206
retrieving revision 1.206.2.1
diff -u -d -r1.206 -r1.206.2.1
--- cmMakefile.h	11 Jun 2007 14:25:40 -0000	1.206
+++ cmMakefile.h	11 Jun 2007 22:23:34 -0000	1.206.2.1
@@ -459,19 +459,19 @@
   /** Get a cmSourceFile pointer for a given source name, if the name is
    *  not found, then a null pointer is returned.
    */
-  cmSourceFile* GetSource(const char* sourceName) const;
+  cmSourceFile* GetSource(const char* sourceName);
 
   ///! Add a new cmSourceFile to the list of sources for this makefile.
-  cmSourceFile* AddSource(cmSourceFile const&);
+  //cmSourceFile* AddSource(cmSourceFile const&);
 
   /** Get a cmSourceFile pointer for a given source name, if the name is
    *  not found, then create the source file and return it. generated 
    * indicates if it is a generated file, this is used in determining
    * how to create the source file instance e.g. name
    */
-  cmSourceFile* GetOrCreateSource(const char* sourceName, 
+  cmSourceFile* GetOrCreateSource(const char* sourceName,
                                   bool generated = false);
-  
+
   /**
    * Obtain a list of auxiliary source directories.
    */

Index: cmAuxSourceDirectoryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAuxSourceDirectoryCommand.cxx,v
retrieving revision 1.23
retrieving revision 1.23.8.1
diff -u -d -r1.23 -r1.23.8.1
--- cmAuxSourceDirectoryCommand.cxx	13 Dec 2006 17:19:58 -0000	1.23
+++ cmAuxSourceDirectoryCommand.cxx	11 Jun 2007 22:23:34 -0000	1.23.8.1
@@ -56,9 +56,9 @@
       if( dotpos != std::string::npos )
         {
         std::string ext = file.substr(dotpos+1);
-        file = file.substr(0, dotpos);
+        std::string base = file.substr(0, dotpos);
         // Process only source files
-        if( file.size() != 0
+        if( base.size() != 0
             && std::find( this->Makefile->GetSourceExtensions().begin(),
                           this->Makefile->GetSourceExtensions().end(), ext )
                  != this->Makefile->GetSourceExtensions().end() )
@@ -68,21 +68,14 @@
           fullname += file;
           // add the file as a class file so 
           // depends can be done
-          cmSourceFile cmfile;
-          cmfile.SetMakefile(this->Makefile);
-          cmfile.SetName(fullname.c_str(), 
-                         this->Makefile->GetCurrentDirectory(),
-                         this->Makefile->GetSourceExtensions(),
-                         this->Makefile->GetHeaderExtensions());
-          cmfile.SetProperty("ABSTRACT","0");
-          this->Makefile->AddSource(cmfile);
-          if (sourceListValue.size() > 0)
+          cmSourceFile* sf =
+            this->Makefile->GetOrCreateSource(fullname.c_str());
+          sf->SetProperty("ABSTRACT","0");
+          if(!sourceListValue.empty())
             {
             sourceListValue += ";";
             }
-          sourceListValue += cmfile.GetSourceName();
-          sourceListValue += ".";
-          sourceListValue += cmfile.GetSourceExtension();
+          sourceListValue += fullname;
           }
         }
       }



More information about the Cmake-commits mailing list