summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
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 /Source/cmTarget.cxx
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.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx108
1 files changed, 105 insertions, 3 deletions
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;
+}