diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 16 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 13 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.h | 1 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmSetTargetPropertiesCommand.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 38 | ||||
-rw-r--r-- | Source/cmTarget.h | 5 |
10 files changed, 137 insertions, 2 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d0fc68f..0b0594c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -840,6 +840,28 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, { 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") diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 53b4220..fc59ed5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -185,6 +185,8 @@ public: memset(this, 0, sizeof(*this)); } const char* TargetPDB; + const char* TargetVersionMajor; + const char* TargetVersionMinor; const char* Language; const char* Objects; const char* Target; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 4295ce8..a24b14b 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1131,6 +1131,20 @@ void cmLocalVisualStudio6Generator } } + // 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 @@ void cmLocalVisualStudio6Generator 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, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 0fbca35..262d92e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -801,6 +801,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, 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 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, 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::OutputBuildTool(std::ostream& fout, } } +//---------------------------------------------------------------------------- +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) diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d52cc63..48dce0c 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -112,6 +112,7 @@ private: 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, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 65e2877..4b24a19a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -372,6 +372,24 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) 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(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index dc7d37d..d80fc7e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -531,6 +531,24 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules 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(); diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 86cb41a..cf777a6 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -108,7 +108,11 @@ public: "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). " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9ac85ee..18cce53 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -890,6 +890,29 @@ const char* cmTarget::GetLocation(const char* config) 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 @@ void cmTarget::GetExecutableNamesInternal(std::string& name, } #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 } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8b05958..dc39f80 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -176,6 +176,11 @@ public: 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 |