summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-12-07 21:46:35 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-12-07 21:46:35 (GMT)
commit174ecf51f857031b0204a516df809814d4dc0386 (patch)
tree4009c61dc9f4c8360bd98cd940d8021f4253fabe
parent0ea95b99cebc23d9fbf7d50872176911f5f65f96 (diff)
parent96f65ba68e82b64eac67b75282bbcab8103c0eb0 (diff)
downloadCMake-174ecf51f857031b0204a516df809814d4dc0386.zip
CMake-174ecf51f857031b0204a516df809814d4dc0386.tar.gz
CMake-174ecf51f857031b0204a516df809814d4dc0386.tar.bz2
Merge topic 'refactor-versioned-lib-names'
96f65ba cmTarget: Create helper method for versioned library names
-rw-r--r--Source/cmTarget.cxx70
-rw-r--r--Source/cmTarget.h7
2 files changed, 37 insertions, 40 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 87f8c5e..d3715b8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -132,6 +132,7 @@ cmTarget::cmTarget()
this->LinkLibrariesAnalyzed = false;
this->HaveInstallRule = false;
this->DLLPlatform = false;
+ this->IsApple = false;
this->IsImportedTarget = false;
}
@@ -1216,6 +1217,9 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->Makefile->IsOn("CYGWIN") ||
this->Makefile->IsOn("MINGW"));
+ // Check whether we are targeting an Apple platform.
+ this->IsApple = this->Makefile->IsOn("APPLE");
+
// Setup default property values.
this->SetPropertyDefault("INSTALL_NAME_DIR", "");
this->SetPropertyDefault("INSTALL_RPATH", "");
@@ -3358,7 +3362,11 @@ void cmTarget::GetLibraryNames(std::string& name,
// the library version as the soversion.
soversion = version;
}
- bool isApple = this->Makefile->IsOn("APPLE");
+ if(!version && soversion)
+ {
+ // Use the soversion as the library version.
+ version = soversion;
+ }
// Get the components of the library name.
std::string prefix;
@@ -3370,47 +3378,12 @@ void cmTarget::GetLibraryNames(std::string& name,
name = prefix+base+suffix;
// The library's soname.
- if(isApple)
- {
- soName = prefix+base;
- }
- else
- {
- soName = name;
- }
- if(soversion)
- {
- soName += ".";
- soName += soversion;
- }
- if(isApple)
- {
- soName += suffix;
- }
+ this->ComputeVersionedName(soName, prefix, base, suffix,
+ name, soversion);
// The library's real name on disk.
- if(isApple)
- {
- realName = prefix+base;
- }
- else
- {
- realName = name;
- }
- if(version)
- {
- realName += ".";
- realName += version;
- }
- else if(soversion)
- {
- realName += ".";
- realName += soversion;
- }
- if(isApple)
- {
- realName += suffix;
- }
+ this->ComputeVersionedName(realName, prefix, base, suffix,
+ name, version);
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -3428,6 +3401,23 @@ void cmTarget::GetLibraryNames(std::string& name,
}
//----------------------------------------------------------------------------
+void cmTarget::ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version)
+{
+ vName = this->IsApple? (prefix+base) : name;
+ if(version)
+ {
+ vName += ".";
+ vName += version;
+ }
+ vName += this->IsApple? suffix : std::string();
+}
+
+//----------------------------------------------------------------------------
void cmTarget::GetExecutableNames(std::string& name,
std::string& realName,
std::string& impName,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 09fee6c..59f0184 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -565,6 +565,7 @@ private:
cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;
bool DLLPlatform;
+ bool IsApple;
bool IsImportedTarget;
// Cache target output paths for each configuration.
@@ -603,6 +604,12 @@ private:
cmTargetInternalPointer Internal;
void ConstructSourceFileFlags();
+ void ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version);
};
typedef std::map<cmStdString,cmTarget> cmTargets;