cmGeneratorTarget: Move GetTargetVersion from cmTarget.
This commit is contained in:
parent
1427227720
commit
12e4790a0b
@ -4398,6 +4398,44 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const
|
|||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
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
|
void
|
||||||
cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
|
cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
|
||||||
|
@ -445,6 +445,17 @@ public:
|
|||||||
|
|
||||||
const char* ImportedGetLocation(const std::string& config) const;
|
const char* ImportedGetLocation(const std::string& config) const;
|
||||||
|
|
||||||
|
/** 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) const;
|
||||||
|
|
||||||
|
/** 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) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class cmTargetTraceDependencies;
|
friend class cmTargetTraceDependencies;
|
||||||
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
|
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
|
||||||
|
@ -2422,7 +2422,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||||||
int patch;
|
int patch;
|
||||||
|
|
||||||
// VERSION -> current_version
|
// VERSION -> current_version
|
||||||
target.GetTargetVersion(false, major, minor, patch);
|
gtgt->GetTargetVersion(false, major, minor, patch);
|
||||||
std::ostringstream v;
|
std::ostringstream v;
|
||||||
|
|
||||||
// Xcode always wants at least 1.0.0 or nothing
|
// Xcode always wants at least 1.0.0 or nothing
|
||||||
@ -2434,7 +2434,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
|||||||
this->CreateString(v.str().c_str()));
|
this->CreateString(v.str().c_str()));
|
||||||
|
|
||||||
// SOVERSION -> compatibility_version
|
// SOVERSION -> compatibility_version
|
||||||
target.GetTargetVersion(true, major, minor, patch);
|
gtgt->GetTargetVersion(true, major, minor, patch);
|
||||||
std::ostringstream vso;
|
std::ostringstream vso;
|
||||||
|
|
||||||
// Xcode always wants at least 1.0.0 or nothing
|
// Xcode always wants at least 1.0.0 or nothing
|
||||||
|
@ -1319,7 +1319,7 @@ void cmLocalVisualStudio6Generator
|
|||||||
{
|
{
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
target.GetTargetVersion(major, minor);
|
gt->GetTargetVersion(major, minor);
|
||||||
std::ostringstream targetVersionStream;
|
std::ostringstream targetVersionStream;
|
||||||
targetVersionStream << "/version:" << major << "." << minor;
|
targetVersionStream << "/version:" << major << "." << minor;
|
||||||
targetVersionFlag = targetVersionStream.str();
|
targetVersionFlag = targetVersionStream.str();
|
||||||
|
@ -1215,7 +1215,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||||||
temp += targetNameFull;
|
temp += targetNameFull;
|
||||||
fout << "\t\t\t\tOutputFile=\""
|
fout << "\t\t\t\tOutputFile=\""
|
||||||
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
|
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
|
||||||
this->WriteTargetVersionAttribute(fout, target);
|
this->WriteTargetVersionAttribute(fout, gt);
|
||||||
linkOptions.OutputFlagMap(fout, "\t\t\t\t");
|
linkOptions.OutputFlagMap(fout, "\t\t\t\t");
|
||||||
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
|
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
|
||||||
this->OutputLibraryDirectories(fout, cli.GetDirectories());
|
this->OutputLibraryDirectories(fout, cli.GetDirectories());
|
||||||
@ -1314,7 +1314,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||||||
temp += targetNameFull;
|
temp += targetNameFull;
|
||||||
fout << "\t\t\t\tOutputFile=\""
|
fout << "\t\t\t\tOutputFile=\""
|
||||||
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
|
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
|
||||||
this->WriteTargetVersionAttribute(fout, target);
|
this->WriteTargetVersionAttribute(fout, gt);
|
||||||
linkOptions.OutputFlagMap(fout, "\t\t\t\t");
|
linkOptions.OutputFlagMap(fout, "\t\t\t\t");
|
||||||
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
|
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
|
||||||
this->OutputLibraryDirectories(fout, cli.GetDirectories());
|
this->OutputLibraryDirectories(fout, cli.GetDirectories());
|
||||||
@ -1384,11 +1384,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalVisualStudio7Generator
|
cmLocalVisualStudio7Generator
|
||||||
::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
|
::WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt)
|
||||||
{
|
{
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
target.GetTargetVersion(major, minor);
|
gt->GetTargetVersion(major, minor);
|
||||||
fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
|
fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ private:
|
|||||||
const char* source,
|
const char* source,
|
||||||
const cmCustomCommand& command,
|
const cmCustomCommand& command,
|
||||||
FCInfo& fcinfo);
|
FCInfo& fcinfo);
|
||||||
void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
|
void WriteTargetVersionAttribute(std::ostream& fout,
|
||||||
|
cmGeneratorTarget* gt);
|
||||||
|
|
||||||
bool WriteGroup(const cmSourceGroup *sg,
|
bool WriteGroup(const cmSourceGroup *sg,
|
||||||
cmTarget& target, std::ostream &fout,
|
cmTarget& target, std::ostream &fout,
|
||||||
|
@ -382,7 +382,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
std::ostringstream minorStream;
|
std::ostringstream minorStream;
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
this->Target->GetTargetVersion(major, minor);
|
this->GeneratorTarget->GetTargetVersion(major, minor);
|
||||||
majorStream << major;
|
majorStream << major;
|
||||||
minorStream << minor;
|
minorStream << minor;
|
||||||
targetVersionMajor = majorStream.str();
|
targetVersionMajor = majorStream.str();
|
||||||
|
@ -630,7 +630,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
std::ostringstream minorStream;
|
std::ostringstream minorStream;
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
this->Target->GetTargetVersion(major, minor);
|
this->GeneratorTarget->GetTargetVersion(major, minor);
|
||||||
majorStream << major;
|
majorStream << major;
|
||||||
minorStream << minor;
|
minorStream << minor;
|
||||||
targetVersionMajor = majorStream.str();
|
targetVersionMajor = majorStream.str();
|
||||||
@ -862,7 +862,7 @@ cmMakefileLibraryTargetGenerator
|
|||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
int patch;
|
int patch;
|
||||||
this->Target->GetTargetVersion(so, major, minor, patch);
|
this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
|
||||||
if(major > 0 || minor > 0 || patch > 0)
|
if(major > 0 || minor > 0 || patch > 0)
|
||||||
{
|
{
|
||||||
// Append the flag since a non-zero version is specified.
|
// Append the flag since a non-zero version is specified.
|
||||||
|
@ -227,7 +227,7 @@ cmNinjaNormalTargetGenerator
|
|||||||
std::ostringstream minorStream;
|
std::ostringstream minorStream;
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
this->GetTarget()->GetTargetVersion(major, minor);
|
this->GetGeneratorTarget()->GetTargetVersion(major, minor);
|
||||||
majorStream << major;
|
majorStream << major;
|
||||||
minorStream << minor;
|
minorStream << minor;
|
||||||
targetVersionMajor = majorStream.str();
|
targetVersionMajor = majorStream.str();
|
||||||
|
@ -1615,44 +1615,6 @@ bool cmTarget::HaveWellDefinedOutputFiles() const
|
|||||||
this->GetType() == cmState::EXECUTABLE;
|
this->GetType() == cmState::EXECUTABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmTarget::GetTargetVersion(int& major, int& minor) const
|
|
||||||
{
|
|
||||||
int patch;
|
|
||||||
this->GetTargetVersion(false, major, minor, patch);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmTarget::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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
|
bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
|
||||||
{
|
{
|
||||||
|
@ -213,17 +213,6 @@ public:
|
|||||||
|
|
||||||
bool IsImported() const {return this->IsImportedTarget;}
|
bool IsImported() const {return this->IsImportedTarget;}
|
||||||
|
|
||||||
/** 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) const;
|
|
||||||
|
|
||||||
/** 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) const;
|
|
||||||
|
|
||||||
// Get the properties
|
// Get the properties
|
||||||
cmPropertyMap &GetProperties() const { return this->Properties; }
|
cmPropertyMap &GetProperties() const { return this->Properties; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user