ENH: Add full target version signature cmTarget::GetTargetVersion.
This commit is contained in:
parent
ba84524207
commit
da4f142cc1
@ -1755,20 +1755,33 @@ const char* cmTarget::NormalGetLocation(const char* config)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTarget::GetTargetVersion(int& major, int& minor)
|
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.
|
// Set the default values.
|
||||||
major = 0;
|
major = 0;
|
||||||
minor = 0;
|
minor = 0;
|
||||||
|
patch = 0;
|
||||||
|
|
||||||
// Look for a VERSION property.
|
// Look for a VERSION or SOVERSION property.
|
||||||
if(const char* version = this->GetProperty("VERSION"))
|
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
|
// Try to parse the version number and store the results that were
|
||||||
// successfully parsed.
|
// successfully parsed.
|
||||||
int parsed_major;
|
int parsed_major;
|
||||||
int parsed_minor;
|
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 2: minor = parsed_minor; // no break!
|
||||||
case 1: major = parsed_major; // no break!
|
case 1: major = parsed_major; // no break!
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -265,6 +265,11 @@ public:
|
|||||||
not set or cannot be parsed. */
|
not set or cannot be parsed. */
|
||||||
void GetTargetVersion(int& major, int& minor);
|
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
|
* Trace through the source files in this target and add al source files
|
||||||
* that they depend on, used by all generators
|
* that they depend on, used by all generators
|
||||||
|
Loading…
x
Reference in New Issue
Block a user