summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator2.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/cmLocalUnixMakefileGenerator2.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/cmLocalUnixMakefileGenerator2.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx104
1 files changed, 37 insertions, 67 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index 92b6be9..124d6ba 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -1857,9 +1857,9 @@ cmLocalUnixMakefileGenerator2
std::string targetNameSO;
std::string targetNameReal;
std::string targetNameBase;
- this->GetLibraryNames(target,
- targetName, targetNameSO,
- targetNameReal, targetNameBase);
+ target.GetLibraryNames(m_Makefile,
+ targetName, targetNameSO,
+ targetNameReal, targetNameBase);
// Construct the full path version of the names.
std::string outpath = m_LibraryOutputPath;
@@ -1897,18 +1897,42 @@ cmLocalUnixMakefileGenerator2
buildEcho += targetOutPath.c_str();
this->AppendEcho(commands, buildEcho.c_str());
- // Add a command to remove any existing files for this library.
+ // Construct a list of files associated with this library that may
+ // need to be cleaned.
std::vector<std::string> cleanFiles;
- cleanFiles.push_back(targetFullPathReal);
- if(targetOutPathSO != targetOutPathReal)
- {
- cleanFiles.push_back(targetFullPathSO);
- }
- if(targetOutPath != targetOutPathSO &&
- targetOutPath != targetOutPathReal)
- {
- cleanFiles.push_back(targetFullPath);
+ {
+ std::string cleanStaticName;
+ std::string cleanSharedName;
+ std::string cleanSharedSOName;
+ std::string cleanSharedRealName;
+ target.GetLibraryCleanNames(m_Makefile,
+ cleanStaticName,
+ cleanSharedName,
+ cleanSharedSOName,
+ cleanSharedRealName);
+ std::string cleanFullStaticName = outpath + cleanStaticName;
+ std::string cleanFullSharedName = outpath + cleanSharedName;
+ std::string cleanFullSharedSOName = outpath + cleanSharedSOName;
+ std::string cleanFullSharedRealName = outpath + cleanSharedRealName;
+ cleanFiles.push_back(cleanFullStaticName);
+ if(cleanSharedRealName != cleanStaticName)
+ {
+ cleanFiles.push_back(cleanFullSharedRealName);
+ }
+ if(cleanSharedSOName != cleanStaticName &&
+ cleanSharedSOName != cleanSharedRealName)
+ {
+ cleanFiles.push_back(cleanFullSharedSOName);
+ }
+ if(cleanSharedName != cleanStaticName &&
+ cleanSharedName != cleanSharedSOName &&
+ cleanSharedName != cleanSharedRealName)
+ {
+ cleanFiles.push_back(cleanFullSharedName);
}
+ }
+
+ // Add a command to remove any existing files for this library.
this->AppendCleanCommand(commands, cleanFiles);
// Add the pre-build and pre-link rules.
@@ -2776,60 +2800,6 @@ cmLocalUnixMakefileGenerator2::SamePath(const char* path1, const char* path2)
}
//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator2::GetLibraryNames(const cmTarget& t,
- std::string& name,
- std::string& soName,
- std::string& realName,
- std::string& baseName)
-{
- // Check for library version properties.
- const char* version = t.GetProperty("VERSION");
- const char* soversion = t.GetProperty("SOVERSION");
- if((t.GetType() != cmTarget::SHARED_LIBRARY &&
- t.GetType() != cmTarget::MODULE_LIBRARY) ||
- !m_Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SONAME_C_FLAG"))
- {
- // 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 = t.GetFullName(m_Makefile);
-
- // 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;
- }
-
- // The library name without extension.
- baseName = t.GetBaseName(m_Makefile);
-}
-
-//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator2
::ConvertToMakeTarget(const char* tgt)