summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx65
-rw-r--r--Source/cmGlobalXCodeGenerator.h6
-rw-r--r--Source/cmLocalGenerator.cxx12
-rw-r--r--Source/cmLocalGenerator.h12
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx11
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx12
-rw-r--r--Source/cmLocalVisualStudio6Generator.h4
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx13
-rw-r--r--Source/cmLocalVisualStudio7Generator.h4
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx3
-rw-r--r--Source/cmLocalVisualStudioGenerator.h4
-rw-r--r--Source/cmLocalXCodeGenerator.cxx25
-rw-r--r--Source/cmLocalXCodeGenerator.h5
-rw-r--r--Source/cmMakefileTargetGenerator.cxx1
-rw-r--r--Source/cmMakefileTargetGenerator.h2
-rw-r--r--Source/cmTarget.cxx66
-rw-r--r--Source/cmTarget.h3
18 files changed, 237 insertions, 15 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 1a21adb..decdbaf 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -124,6 +124,20 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++");
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
this->cmGlobalGenerator::EnableLanguage(lang, mf);
+ const char* osxArch =
+ mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
+ const char* sysroot =
+ mf->GetDefinition("CMAKE_OSX_SYSROOT");
+ if(osxArch && sysroot)
+ {
+ std::cerr <<"EnableLanguage archs\n";
+ this->Architectures.clear();
+ cmSystemTools::ExpandListArgument(std::string(osxArch),
+ this->Architectures);
+ }
+ else
+ std::cerr <<"no EnableLanguage archs\n";
+
}
//----------------------------------------------------------------------------
@@ -2156,9 +2170,6 @@ void cmGlobalXCodeGenerator
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
if(osxArch && sysroot)
{
- this->Architectures.clear();
- cmSystemTools::ExpandListArgument(std::string(osxArch),
- this->Architectures);
if(this->Architectures.size() > 1)
{
buildSettings->AddAttribute("SDKROOT",
@@ -2217,7 +2228,6 @@ void cmGlobalXCodeGenerator
this->RootObject->AddAttribute("targets", allTargets);
}
-
//----------------------------------------------------------------------------
void
cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
@@ -2555,6 +2565,52 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
return ret;
}
+void cmGlobalXCodeGenerator::
+GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs)
+{
+ std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += target->GetName();
+ dir += ".build/";
+ dir += this->GetCMakeCFGInitDirectory();
+ dir += "/";
+ if(target->GetType() != cmTarget::EXECUTABLE)
+ {
+ dir += "lib";
+ }
+ dir += target->GetName();
+ if(target->GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ dir += ".a";
+ }
+ if(target->GetType() == cmTarget::SHARED_LIBRARY)
+ {
+ dir += ".dylib";
+ }
+ if(target->GetType() == cmTarget::MODULE_LIBRARY)
+ {
+ dir += ".so";
+ }
+ dir += ".build/Objects-normal/";
+ std::string dirsave = dir;
+ if(this->Architectures.size())
+ {
+ for(std::vector<std::string>::iterator i = this->Architectures.begin();
+ i != this->Architectures.end(); ++i)
+ {
+ dir += *i;
+ dirs.push_back(dir);
+ dir = dirsave;
+ }
+ }
+ else
+ {
+ dirs.push_back(dir);
+ }
+}
+
//----------------------------------------------------------------------------
void
cmGlobalXCodeGenerator
@@ -2567,6 +2623,7 @@ cmGlobalXCodeGenerator
{
if(config)
{
+
dir += prefix;
dir += config;
dir += suffix;
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 991a223..27470d6 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -82,13 +82,16 @@ public:
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGInitDirectory() { return "."; }
+ void GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs);
+ void SetCurrentLocalGenerator(cmLocalGenerator*);
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
void CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
- void SetCurrentLocalGenerator(cmLocalGenerator*);
std::string XCodeEscapePath(const char* p);
std::string ConvertToRelativeForXCode(const char* p);
std::string ConvertToRelativeForMake(const char* p);
@@ -158,6 +161,7 @@ private:
const char* varNameLang,
const char* varNameSuffix,
const char* default_flags);
+
protected:
virtual const char* GetInstallTargetName() { return "install"; }
virtual const char* GetPackageTargetName() { return "package"; }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f0fa9be..abb2328 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2399,3 +2399,15 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
}
return std::string(&arg[0]);
}
+void
+cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs)
+{
+ cmSystemTools::Error("GetTargetObjectFileDirectories called on cmLocalGenerator");
+}
+
+std::string cmLocalGenerator::GetSourceObjectName(cmSourceFile& sf)
+{
+ return sf.GetSourceName();
+}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 4aa49a7..e9c58d4 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -214,7 +214,17 @@ public:
/** Backwards-compatibility version of EscapeForShell. */
std::string EscapeForShellOldStyle(const char* str);
-
+
+ /** Return the directories into which object files will be put.
+ * There maybe more than one for fat binary systems like OSX.
+ */
+ virtual void
+ GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs);
+ // return the source name for the object file
+ virtual std::string GetSourceObjectName(cmSourceFile& );
+
protected:
/** Construct a comment for a custom command. */
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index dcfb631..19fd75b 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1920,3 +1920,14 @@ void cmLocalUnixMakefileGenerator3
}
}
}
+
+
+void cmLocalUnixMakefileGenerator3
+::GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>& dirs)
+{
+ std::string dir = this->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += this->GetTargetDirectory(*target);
+ dirs.push_back(dir);
+}
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 7747b9c..e00ed25 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -246,7 +246,9 @@ public:
{
return !this->SkipAssemblySourceRules;
}
-
+ // Get the directories into which the .o files will go for this target
+ void GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>& dirs);
protected:
// these two methods just compute reasonable values for LibraryOutputPath
// and ExecutableOutputPath
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 0c29c03..d53ac78 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1472,3 +1472,15 @@ void cmLocalVisualStudio6Generator
options += "\n";
}
}
+
+
+void cmLocalVisualStudio6Generator
+::GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs)
+{
+ std::string dir = this->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += this->GetGlobalGenerator()->GetCMakeCFGInitDirectory();
+ dirs.push_back(dir);
+}
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index cdc246f..3b789f8 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -61,7 +61,9 @@ public:
{
return this->CreatedProjectNames;
}
-
+ void GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs);
private:
std::string DSPHeaderTemplate;
std::string DSPFooterTemplate;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 4025b89..212eb12 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1949,3 +1949,16 @@ cmLocalVisualStudio7GeneratorOptions
fout << "\"" << suffix;
}
}
+void cmLocalVisualStudio7Generator::
+GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs)
+{
+ std::string dir = this->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += this->GetTargetDirectory(*target);
+ dir += "/";
+ dir += this->GetGlobalGenerator()->GetCMakeCFGInitDirectory();
+ std::cerr << dir << "\n";
+ dirs.push_back(dir);
+}
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 1357727..746e657 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -66,6 +66,10 @@ public:
void SetVersion8() {this->Version = 8;}
void SetPlatformName(const char* n) { this->PlatformName = n;}
virtual void ConfigureFinalPass();
+ void GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs);
+
private:
typedef cmLocalVisualStudio7GeneratorOptions Options;
void ReadAndStoreExternalGUID(const char* name,
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index d6f2921..8ca677e 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -15,7 +15,7 @@
=========================================================================*/
#include "cmLocalVisualStudioGenerator.h"
-
+#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
@@ -178,3 +178,4 @@ cmLocalVisualStudioGenerator
}
return script;
}
+
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index ca9cb6c..8259474 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -33,7 +33,9 @@ class cmLocalVisualStudioGenerator : public cmLocalGenerator
public:
cmLocalVisualStudioGenerator();
virtual ~cmLocalVisualStudioGenerator();
-
+ /** Return the directories into which object files will be put.
+ * There maybe more than one for fat binary systems like OSX.
+ */
protected:
/** Construct a script from the given list of command lines. */
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index c7f6de5..311735d 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -1,4 +1,6 @@
#include "cmLocalXCodeGenerator.h"
+#include "cmGlobalXCodeGenerator.h"
+#include "cmSourceFile.h"
cmLocalXCodeGenerator::cmLocalXCodeGenerator()
{
@@ -11,3 +13,26 @@ cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
{
}
+void cmLocalXCodeGenerator::
+GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs)
+{
+ cmGlobalXCodeGenerator* g = (cmGlobalXCodeGenerator*)this->GetGlobalGenerator();
+ g->SetCurrentLocalGenerator(this);
+ g->GetTargetObjectFileDirectories(target,
+ dirs);
+}
+
+ // return the source name for the object file
+std::string cmLocalXCodeGenerator::GetSourceObjectName(cmSourceFile& sf )
+{
+ std::string ret = sf.GetSourceName();
+ std::string::size_type pos = ret.find("/");
+ if(pos == ret.npos)
+ {
+ return ret;
+ }
+ return ret.substr(pos+1);
+}
+
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 6882de4..8ab9467 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -32,6 +32,11 @@ public:
cmLocalXCodeGenerator();
virtual ~cmLocalXCodeGenerator();
+ void GetTargetObjectFileDirectories(cmTarget* target,
+ std::vector<std::string>&
+ dirs);
+ // return the source name for the object file
+ virtual std::string GetSourceObjectName(cmSourceFile& );
private:
};
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3245d2f..98e4c82 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1275,4 +1275,3 @@ void cmMakefileTargetGenerator::WriteProgressVariables(unsigned long total,
current += this->NumberOfProgressActions;
delete progressFileStream;
}
-
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index fb6562b..308a64d 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -60,7 +60,7 @@ public:
return this->NumberOfProgressActions;}
const char *GetTargetName() { return this->TargetName.c_str(); }
-
+ cmTarget* GetTarget() { return this->Target;}
protected:
// create the file and directory etc
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 5e2001a..5349dff 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -256,6 +256,14 @@ void cmTarget::DefineProperties(cmake *cm)
"in contrast to a console application for example. This changes "
"how the executable will be linked.");
+ cm->DefineProperty
+ ("OBJECT_FILES", cmProperty::TARGET,
+ "Used to get the resulting list of object files that make up a "
+ "target.",
+ "This can be used to put object files from one library "
+ "into another library. It is a read only property. It "
+ "converts the source list for the target into a list of full "
+ "paths to object names that will be produced by the target.");
// define some properties without documentation
cm->DefineProperty("DEBUG_OUTPUT_NAME", cmProperty::TARGET,0,0);
@@ -529,13 +537,20 @@ void cmTarget::TraceVSDependencies(std::string projFile,
void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
{
+ // only allow this to be called once
+ // there is a lazy evaluation of this in ComputeObjectFiles,
+ // that could break backwards compatibility with projects that
+ // use old style source lists.
+ if(this->SourceFiles.size() != 0)
+ {
+ return;
+ }
// this is only done for non install targets
if ((this->TargetTypeValue == cmTarget::INSTALL_FILES)
|| (this->TargetTypeValue == cmTarget::INSTALL_PROGRAMS))
{
return;
}
-
// for each src lists add the classes
for (std::vector<std::string>::const_iterator s = this->SourceLists.begin();
s != this->SourceLists.end(); ++s)
@@ -1160,6 +1175,49 @@ const char *cmTarget::GetProperty(const char* prop)
return this->GetProperty(prop, cmProperty::TARGET);
}
+void cmTarget::ComputeObjectFiles()
+{
+ // Force the SourceFiles vector to be populated
+ this->GenerateSourceFilesFromSourceLists(*this->Makefile);
+ std::vector<std::string> dirs;
+ this->Makefile->GetLocalGenerator()->
+ GetTargetObjectFileDirectories(this,
+ dirs);
+ std::string objectFiles;
+ std::string objExtensionLookup1 = "CMAKE_";
+ std::string objExtensionLookup2 = "_OUTPUT_EXTENSION";
+
+ for(std::vector<std::string>::iterator d = dirs.begin();
+ d != dirs.end(); ++d)
+ {
+ for(std::vector<cmSourceFile*>::iterator s = this->SourceFiles.begin();
+ s != this->SourceFiles.end(); ++s)
+ {
+ cmSourceFile* sf = *s;
+ const char* lang = this->Makefile->GetLocalGenerator()->
+ GetGlobalGenerator()->GetLanguageFromExtension(sf->GetSourceExtension().c_str());
+ std::string lookupObj = objExtensionLookup1 + lang;
+ lookupObj += objExtensionLookup2;
+ const char* obj = this->Makefile->GetDefinition(lookupObj.c_str());
+ if(obj)
+ {
+ if(objectFiles.size())
+ {
+ objectFiles += ";";
+ }
+ std::string objFile = *d;
+ objFile += "/";
+ objFile += this->Makefile->GetLocalGenerator()->
+ GetSourceObjectName(*sf);
+ objFile += obj;
+ objectFiles += objFile;
+ }
+ }
+ }
+ this->SetProperty("OBJECT_FILES", objectFiles.c_str());
+}
+
+
const char *cmTarget::GetProperty(const char* prop,
cmProperty::ScopeType scope)
{
@@ -1178,7 +1236,10 @@ const char *cmTarget::GetProperty(const char* prop,
// variable in the location.
this->SetProperty("LOCATION", this->GetLocation(0));
}
-
+ if(strcmp(prop, "OBJECT_FILES") == 0)
+ {
+ this->ComputeObjectFiles();
+ }
// Per-configuration location can be computed.
int len = static_cast<int>(strlen(prop));
if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
@@ -1186,7 +1247,6 @@ const char *cmTarget::GetProperty(const char* prop,
std::string configName(prop, len-9);
this->SetProperty(prop, this->GetLocation(configName.c_str()));
}
-
// the type property returns what type the target is
if (!strcmp(prop,"TYPE"))
{
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 3e7d838..de216f3 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -261,6 +261,9 @@ public:
// Define the properties
static void DefineProperties(cmake *cm);
+
+ // Compute the OBJECT_FILES property only when requested
+ void ComputeObjectFiles();
private:
/**