summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-09-22 18:42:05 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-09-22 18:42:05 (GMT)
commit692ba48c4e5762b370f2999e902b8bd677c77161 (patch)
tree0c9465d0e38a15bd0cb043f234b4e4ab0cee51a2 /Source/cmTarget.cxx
parent597185754420db18d83b2c9e3b9f1e33675bd935 (diff)
downloadCMake-692ba48c4e5762b370f2999e902b8bd677c77161.zip
CMake-692ba48c4e5762b370f2999e902b8bd677c77161.tar.gz
CMake-692ba48c4e5762b370f2999e902b8bd677c77161.tar.bz2
ENH: major changes to support addition of languages from cmake modules directory.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx110
1 files changed, 68 insertions, 42 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 7c3fb7a..f9ed992 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -17,15 +17,16 @@
#include "cmTarget.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
-
+#include "cmGlobalGenerator.h"
#include <map>
#include <set>
#include <queue>
#include <stdlib.h> // required for atof
-void cmTarget::SetType(TargetType type)
+void cmTarget::SetType(TargetType type, const char* name)
{
+ m_Name = name;
// only add dependency information for library targets
m_TargetType = type;
if(m_TargetType >= STATIC_LIBRARY && m_TargetType <= MODULE_LIBRARY) {
@@ -419,46 +420,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
}
-bool cmTarget::HasCxx() const
-{
- if(this->GetProperty("HAS_CXX"))
- {
- return true;
- }
- for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
- i != m_SourceFiles.end(); ++i)
- {
- if(cmSystemTools::GetFileFormat((*i)->GetSourceExtension().c_str())
- == cmSystemTools::CXX_FILE_FORMAT)
- {
- return true;
- }
- }
- return false;
-}
-
-bool cmTarget::HasFortran() const
-{
- if(this->GetProperty("HAS_FORTRAN"))
- {
- return true;
- }
- for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
- i != m_SourceFiles.end(); ++i)
- {
- if(cmSystemTools::GetFileFormat((*i)->GetSourceExtension().c_str())
- == cmSystemTools::FORTRAN_FILE_FORMAT)
- {
- return true;
- }
- }
- return false;
-}
-
-
-
-
-
void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
{
@@ -783,3 +744,68 @@ bool cmTarget::GetPropertyAsBool(const char* prop) const
}
return false;
}
+
+const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg) const
+{
+ if(this->GetProperty("HAS_CXX"))
+ {
+ const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", "CXX");
+ }
+ const char* linkerLang = this->GetProperty("LINKER_LANGUAGE");
+ if(linkerLang)
+ {
+ return linkerLang;
+ }
+ std::set<cmStdString> languages;
+ for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
+ i != m_SourceFiles.end(); ++i)
+ {
+ const char* lang =
+ gg->GetLanguageFromExtension((*i)->GetSourceExtension().c_str());
+ if(lang)
+ {
+ languages.insert(lang);
+ }
+ }
+ if(languages.size() == 0)
+ {
+ std::string m = "Error Target: ";
+ m += m_Name + " contains no source files with an enabled languages.";
+ cmSystemTools::Error(m.c_str());
+ return "(NullLanguage)";
+ }
+ if(languages.size() == 1)
+ {
+ const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", languages.begin()->c_str());
+ return this->GetProperty("LINKER_LANGUAGE");
+ }
+ const char* prefLang = 0;
+ for(std::set<cmStdString>::const_iterator s = languages.begin();
+ s != languages.end(); ++s)
+ {
+ const char* lpref = gg->GetLinkerPreference(s->c_str());
+ if(lpref[0] == 'P')
+ {
+ if(prefLang && !(*s == prefLang))
+ {
+ std::string m = "Error Target: ";
+ m += m_Name + " Contains more than one Prefered language: ";
+ m += *s;
+ m += " and ";
+ m += prefLang;
+ m += "\nYou must set the LINKER_LANGUAGE property for this target.";
+ cmSystemTools::Error(m.c_str());
+ }
+ else
+ {
+ prefLang = s->c_str();
+ }
+ }
+ }
+ if(!prefLang)
+ {
+ prefLang = languages.begin()->c_str();
+ }
+ const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", languages.begin()->c_str());
+ return this->GetProperty("LINKER_LANGUAGE");
+}