[cmake-commits] king committed cmLocalUnixMakefileGenerator3.cxx 1.199 1.200 cmLocalUnixMakefileGenerator3.h 1.68 1.69 cmLocalVisualStudio7Generator.cxx 1.175 1.176 cmLocalVisualStudio7Generator.h 1.34 1.35 cmMakefileExecutableTargetGenerator.cxx 1.27 1.28 cmMakefileLibraryTargetGenerator.cxx 1.32 1.33 cmMakefileTargetGenerator.cxx 1.56 1.57 cmTarget.cxx 1.124 1.125 cmTarget.h 1.73 1.74

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 8 14:57:30 EST 2007


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

Modified Files:
	cmLocalUnixMakefileGenerator3.cxx 
	cmLocalUnixMakefileGenerator3.h 
	cmLocalVisualStudio7Generator.cxx 
	cmLocalVisualStudio7Generator.h 
	cmMakefileExecutableTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmTarget.cxx cmTarget.h 
Log Message:
ENH: Replaced LibraryOutputPath and ExecutableOutputPath variables in Makefile and VS generators to instead ask each target for its output path.  This significantly reduces total code size and centralizes previously duplicate code.  It is also a step towards bug#2240.


Index: cmLocalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- cmLocalUnixMakefileGenerator3.h	8 Mar 2007 18:05:02 -0000	1.68
+++ cmLocalUnixMakefileGenerator3.h	8 Mar 2007 19:57:28 -0000	1.69
@@ -254,11 +254,6 @@
   void GetTargetObjectFileDirectories(cmTarget* target,
                                       std::vector<std::string>& dirs);
 protected:
-  // these two methods just compute reasonable values for LibraryOutputPath
-  // and ExecutableOutputPath
-  void ConfigureOutputPaths();
-  void FormatOutputPath(std::string& path, const char* name);
-
   void WriteLocalMakefile();
   
   
@@ -332,8 +327,6 @@
   int MakefileVariableSize;
   std::string IncludeDirective;
   std::string MakeSilentFlag;
-  std::string ExecutableOutputPath;
-  std::string LibraryOutputPath;
   std::string ConfigurationName;
   std::string NativeEchoCommand;
   bool NativeEchoWindows;

Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- cmLocalVisualStudio7Generator.cxx	7 Mar 2007 20:57:52 -0000	1.175
+++ cmLocalVisualStudio7Generator.cxx	8 Mar 2007 19:57:28 -0000	1.176
@@ -105,35 +105,6 @@
       }
     }
 
-  this->LibraryOutputPath = "";
-  if (this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
-    {
-    this->LibraryOutputPath = 
-      this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
-    }
-  if(this->LibraryOutputPath.size())
-    {
-    // make sure there is a trailing slash
-    if(this->LibraryOutputPath[this->LibraryOutputPath.size()-1] != '/')
-      {
-      this->LibraryOutputPath += "/";
-      }
-    }
-  this->ExecutableOutputPath = "";
-  if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
-    {
-    this->ExecutableOutputPath = 
-      this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
-    }
-  if(this->ExecutableOutputPath.size())
-    {
-    // make sure there is a trailing slash
-    if(this->ExecutableOutputPath[this->ExecutableOutputPath.size()-1] != '/')
-      {
-      this->ExecutableOutputPath += "/";
-      }
-    }
-
   // Create the VCProj or set of VCProj's for libraries and executables
 
   // clear project names
@@ -627,22 +598,15 @@
   targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n");
   fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
   fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
-  if(targetOptions.UsingDebugPDB())
+  if(targetOptions.UsingDebugPDB() &&
+     (target.GetType() == cmTarget::EXECUTABLE ||
+      target.GetType() == cmTarget::STATIC_LIBRARY ||
+      target.GetType() == cmTarget::SHARED_LIBRARY ||
+      target.GetType() == cmTarget::MODULE_LIBRARY))
     {
-    if(target.GetType() == cmTarget::EXECUTABLE)
-      {
-      fout <<  "\t\t\t\tProgramDataBaseFileName=\""
-           << this->ExecutableOutputPath
-           << "$(OutDir)/" << target.GetPDBName(configName) << "\"\n";
-      }
-    else if(target.GetType() == cmTarget::STATIC_LIBRARY ||
-            target.GetType() == cmTarget::SHARED_LIBRARY ||
-            target.GetType() == cmTarget::MODULE_LIBRARY)
-      {
-      fout <<  "\t\t\t\tProgramDataBaseFileName=\""
-           << this->LibraryOutputPath
-           << "$(OutDir)/" << target.GetPDBName(configName) << "\"\n";
-      }
+    fout <<  "\t\t\t\tProgramDataBaseFileName=\""
+         << target.GetOutputDir() << "/$(OutDir)/"
+         << target.GetPDBName(configName) << "\"\n";
     }
   fout << "/>\n";  // end of <Tool Name=VCCLCompilerTool
   fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
@@ -764,8 +728,9 @@
     case cmTarget::STATIC_LIBRARY:
     {
     std::string targetNameFull = target.GetFullName(configName);
-    std::string libpath = this->LibraryOutputPath +
-      "$(OutDir)/" + targetNameFull;
+    std::string libpath = target.GetOutputDir();
+    libpath += "/$(OutDir)/";
+    libpath += targetNameFull;
     fout << "\t\t\t<Tool\n"
          << "\t\t\t\tName=\"VCLibrarianTool\"\n";
     if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
@@ -830,7 +795,8 @@
          << " ";
     this->OutputLibraries(fout, linkLibs);
     fout << "\"\n";
-    temp = this->LibraryOutputPath;
+    temp = target.GetOutputDir();
+    temp += "/";
     temp += configName;
     temp += "/";
     temp += targetNameFull;
@@ -842,8 +808,8 @@
     this->OutputLibraryDirectories(fout, linkDirs);
     fout << "\"\n";
     this->OutputModuleDefinitionFile(fout, target);
-    temp = this->LibraryOutputPath;
-    temp += "$(OutDir)/";
+    temp = target.GetOutputDir();
+    temp += "/$(OutDir)/";
     temp += targetNamePDB;
     fout << "\t\t\t\tProgramDataBaseFile=\"" <<
       this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
@@ -860,7 +826,8 @@
       {
       fout << "\t\t\t\tStackReserveSize=\"" << stackVal  << "\"\n";
       }
-    temp = this->LibraryOutputPath;
+    temp = target.GetOutputDir();
+    temp += "/";
     temp += configName;
     temp += "/";
     temp += targetNameImport;
@@ -908,7 +875,8 @@
          << " ";
     this->OutputLibraries(fout, linkLibs);
     fout << "\"\n";
-    temp = this->ExecutableOutputPath;
+    temp = target.GetOutputDir();
+    temp += "/";
     temp += configName;
     temp += "/";
     temp += targetNameFull;
@@ -919,8 +887,9 @@
     fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
     this->OutputLibraryDirectories(fout, linkDirs);
     fout << "\"\n";
-    fout << "\t\t\t\tProgramDataBaseFile=\"" << this->ExecutableOutputPath
-         << "$(OutDir)\\" << targetNamePDB << "\"\n";
+    fout << "\t\t\t\tProgramDataBaseFile=\""
+         << target.GetOutputDir() << "\\$(OutDir)\\" << targetNamePDB
+         << "\"\n";
     if(strcmp(configName, "Debug") == 0
        || strcmp(configName, "RelWithDebInfo") == 0)
       {

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cmLocalVisualStudio7Generator.h	16 Feb 2007 21:45:47 -0000	1.34
+++ cmLocalVisualStudio7Generator.h	8 Mar 2007 19:57:28 -0000	1.35
@@ -125,8 +125,6 @@
   virtual std::string GetTargetDirectory(cmTarget&);
 
   std::vector<std::string> CreatedProjectNames;
-  std::string LibraryOutputPath;
-  std::string ExecutableOutputPath;
   std::string ModuleDefinitionFile;
   int Version;
   std::string PlatformName; // Win32 or x64 

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- cmMakefileLibraryTargetGenerator.cxx	8 Mar 2007 15:31:03 -0000	1.32
+++ cmMakefileLibraryTargetGenerator.cxx	8 Mar 2007 19:57:28 -0000	1.33
@@ -245,12 +245,7 @@
     this->LocalGenerator->ConfigurationName.c_str());
 
   // Construct the full path version of the names.
-  std::string outpath = this->LocalGenerator->LibraryOutputPath;
-  if(outpath.length() == 0)
-    {
-    outpath = this->Makefile->GetStartOutputDirectory();
-    outpath += "/";
-    }
+  std::string outpath;
   if(relink)
     {
     outpath = this->Makefile->GetStartOutputDirectory();
@@ -259,6 +254,11 @@
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
     }
+  else
+    {
+    outpath = this->Target->GetOutputDir();
+    outpath += "/";
+    }
   std::string targetFullPath = outpath + targetName;
   std::string targetFullPathPDB = outpath + targetNamePDB;
   std::string targetFullPathSO = outpath + targetNameSO;

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- cmTarget.h	23 Feb 2007 14:46:27 -0000	1.73
+++ cmTarget.h	8 Mar 2007 19:57:28 -0000	1.74
@@ -213,6 +213,9 @@
       makefile and the configuration type.  */
   std::string GetFullPath(const char* config=0, bool implib = false);
 
+  /** Get the full path to the target output directory.  */
+  const char* GetOutputDir();
+
   /** Get the names of the library needed to generate a build rule
       that takes into account shared library version numbers.  This
       should be called only on a library target.  */
@@ -357,6 +360,7 @@
   bool HaveInstallRule;
   std::string InstallPath;
   std::string RuntimeInstallPath;
+  std::string OutputDir;
   std::string Directory;
   std::string Location;
   std::set<cmStdString> Utilities;

Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmMakefileExecutableTargetGenerator.cxx	8 Mar 2007 15:31:03 -0000	1.27
+++ cmMakefileExecutableTargetGenerator.cxx	8 Mar 2007 19:57:28 -0000	1.28
@@ -116,12 +116,8 @@
      this->LocalGenerator->ConfigurationName.c_str());
 
   // Construct the full path version of the names.
-  std::string outpath = this->LocalGenerator->ExecutableOutputPath;
-  if(outpath.length() == 0)
-    {
-    outpath = this->Makefile->GetStartOutputDirectory();
-    outpath += "/";
-    }
+  std::string outpath = this->Target->GetOutputDir();
+  outpath += "/";
 #ifdef __APPLE__
   if(this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
     {

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- cmLocalUnixMakefileGenerator3.cxx	8 Mar 2007 19:15:45 -0000	1.199
+++ cmLocalUnixMakefileGenerator3.cxx	8 Mar 2007 19:57:28 -0000	1.200
@@ -78,8 +78,17 @@
 //----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::Generate()
 {
-  // Setup our configuration variables for this directory.
-  this->ConfigureOutputPaths();
+  // Store the configuration name that will be generated.
+  if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
+    {
+    // Use the build type given by the user.
+    this->ConfigurationName = config;
+    }
+  else
+    {
+    // No configuration type given.
+    this->ConfigurationName = "";
+    }
 
   // Record whether some options are enabled to avoid checking many
   // times later.
@@ -182,66 +191,6 @@
 }
 
 //----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::ConfigureOutputPaths()
-{
-  // Format the library and executable output paths.
-  if(const char* libOut = 
-     this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
-    {
-    this->LibraryOutputPath = libOut;
-    this->FormatOutputPath(this->LibraryOutputPath, "LIBRARY");
-    }
-  if(const char* exeOut = 
-     this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
-    {
-    this->ExecutableOutputPath = exeOut;
-    this->FormatOutputPath(this->ExecutableOutputPath, "EXECUTABLE");
-    }
-
-  // Store the configuration name that will be generated.
-  if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
-    {
-    // Use the build type given by the user.
-    this->ConfigurationName = config;
-    }
-  else
-    {
-    // No configuration type given.
-    this->ConfigurationName = "";
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::FormatOutputPath(std::string& path,
-                                                     const char* name)
-{
-  if(!path.empty())
-    {
-    // Convert the output path to a full path in case it is
-    // specified as a relative path.  Treat a relative path as
-    // relative to the current output directory for this makefile.
-    path = cmSystemTools::CollapseFullPath
-      (path.c_str(), this->Makefile->GetStartOutputDirectory());
-
-    // Add a trailing slash for easy appending later.
-    if(path.empty() || path[path.size()-1] != '/')
-      {
-      path += "/";
-      }
-
-    // Make sure the output path exists on disk.
-    if(!cmSystemTools::MakeDirectory(path.c_str()))
-      {
-      cmSystemTools::Error("Error failed to create ",
-                           name, "_OUTPUT_PATH directory:", path.c_str());
-      }
-
-    // Add this as a link directory automatically.
-    this->Makefile->AddLinkDirectory(path.c_str());
-    }
-}
-
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
 {
   // generate the includes

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- cmMakefileTargetGenerator.cxx	8 Mar 2007 15:31:03 -0000	1.56
+++ cmMakefileTargetGenerator.cxx	8 Mar 2007 19:57:28 -0000	1.57
@@ -466,16 +466,13 @@
   {
   std::string targetFullPathPDB;
   const char* configName = this->LocalGenerator->ConfigurationName.c_str();
-  if(this->Target->GetType() == cmTarget::EXECUTABLE)
-    {
-    targetFullPathPDB = this->LocalGenerator->ExecutableOutputPath;
-    targetFullPathPDB += this->Target->GetPDBName(configName);
-    }
-  else if(this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
-          this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
-          this->Target->GetType() == cmTarget::MODULE_LIBRARY)
+  if(this->Target->GetType() == cmTarget::EXECUTABLE ||
+     this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
+     this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+     this->Target->GetType() == cmTarget::MODULE_LIBRARY)
     {
-    targetFullPathPDB = this->LocalGenerator->LibraryOutputPath;
+    targetFullPathPDB = this->Target->GetOutputDir();
+    targetFullPathPDB += "/";
     targetFullPathPDB += this->Target->GetPDBName(configName);
     }
   targetOutPathPDB =

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- cmTarget.cxx	23 Feb 2007 14:46:27 -0000	1.124
+++ cmTarget.cxx	8 Mar 2007 19:57:28 -0000	1.125
@@ -1093,34 +1093,7 @@
 
 const char* cmTarget::GetDirectory(const char* config)
 {
-  switch( this->GetType() )
-    {
-    case cmTarget::STATIC_LIBRARY:
-    case cmTarget::MODULE_LIBRARY:
-    case cmTarget::SHARED_LIBRARY:
-      this->Directory = 
-        this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
-      break;
-    case cmTarget::EXECUTABLE:
-      this->Directory = 
-        this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
-      break;
-    default:
-      this->Directory = this->Makefile->GetStartOutputDirectory();
-      break;
-    }
-  if(this->Directory.empty())
-    {
-    this->Directory = this->Makefile->GetStartOutputDirectory();
-    }
-  // if LIBRARY_OUTPUT_PATH or EXECUTABLE_OUTPUT_PATH was relative
-  // then make them full paths because this directory MUST 
-  // be a full path or things will not work!!!
-  if(!cmSystemTools::FileIsFullPath(this->Directory.c_str()))
-    {
-    this->Directory = this->Makefile->GetCurrentOutputDirectory() + 
-      std::string("/") + this->Directory;
-    }
+  this->Directory = this->GetOutputDir();
   if(config)
     {
     // Add the configuration's subdirectory.
@@ -1956,3 +1929,50 @@
     return "";
     }
 }
+
+//----------------------------------------------------------------------------
+const char* cmTarget::GetOutputDir()
+{
+  if(this->OutputDir.empty())
+    {
+    // Lookup the output path for this target type.
+    switch(this->GetType())
+      {
+      case cmTarget::STATIC_LIBRARY:
+      case cmTarget::MODULE_LIBRARY:
+      case cmTarget::SHARED_LIBRARY:
+        this->OutputDir =
+          this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
+        break;
+      case cmTarget::EXECUTABLE:
+        this->OutputDir =
+          this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
+        break;
+      }
+    if(this->OutputDir.empty())
+      {
+      this->OutputDir = ".";
+      }
+
+    // Convert the output path to a full path in case it is
+    // specified as a relative path.  Treat a relative path as
+    // relative to the current output directory for this makefile.
+    this->OutputDir =
+      cmSystemTools::CollapseFullPath
+      (this->OutputDir.c_str(), this->Makefile->GetStartOutputDirectory());
+
+    // Make sure the output path exists on disk.
+    if(!cmSystemTools::MakeDirectory(this->OutputDir.c_str()))
+      {
+      cmSystemTools::Error("Error failed to create output directory:",
+                           this->OutputDir.c_str());
+      }
+
+    // TODO: This came from cmLocalUnixMakefileGenerator3::FormatOutputPath.
+    // Where should it go.  Is it still needed?
+    // Add this as a link directory automatically.
+    // this->Makefile->AddLinkDirectory(path.c_str());
+    }
+
+  return this->OutputDir.c_str();
+}



More information about the Cmake-commits mailing list