summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-04-22 19:23:21 (GMT)
committerBrad King <brad.king@kitware.com>2005-04-22 19:23:21 (GMT)
commit1b71f4477beeb41e3924993b5d4b78eadc092ec8 (patch)
treecd6573e19ddb19b80adc278a528af356639cf130
parent98d872c90e181e1f735cf5f801a5d18a0347cc96 (diff)
downloadCMake-1b71f4477beeb41e3924993b5d4b78eadc092ec8.zip
CMake-1b71f4477beeb41e3924993b5d4b78eadc092ec8.tar.gz
CMake-1b71f4477beeb41e3924993b5d4b78eadc092ec8.tar.bz2
ENH: Added cmTarget::GetBaseName and cmTarget::GetFullName methods and removed cmLocalGenerator::GetFullTargetName and cmLocalUnixMakefileGenerator2::GetBaseTargetName. This functionality is more sensibly implemented in cmTarget. It is also needed for an upcoming feature in which both the shared and static versions of a library will be removed before one is linked.
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx3
-rw-r--r--Source/cmLocalGenerator.cxx51
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx42
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.h1
-rw-r--r--Source/cmTarget.cxx108
-rw-r--r--Source/cmTarget.h12
7 files changed, 125 insertions, 95 deletions
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 6ff0fcc..9c8ed4f 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -64,8 +64,7 @@ bool cmGetTargetPropertyCommand::InitialPass(
target_location += "/";
}
- cmLocalGenerator* lg = m_Makefile->GetLocalGenerator();
- target_location += lg->GetFullTargetName(targetName, target);
+ target_location += target.GetFullName(m_Makefile);
m_Makefile->AddDefinition(var, target_location.c_str());
return true;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0db9559..259a1f5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -212,7 +212,7 @@ void cmLocalGenerator::GenerateInstallRules()
case cmTarget::STATIC_LIBRARY:
case cmTarget::MODULE_LIBRARY:
fname = libOutPath;
- fname += this->GetFullTargetName(l->first.c_str(), l->second);
+ fname += l->second.GetFullName(m_Makefile);
files = fname.c_str();
this->AddInstallRule(fout, dest, type, files);
break;
@@ -220,7 +220,7 @@ void cmLocalGenerator::GenerateInstallRules()
{
// Special code to handle DLL
fname = libOutPath;
- fname += this->GetFullTargetName(l->first.c_str(), l->second);
+ fname += l->second.GetFullName(m_Makefile);
std::string ext = cmSystemTools::GetFilenameExtension(fname);
ext = cmSystemTools::LowerCase(ext);
if ( ext == ".dll" )
@@ -263,7 +263,7 @@ void cmLocalGenerator::GenerateInstallRules()
break;
case cmTarget::EXECUTABLE:
fname = exeOutPath;
- fname += this->GetFullTargetName(l->first.c_str(), l->second);
+ fname += l->second.GetFullName(m_Makefile);
files = fname.c_str();
this->AddInstallRule(fout, dest, type, files);
break;
@@ -380,49 +380,6 @@ void cmLocalGenerator::AddInstallRule(std::ostream& fout, const char* dest,
<< " FILES \"" << sfiles.c_str() << "\")\n";
}
-std::string cmLocalGenerator::GetFullTargetName(const char* n,
- const cmTarget& t)
-{
- const char* targetPrefix = t.GetProperty("PREFIX");
- const char* targetSuffix = t.GetProperty("SUFFIX");
- if(!targetSuffix && t.GetType() == cmTarget::EXECUTABLE)
- {
- targetSuffix = cmSystemTools::GetExecutableExtension();
- }
- const char* prefixVar = t.GetPrefixVariable();
- const char* suffixVar = t.GetSuffixVariable();
- const char* ll = t.GetLinkerLanguage(this->GetGlobalGenerator());
- // first try language specific suffix
- if(ll)
- {
- if(!targetSuffix)
- {
- std::string langSuff = suffixVar + std::string("_") + ll;
- targetSuffix = m_Makefile->GetDefinition(langSuff.c_str());
- }
- if(!targetPrefix)
- {
- std::string langPrefix = prefixVar + std::string("_") + ll;
- targetPrefix = m_Makefile->GetDefinition(langPrefix.c_str());
- }
- }
-
- // if there is no prefix on the target use the cmake definition
- if(!targetPrefix && prefixVar)
- {
- targetPrefix = m_Makefile->GetSafeDefinition(prefixVar);
- }
- // if there is no suffix on the target use the cmake definition
- if(!targetSuffix && suffixVar)
- {
- targetSuffix = m_Makefile->GetSafeDefinition(suffixVar);
- }
- std::string name = targetPrefix?targetPrefix:"";
- name += n;
- name += targetSuffix?targetSuffix:"";
- return name;
-}
-
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
const char* lang,
cmSourceFile& source,
@@ -519,7 +476,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
std::string createRule = "CMAKE_";
createRule += llang;
createRule += target.GetCreateRuleVariable();
- std::string targetName = this->GetFullTargetName(target.GetName(), target);
+ std::string targetName = target.GetFullName(m_Makefile);
// Executable :
// Shared Library:
// Static Library:
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index bea6c67..4012cdf 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -69,9 +69,6 @@ public:
///! Set the Global Generator, done on creation by the GlobalGenerator
void SetGlobalGenerator(cmGlobalGenerator *gg);
-
- /** Get the full name of the target's file, without path. */
- std::string GetFullTargetName(const char* n, const cmTarget& t);
/**
* Convert the given remote path to a relative path with respect to
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index bd1c080..92b6be9 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -1478,7 +1478,7 @@ cmLocalUnixMakefileGenerator2
const char* targetOutPath)
{
// Add a rule to build the target by name.
- std::string localName = this->GetFullTargetName(target.GetName(), target);
+ std::string localName = target.GetFullName(m_Makefile);
localName = this->ConvertToRelativeOutputPath(localName.c_str());
this->WriteConvenienceRule(ruleFileStream, targetOutPath,
localName.c_str());
@@ -2776,42 +2776,6 @@ cmLocalUnixMakefileGenerator2::SamePath(const char* path1, const char* path2)
}
//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator2::GetBaseTargetName(const cmTarget& t)
-{
- std::string pathPrefix = "";
-#ifdef __APPLE__
- if ( t.GetPropertyAsBool("MACOSX_BUNDLE") )
- {
- pathPrefix = t.GetName();
- pathPrefix += ".app/Contents/MacOS/";
- }
-#endif
-
- const char* targetPrefix = t.GetProperty("PREFIX");
- const char* prefixVar = t.GetPrefixVariable();
- // if there is no prefix on the target use the cmake definition
- if(!targetPrefix && prefixVar)
- {
- // first check for a language specific suffix var
- const char* ll = t.GetLinkerLanguage(this->GetGlobalGenerator());
- if(ll)
- {
- std::string langPrefix = prefixVar + std::string("_") + ll;
- targetPrefix = m_Makefile->GetDefinition(langPrefix.c_str());
- }
- // if there not a language specific suffix then use the general one
- if(!targetPrefix)
- {
- targetPrefix = m_Makefile->GetSafeDefinition(prefixVar);
- }
- }
- std::string name = pathPrefix + (targetPrefix?targetPrefix:"");
- name += t.GetName();
- return name;
-}
-
-//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator2::GetLibraryNames(const cmTarget& t,
std::string& name,
std::string& soName,
@@ -2838,7 +2802,7 @@ void cmLocalUnixMakefileGenerator2::GetLibraryNames(const cmTarget& t,
}
// The library name.
- name = this->GetFullTargetName(t.GetName(), t);
+ name = t.GetFullName(m_Makefile);
// The library's soname.
soName = name;
@@ -2862,7 +2826,7 @@ void cmLocalUnixMakefileGenerator2::GetLibraryNames(const cmTarget& t,
}
// The library name without extension.
- baseName = this->GetBaseTargetName(t);
+ baseName = t.GetBaseName(m_Makefile);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h
index 76bc75a..8f77b5e 100644
--- a/Source/cmLocalUnixMakefileGenerator2.h
+++ b/Source/cmLocalUnixMakefileGenerator2.h
@@ -221,7 +221,6 @@ protected:
//==========================================================================
bool SamePath(const char* path1, const char* path2);
- std::string GetBaseTargetName(const cmTarget& t);
void GetLibraryNames(const cmTarget& t,
std::string& name, std::string& soName,
std::string& realName, std::string& baseName);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c2af5e4..479947f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -17,6 +17,7 @@
#include "cmTarget.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
#include <map>
#include <set>
@@ -831,10 +832,14 @@ const char* cmTarget::GetCreateRuleVariable()
return "";
}
-
const char* cmTarget::GetSuffixVariable() const
{
- switch(this->GetType())
+ return this->GetSuffixVariableInternal(this->GetType());
+}
+
+const char* cmTarget::GetSuffixVariableInternal(TargetType type) const
+{
+ switch(type)
{
case cmTarget::STATIC_LIBRARY:
return "CMAKE_STATIC_LIBRARY_SUFFIX";
@@ -855,7 +860,12 @@ const char* cmTarget::GetSuffixVariable() const
const char* cmTarget::GetPrefixVariable() const
{
- switch(this->GetType())
+ return this->GetPrefixVariableInternal(this->GetType());
+}
+
+const char* cmTarget::GetPrefixVariableInternal(TargetType type) const
+{
+ switch(type)
{
case cmTarget::STATIC_LIBRARY:
return "CMAKE_STATIC_LIBRARY_PREFIX";
@@ -872,3 +882,95 @@ const char* cmTarget::GetPrefixVariable() const
}
return "";
}
+
+std::string cmTarget::GetFullName(cmMakefile* mf) const
+{
+ return this->GetFullNameInternal(mf, this->GetType());
+}
+
+std::string cmTarget::GetFullNameInternal(cmMakefile* mf,
+ TargetType type) const
+{
+ const char* targetPrefix = this->GetProperty("PREFIX");
+ const char* targetSuffix = this->GetProperty("SUFFIX");
+ if(!targetSuffix && this->GetType() == cmTarget::EXECUTABLE)
+ {
+ targetSuffix = cmSystemTools::GetExecutableExtension();
+ }
+ const char* prefixVar = this->GetPrefixVariableInternal(type);
+ const char* suffixVar = this->GetSuffixVariableInternal(type);
+ const char* ll =
+ this->GetLinkerLanguage(
+ mf->GetLocalGenerator()->GetGlobalGenerator());
+ // first try language specific suffix
+ if(ll)
+ {
+ if(!targetSuffix)
+ {
+ std::string langSuff = suffixVar + std::string("_") + ll;
+ targetSuffix = mf->GetDefinition(langSuff.c_str());
+ }
+ if(!targetPrefix)
+ {
+ std::string langPrefix = prefixVar + std::string("_") + ll;
+ targetPrefix = mf->GetDefinition(langPrefix.c_str());
+ }
+ }
+
+ // if there is no prefix on the target use the cmake definition
+ if(!targetPrefix && prefixVar)
+ {
+ targetPrefix = mf->GetSafeDefinition(prefixVar);
+ }
+ // if there is no suffix on the target use the cmake definition
+ if(!targetSuffix && suffixVar)
+ {
+ targetSuffix = mf->GetSafeDefinition(suffixVar);
+ }
+ std::string name = targetPrefix?targetPrefix:"";
+ name += this->GetName();
+ name += targetSuffix?targetSuffix:"";
+ return name;
+}
+
+std::string cmTarget::GetBaseName(cmMakefile* mf) const
+{
+ return this->GetBaseNameInternal(mf, this->GetType());
+}
+
+std::string
+cmTarget::GetBaseNameInternal(cmMakefile* mf, TargetType type) const
+{
+ std::string pathPrefix = "";
+#ifdef __APPLE__
+ if(this->GetPropertyAsBool("MACOSX_BUNDLE"))
+ {
+ pathPrefix = this->GetName();
+ pathPrefix += ".app/Contents/MacOS/";
+ }
+#endif
+ const char* targetPrefix = this->GetProperty("PREFIX");
+ const char* prefixVar = this->GetPrefixVariableInternal(type);
+ // if there is no prefix on the target use the cmake definition
+ if(!targetPrefix && prefixVar)
+ {
+ // first check for a language specific suffix var
+ const char* ll =
+ this->GetLinkerLanguage(
+ mf->GetLocalGenerator()->GetGlobalGenerator());
+ if(ll)
+ {
+ std::string langPrefix = prefixVar + std::string("_") + ll;
+ targetPrefix = mf->GetDefinition(langPrefix.c_str());
+ }
+ // if there not a language specific suffix then use the general one
+ if(!targetPrefix)
+ {
+ targetPrefix = mf->GetSafeDefinition(prefixVar);
+ }
+ }
+ std::string name = pathPrefix;
+ name += targetPrefix?targetPrefix:"";
+ name += this->GetName();
+ return name;
+}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index cc84849..e1ea2ee 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -167,6 +167,14 @@ public:
const char* GetSuffixVariable() const;
///! Return the name of the variable to look up the target suffix
const char* GetPrefixVariable() const;
+
+ // Get the full name of the target according to the settings in the
+ // given makefile.
+ std::string GetFullName(cmMakefile* mf) const;
+
+ // Get the baes name (no suffix) of the target according to the
+ // settings in the given makefile.
+ std::string GetBaseName(cmMakefile* mf) const;
private:
/**
* A list of direct dependencies. Use in conjunction with DependencyMap.
@@ -221,6 +229,10 @@ private:
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
DependencyMap& dep_map );
+ const char* GetSuffixVariableInternal(TargetType type) const;
+ const char* GetPrefixVariableInternal(TargetType type) const;
+ std::string GetFullNameInternal(cmMakefile* mf, TargetType type) const;
+ std::string GetBaseNameInternal(cmMakefile* mf, TargetType type) const;
private:
std::string m_Name;