summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-07-09 14:09:00 (GMT)
committerBrad King <brad.king@kitware.com>2008-07-09 14:09:00 (GMT)
commitda4f142cc12cf603f7d34562d558c0ed7bd65d5f (patch)
treecc4edfa216e0fc4485e1f094f94578d30305c3ef /Source
parentba8452420738a1adf58186367eeb24de3c7a56e5 (diff)
downloadCMake-da4f142cc12cf603f7d34562d558c0ed7bd65d5f.zip
CMake-da4f142cc12cf603f7d34562d558c0ed7bd65d5f.tar.gz
CMake-da4f142cc12cf603f7d34562d558c0ed7bd65d5f.tar.bz2
ENH: Add full target version signature cmTarget::GetTargetVersion.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTarget.cxx19
-rw-r--r--Source/cmTarget.h5
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