[cmake-commits] king committed cmLocalGenerator.cxx 1.161 1.162 cmLocalGenerator.h 1.68 1.69 cmLocalVisualStudio6Generator.cxx 1.105 1.106 cmLocalVisualStudio7Generator.cxx 1.153 1.154 cmLocalVisualStudio7Generator.h 1.26 1.27 cmMakefileExecutableTargetGenerator.cxx 1.21 1.22 cmMakefileLibraryTargetGenerator.cxx 1.27 1.28 cmSetTargetPropertiesCommand.h 1.26 1.27 cmTarget.cxx 1.105 1.106 cmTarget.h 1.64 1.65

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Oct 16 18:17:16 EDT 2006


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

Modified Files:
	cmLocalGenerator.cxx cmLocalGenerator.h 
	cmLocalVisualStudio6Generator.cxx 
	cmLocalVisualStudio7Generator.cxx 
	cmLocalVisualStudio7Generator.h 
	cmMakefileExecutableTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmSetTargetPropertiesCommand.h cmTarget.cxx cmTarget.h 
Log Message:
ENH: Adding image version number (major.minor) property to windows binaries.  Default is 0.0, but the VERSION target property may change the value.  Windows now has first-class support for dll and exe versioning.  This addresses bug#1219.


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- cmLocalVisualStudio7Generator.cxx	13 Oct 2006 20:13:14 -0000	1.153
+++ cmLocalVisualStudio7Generator.cxx	16 Oct 2006 22:17:14 -0000	1.154
@@ -801,6 +801,7 @@
     temp += targetFullName;
     fout << "\t\t\t\tOutputFile=\""
          << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+    this->WriteTargetVersionAttribute(fout, target);
     for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
         i != flagMap.end(); ++i)
       {
@@ -885,6 +886,7 @@
     temp += targetFullName;
     fout << "\t\t\t\tOutputFile=\"" 
          << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+    this->WriteTargetVersionAttribute(fout, target);
     for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
         i != flagMap.end(); ++i)
       {
@@ -925,6 +927,17 @@
     }
 }
 
+//----------------------------------------------------------------------------
+void
+cmLocalVisualStudio7Generator
+::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
+{
+  int major;
+  int minor;
+  target.GetTargetVersion(major, minor);
+  fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
+}
+
 void cmLocalVisualStudio7Generator
 ::OutputModuleDefinitionFile(std::ostream& fout,
                              cmTarget &target)

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmLocalVisualStudio7Generator.h	28 Sep 2006 20:40:35 -0000	1.26
+++ cmLocalVisualStudio7Generator.h	16 Oct 2006 22:17:14 -0000	1.27
@@ -112,6 +112,7 @@
                        const std::vector<std::string>& depends,
                        const std::vector<std::string>& outputs,
                        const char* extraFlags);
+  void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
 
   void WriteGroup(const cmSourceGroup *sg, 
                   cmTarget target, std::ostream &fout, 

Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- cmLocalGenerator.cxx	13 Oct 2006 14:03:54 -0000	1.161
+++ cmLocalGenerator.cxx	16 Oct 2006 22:17:14 -0000	1.162
@@ -840,6 +840,28 @@
       {
       return this->TargetImplib;
       }
+    if(variable == "TARGET_VERSION_MAJOR")
+      {
+      if(replaceValues.TargetVersionMajor)
+        {
+        return replaceValues.TargetVersionMajor;
+        }
+      else
+        {
+        return "0";
+        }
+      }
+    if(variable == "TARGET_VERSION_MINOR")
+      {
+      if(replaceValues.TargetVersionMinor)
+        {
+        return replaceValues.TargetVersionMinor;
+        }
+      else
+        {
+        return "0";
+        }
+      }
     if(replaceValues.Target)
       {
       if(variable == "TARGET_BASE")

Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- cmLocalVisualStudio6Generator.cxx	27 Sep 2006 17:43:45 -0000	1.105
+++ cmLocalVisualStudio6Generator.cxx	16 Oct 2006 22:17:14 -0000	1.106
@@ -1131,6 +1131,20 @@
       }
     }
 
+  // Compute version number information.
+  std::string targetVersionFlag;
+  if(target.GetType() == cmTarget::EXECUTABLE ||
+     target.GetType() == cmTarget::SHARED_LIBRARY ||
+     target.GetType() == cmTarget::MODULE_LIBRARY)
+    {
+    int major;
+    int minor;
+    target.GetTargetVersion(major, minor);
+    cmOStringStream targetVersionStream;
+    targetVersionStream << "/version:" << major << "." << minor;
+    targetVersionFlag = targetVersionStream.str();
+    }
+
   // Compute the real name of the target.
   std::string outputName = 
     "(OUTPUT_NAME is for libraries and executables only)";
@@ -1279,6 +1293,8 @@
 
     cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
                                  this->IncludeOptions.c_str());
+    cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
+                                 targetVersionFlag.c_str());
     cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
     // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH 
     // are already quoted in the template file,

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmMakefileLibraryTargetGenerator.cxx	13 Oct 2006 17:59:59 -0000	1.27
+++ cmMakefileLibraryTargetGenerator.cxx	16 Oct 2006 22:17:14 -0000	1.28
@@ -531,6 +531,24 @@
   cleanObjs += ")";
   cmLocalGenerator::RuleVariables vars;
   vars.TargetPDB = targetOutPathPDB.c_str();
+
+  // Setup the target version.
+  std::string targetVersionMajor;
+  std::string targetVersionMinor;
+  {
+  cmOStringStream majorStream;
+  cmOStringStream minorStream;
+  int major;
+  int minor;
+  this->Target->GetTargetVersion(major, minor);
+  majorStream << major;
+  minorStream << minor;
+  targetVersionMajor = majorStream.str();
+  targetVersionMinor = minorStream.str();
+  }
+  vars.TargetVersionMajor = targetVersionMajor.c_str();
+  vars.TargetVersionMinor = targetVersionMinor.c_str();
+
   vars.Language = linkLanguage;
   vars.Objects = buildObjs.c_str();
   std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash();

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- cmTarget.h	19 May 2006 17:02:12 -0000	1.64
+++ cmTarget.h	16 Oct 2006 22:17:14 -0000	1.65
@@ -176,6 +176,11 @@
       target property.  */
   const char* GetLocation(const char* config);
 
+  /** 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);
+
   /**
    * Trace through the source files in this target and add al source files
    * that they depend on, used by the visual studio generators

Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cmMakefileExecutableTargetGenerator.cxx	28 Sep 2006 20:40:35 -0000	1.21
+++ cmMakefileExecutableTargetGenerator.cxx	16 Oct 2006 22:17:14 -0000	1.22
@@ -372,6 +372,24 @@
   vars.Objects = buildObjs.c_str();
   vars.Target = targetOutPathReal.c_str();
   vars.TargetPDB = targetOutPathPDB.c_str();
+
+  // Setup the target version.
+  std::string targetVersionMajor;
+  std::string targetVersionMinor;
+  {
+  cmOStringStream majorStream;
+  cmOStringStream minorStream;
+  int major;
+  int minor;
+  this->Target->GetTargetVersion(major, minor);
+  majorStream << major;
+  minorStream << minor;
+  targetVersionMajor = majorStream.str();
+  targetVersionMinor = minorStream.str();
+  }
+  vars.TargetVersionMajor = targetVersionMajor.c_str();
+  vars.TargetVersionMinor = targetVersionMinor.c_str();
+
   std::string linkString = linklibs.str();
   vars.LinkLibraries = linkString.c_str();
   vars.Flags = flags.c_str();

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- cmLocalGenerator.h	4 Oct 2006 22:52:29 -0000	1.68
+++ cmLocalGenerator.h	16 Oct 2006 22:17:14 -0000	1.69
@@ -185,6 +185,8 @@
         memset(this, 0,  sizeof(*this));
       }
     const char* TargetPDB;
+    const char* TargetVersionMajor;
+    const char* TargetVersionMinor;
     const char* Language;
     const char* Objects;
     const char* Target;

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- cmTarget.cxx	5 Oct 2006 20:30:47 -0000	1.105
+++ cmTarget.cxx	16 Oct 2006 22:17:14 -0000	1.106
@@ -890,6 +890,29 @@
   return this->Location.c_str();
 }
 
+//----------------------------------------------------------------------------
+void cmTarget::GetTargetVersion(int& major, int& minor)
+{
+  // Set the default values.
+  major = 0;
+  minor = 0;
+
+  // Look for a VERSION property.
+  if(const char* version = this->GetProperty("VERSION"))
+    {
+    // Try to parse the version number and store the results that were
+    // successfully parsed.
+    int parsed_major;
+    int parsed_minor;
+    switch(sscanf(version, "%d.%d", &parsed_major, &parsed_minor))
+      {
+      case 2: minor = parsed_minor; // no break!
+      case 1: major = parsed_major; // no break!
+      default: break;
+      }
+    }
+}
+
 const char *cmTarget::GetProperty(const char* prop)
 {
   // watch for special "computed" properties that are dependent on other
@@ -1442,16 +1465,29 @@
     }
 #endif
 
+  // Get the components of the executable name.
+  std::string prefix;
+  std::string base;
+  std::string suffix;
+  this->GetFullNameInternal(type, config, false, prefix, base, suffix);
+
   // The executable name.
-  name = this->GetFullNameInternal(type, config, false);
+  name = prefix+base+suffix;
 
   // The executable's real name on disk.
+#if defined(__CYGWIN__)
+  realName = prefix+base;
+#else
   realName = name;
+#endif
   if(version)
     {
     realName += "-";
     realName += version;
     }
+#if defined(__CYGWIN__)
+  realName += suffix;
+#endif
 }
 
 //----------------------------------------------------------------------------

Index: cmSetTargetPropertiesCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetTargetPropertiesCommand.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmSetTargetPropertiesCommand.h	3 Aug 2006 13:42:48 -0000	1.26
+++ cmSetTargetPropertiesCommand.h	16 Oct 2006 22:17:14 -0000	1.27
@@ -108,7 +108,11 @@
         "the same version number. "
         "For executables VERSION can be used to specify the build version. "
         "When building or installing appropriate symlinks are created if "
-        "the platform supports symlinks.\n"
+        "the platform supports symlinks. "
+        "For shared libraries and executables on Windows the VERSION "
+        "attribute is parsed to extract a \"major.minor\" version number. "
+        "These numbers are used as the image version of the binary. "
+        "\n"
         "There are a few properties used to specify RPATH rules. "
         "INSTALL_RPATH is a semicolon-separated list specifying the rpath "
         "to use in installed targets (for platforms that support it). "



More information about the Cmake-commits mailing list