Bläddra i källkod

cmGeneratorTarget: Move GetTargetVersion from cmTarget.

Stephen Kelly 10 år sedan
förälder
incheckning
12e4790a0b

+ 38 - 0
Source/cmGeneratorTarget.cxx

@@ -4398,6 +4398,44 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const
   return i->second;
 }
 
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const
+{
+  int patch;
+  this->GetTargetVersion(false, major, minor, patch);
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GetTargetVersion(bool soversion,
+                                int& major, int& minor, int& patch) const
+{
+  // Set the default values.
+  major = 0;
+  minor = 0;
+  patch = 0;
+
+  assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+
+  // Look for a VERSION or SOVERSION property.
+  const char* prop = soversion? "SOVERSION" : "VERSION";
+  if(const char* version = this->GetProperty(prop))
+    {
+    // Try to parse the version number and store the results that were
+    // successfully parsed.
+    int parsed_major;
+    int parsed_minor;
+    int parsed_patch;
+    switch(sscanf(version, "%d.%d.%d",
+                  &parsed_major, &parsed_minor, &parsed_patch))
+      {
+      case 3: patch = parsed_patch; // no break!
+      case 2: minor = parsed_minor; // no break!
+      case 1: major = parsed_major; // no break!
+      default: break;
+      }
+    }
+}
+
 //----------------------------------------------------------------------------
 void
 cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,

+ 11 - 0
Source/cmGeneratorTarget.h

@@ -445,6 +445,17 @@ public:
 
   const char* ImportedGetLocation(const std::string& config) const;
 
+  /** Get the target major and minor version numbers interpreted from
+      the VERSION property.  Version 0 is returned if the property is
+      not set or cannot be parsed.  */
+  void GetTargetVersion(int& major, int& minor) const;
+
+  /** Get the target major, minor, and patch version numbers
+      interpreted from the VERSION or SOVERSION property.  Version 0
+      is returned if the property is not set or cannot be parsed.  */
+  void
+  GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
+
 private:
   friend class cmTargetTraceDependencies;
   struct SourceEntry { std::vector<cmSourceFile*> Depends; };

+ 2 - 2
Source/cmGlobalXCodeGenerator.cxx

@@ -2422,7 +2422,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
     int patch;
 
     // VERSION -> current_version
-    target.GetTargetVersion(false, major, minor, patch);
+    gtgt->GetTargetVersion(false, major, minor, patch);
     std::ostringstream v;
 
     // Xcode always wants at least 1.0.0 or nothing
@@ -2434,7 +2434,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
                                 this->CreateString(v.str().c_str()));
 
     // SOVERSION -> compatibility_version
-    target.GetTargetVersion(true, major, minor, patch);
+    gtgt->GetTargetVersion(true, major, minor, patch);
     std::ostringstream vso;
 
     // Xcode always wants at least 1.0.0 or nothing

+ 1 - 1
Source/cmLocalVisualStudio6Generator.cxx

@@ -1319,7 +1319,7 @@ void cmLocalVisualStudio6Generator
     {
     int major;
     int minor;
-    target.GetTargetVersion(major, minor);
+    gt->GetTargetVersion(major, minor);
     std::ostringstream targetVersionStream;
     targetVersionStream << "/version:" << major << "." << minor;
     targetVersionFlag = targetVersionStream.str();

+ 4 - 4
Source/cmLocalVisualStudio7Generator.cxx

@@ -1215,7 +1215,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
     temp += targetNameFull;
     fout << "\t\t\t\tOutputFile=\""
          << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
-    this->WriteTargetVersionAttribute(fout, target);
+    this->WriteTargetVersionAttribute(fout, gt);
     linkOptions.OutputFlagMap(fout, "\t\t\t\t");
     fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
     this->OutputLibraryDirectories(fout, cli.GetDirectories());
@@ -1314,7 +1314,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
     temp += targetNameFull;
     fout << "\t\t\t\tOutputFile=\""
          << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
-    this->WriteTargetVersionAttribute(fout, target);
+    this->WriteTargetVersionAttribute(fout, gt);
     linkOptions.OutputFlagMap(fout, "\t\t\t\t");
     fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
     this->OutputLibraryDirectories(fout, cli.GetDirectories());
@@ -1384,11 +1384,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
 //----------------------------------------------------------------------------
 void
 cmLocalVisualStudio7Generator
-::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
+::WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt)
 {
   int major;
   int minor;
-  target.GetTargetVersion(major, minor);
+  gt->GetTargetVersion(major, minor);
   fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
 }
 

+ 2 - 1
Source/cmLocalVisualStudio7Generator.h

@@ -106,7 +106,8 @@ private:
                        const char* source,
                        const cmCustomCommand& command,
                        FCInfo& fcinfo);
-  void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
+  void WriteTargetVersionAttribute(std::ostream& fout,
+                                   cmGeneratorTarget* gt);
 
   bool WriteGroup(const cmSourceGroup *sg,
                   cmTarget& target, std::ostream &fout,

+ 1 - 1
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -382,7 +382,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   std::ostringstream minorStream;
   int major;
   int minor;
-  this->Target->GetTargetVersion(major, minor);
+  this->GeneratorTarget->GetTargetVersion(major, minor);
   majorStream << major;
   minorStream << minor;
   targetVersionMajor = majorStream.str();

+ 2 - 2
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -630,7 +630,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::ostringstream minorStream;
   int major;
   int minor;
-  this->Target->GetTargetVersion(major, minor);
+  this->GeneratorTarget->GetTargetVersion(major, minor);
   majorStream << major;
   minorStream << minor;
   targetVersionMajor = majorStream.str();
@@ -862,7 +862,7 @@ cmMakefileLibraryTargetGenerator
   int major;
   int minor;
   int patch;
-  this->Target->GetTargetVersion(so, major, minor, patch);
+  this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
   if(major > 0 || minor > 0 || patch > 0)
     {
     // Append the flag since a non-zero version is specified.

+ 1 - 1
Source/cmNinjaNormalTargetGenerator.cxx

@@ -227,7 +227,7 @@ cmNinjaNormalTargetGenerator
     std::ostringstream minorStream;
     int major;
     int minor;
-    this->GetTarget()->GetTargetVersion(major, minor);
+    this->GetGeneratorTarget()->GetTargetVersion(major, minor);
     majorStream << major;
     minorStream << minor;
     targetVersionMajor = majorStream.str();

+ 0 - 38
Source/cmTarget.cxx

@@ -1615,44 +1615,6 @@ bool cmTarget::HaveWellDefinedOutputFiles() const
     this->GetType() == cmState::EXECUTABLE;
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::GetTargetVersion(int& major, int& minor) const
-{
-  int patch;
-  this->GetTargetVersion(false, major, minor, patch);
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GetTargetVersion(bool soversion,
-                                int& major, int& minor, int& patch) const
-{
-  // Set the default values.
-  major = 0;
-  minor = 0;
-  patch = 0;
-
-  assert(this->GetType() != cmState::INTERFACE_LIBRARY);
-
-  // Look for a VERSION or SOVERSION property.
-  const char* prop = soversion? "SOVERSION" : "VERSION";
-  if(const char* version = this->GetProperty(prop))
-    {
-    // Try to parse the version number and store the results that were
-    // successfully parsed.
-    int parsed_major;
-    int parsed_minor;
-    int parsed_patch;
-    switch(sscanf(version, "%d.%d.%d",
-                  &parsed_major, &parsed_minor, &parsed_patch))
-      {
-      case 3: patch = parsed_patch; // no break!
-      case 2: minor = parsed_minor; // no break!
-      case 1: major = parsed_major; // no break!
-      default: break;
-      }
-    }
-}
-
 //----------------------------------------------------------------------------
 bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
 {

+ 0 - 11
Source/cmTarget.h

@@ -213,17 +213,6 @@ public:
 
   bool IsImported() const {return this->IsImportedTarget;}
 
-  /** Get the target major and minor version numbers interpreted from
-      the VERSION property.  Version 0 is returned if the property is
-      not set or cannot be parsed.  */
-  void GetTargetVersion(int& major, int& minor) const;
-
-  /** Get the target major, minor, and patch version numbers
-      interpreted from the VERSION or SOVERSION property.  Version 0
-      is returned if the property is not set or cannot be parsed.  */
-  void
-  GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
-
   // Get the properties
   cmPropertyMap &GetProperties() const { return this->Properties; }