diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-10-16 17:19:51 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-10-16 18:24:44 (GMT) |
commit | 12e4790a0b40d8176940f855f7f6c9cfe6c39f9f (patch) | |
tree | b23abcd5502f02ed491621cca09689666fd93d83 /Source/cmGeneratorTarget.cxx | |
parent | 14272277205ac7927a4c13b628ce411538f7b17c (diff) | |
download | CMake-12e4790a0b40d8176940f855f7f6c9cfe6c39f9f.zip CMake-12e4790a0b40d8176940f855f7f6c9cfe6c39f9f.tar.gz CMake-12e4790a0b40d8176940f855f7f6c9cfe6c39f9f.tar.bz2 |
cmGeneratorTarget: Move GetTargetVersion from cmTarget.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b6c2967..7e4c917 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4399,6 +4399,44 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } //---------------------------------------------------------------------------- +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, const std::string &result, |