From da4f142cc12cf603f7d34562d558c0ed7bd65d5f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Jul 2008 10:09:00 -0400 Subject: ENH: Add full target version signature cmTarget::GetTargetVersion. --- Source/cmTarget.cxx | 19 ++++++++++++++++--- Source/cmTarget.h | 5 +++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c4cc793..6e81a1a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1756,19 +1756,32 @@ const char* cmTarget::NormalGetLocation(const char* config) //---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(int& major, int& minor) { + int patch; + this->GetTargetVersion(false, major, minor, patch); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetTargetVersion(bool soversion, + int& major, int& minor, int& patch) +{ // Set the default values. major = 0; minor = 0; + patch = 0; - // Look for a VERSION property. - if(const char* version = this->GetProperty("VERSION")) + // 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; - switch(sscanf(version, "%d.%d", &parsed_major, &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; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index af94876..8ec2e1f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -265,6 +265,11 @@ public: not set or cannot be parsed. */ void GetTargetVersion(int& major, int& minor); + /** 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); + /** * Trace through the source files in this target and add al source files * that they depend on, used by all generators -- cgit v0.12