summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-04-22 20:11:00 (GMT)
committerBrad King <brad.king@kitware.com>2005-04-22 20:11:00 (GMT)
commitb1c528978705e7daab02660e19742bc4863fd8e9 (patch)
tree98a6bac0af6a3002c841cfda21f5337a76634a5f /Source/cmTarget.cxx
parent1b71f4477beeb41e3924993b5d4b78eadc092ec8 (diff)
downloadCMake-b1c528978705e7daab02660e19742bc4863fd8e9.zip
CMake-b1c528978705e7daab02660e19742bc4863fd8e9.tar.gz
CMake-b1c528978705e7daab02660e19742bc4863fd8e9.tar.bz2
ENH: Created cmTarget::GetLibraryNames to replace cmLocalUnixMakefileGenerator2::GetLibraryNames. Added cmTarget::GetLibraryCleanNames to be used by cmLocalUnixMakefileGenerator2. Now when a library is linked both the shared and static versions are removed from the build tree. In this way we avoid having both kinds of libraries present when the user switches BUILD_SHARED_LIBS on/off. This prevents problems with turning off shared libraries and then expecting the linker to use the static libraries only to find it is using the out-of-date shared versions.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx105
1 files changed, 105 insertions, 0 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 479947f..f186c99 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -974,3 +974,108 @@ cmTarget::GetBaseNameInternal(cmMakefile* mf, TargetType type) const
name += this->GetName();
return name;
}
+
+void cmTarget::GetLibraryNames(cmMakefile* mf,
+ std::string& name,
+ std::string& soName,
+ std::string& realName,
+ std::string& baseName) const
+{
+ // Get the names based on the real type of the library.
+ this->GetLibraryNamesInternal(mf, name, soName, realName, this->GetType());
+
+ // The library name without extension.
+ baseName = this->GetBaseName(mf);
+}
+
+void cmTarget::GetLibraryCleanNames(cmMakefile* mf,
+ std::string& staticName,
+ std::string& sharedName,
+ std::string& sharedSOName,
+ std::string& sharedRealName) const
+{
+ // Get the name as if this were a static library.
+ std::string soName;
+ std::string realName;
+ this->GetLibraryNamesInternal(mf, staticName, soName, realName,
+ cmTarget::STATIC_LIBRARY);
+
+ // Get the names as if this were a shared library.
+ if(this->GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ // Since the real type is static then the user either specified
+ // STATIC or did not specify a type. In the former case the
+ // shared library will never be present. In the latter case the
+ // type will never be MODULE. Either way the only names that
+ // might have to be cleaned are the shared library names.
+ this->GetLibraryNamesInternal(mf, sharedName, sharedSOName,
+ sharedRealName, cmTarget::SHARED_LIBRARY);
+ }
+ else
+ {
+ // Use the name of the real type of the library (shared or module).
+ this->GetLibraryNamesInternal(mf, sharedName, sharedSOName,
+ sharedRealName, this->GetType());
+ }
+}
+
+void cmTarget::GetLibraryNamesInternal(cmMakefile* mf,
+ std::string& name,
+ std::string& soName,
+ std::string& realName,
+ TargetType type) const
+{
+ // Construct the name of the soname flag variable for this language.
+ const char* ll =
+ this->GetLinkerLanguage(
+ mf->GetLocalGenerator()->GetGlobalGenerator());
+ std::string sonameFlag = "CMAKE_SHARED_LIBRARY_SONAME";
+ if(ll)
+ {
+ sonameFlag += "_";
+ sonameFlag += ll;
+ }
+ sonameFlag += "_FLAG";
+
+ // Check for library version properties.
+ const char* version = this->GetProperty("VERSION");
+ const char* soversion = this->GetProperty("SOVERSION");
+ if((type != cmTarget::SHARED_LIBRARY && type != cmTarget::MODULE_LIBRARY) ||
+ !mf->GetDefinition(sonameFlag.c_str()))
+ {
+ // Versioning is supported only for shared libraries and modules,
+ // and then only when the platform supports an soname flag.
+ version = 0;
+ soversion = 0;
+ }
+ if(version && !soversion)
+ {
+ // The soversion must be set if the library version is set. Use
+ // the library version as the soversion.
+ soversion = version;
+ }
+
+ // The library name.
+ name = this->GetFullNameInternal(mf, type);
+
+ // The library's soname.
+ soName = name;
+ if(soversion)
+ {
+ soName += ".";
+ soName += soversion;
+ }
+
+ // The library's real name on disk.
+ realName = name;
+ if(version)
+ {
+ realName += ".";
+ realName += version;
+ }
+ else if(soversion)
+ {
+ realName += ".";
+ realName += soversion;
+ }
+}