[cmake-commits] alex committed cmAddDependenciesCommand.cxx 1.14 1.15
cmAddExecutableCommand.cxx 1.29 1.30
cmGetTargetPropertyCommand.cxx 1.7 1.8 cmGlobalGenerator.cxx
1.176 1.177 cmGlobalGenerator.h 1.76 1.77
cmGlobalUnixMakefileGenerator3.cxx 1.106 1.107
cmGlobalVisualStudio6Generator.cxx 1.68 1.69
cmGlobalVisualStudio71Generator.cxx 1.39 1.40
cmGlobalVisualStudio7Generator.cxx 1.86 1.87
cmGlobalVisualStudio8Generator.cxx 1.19 1.20
cmGlobalVisualStudioGenerator.cxx 1.3 1.4
cmGlobalXCodeGenerator.cxx 1.151 1.152
cmIncludeExternalMSProjectCommand.cxx 1.18 1.19
cmInstallCommand.cxx 1.20 1.21 cmInstallTargetGenerator.cxx
1.33 1.34 cmLocalGenerator.cxx 1.220 1.221
cmLocalUnixMakefileGenerator3.cxx 1.209 1.210
cmLocalVisualStudio6Generator.cxx 1.123 1.124 cmMakefile.cxx
1.390 1.391 cmMakefile.h 1.203 1.204
cmMakefileTargetGenerator.cxx 1.63 1.64
cmSetTargetPropertiesCommand.cxx 1.6 1.7 cmTarget.cxx 1.141
1.142 cmTarget.h 1.82 1.83
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue May 22 10:25:01 EDT 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv8707/Source
Modified Files:
cmAddDependenciesCommand.cxx cmAddExecutableCommand.cxx
cmGetTargetPropertyCommand.cxx cmGlobalGenerator.cxx
cmGlobalGenerator.h cmGlobalUnixMakefileGenerator3.cxx
cmGlobalVisualStudio6Generator.cxx
cmGlobalVisualStudio71Generator.cxx
cmGlobalVisualStudio7Generator.cxx
cmGlobalVisualStudio8Generator.cxx
cmGlobalVisualStudioGenerator.cxx cmGlobalXCodeGenerator.cxx
cmIncludeExternalMSProjectCommand.cxx cmInstallCommand.cxx
cmInstallTargetGenerator.cxx cmLocalGenerator.cxx
cmLocalUnixMakefileGenerator3.cxx
cmLocalVisualStudio6Generator.cxx cmMakefile.cxx cmMakefile.h
cmMakefileTargetGenerator.cxx cmSetTargetPropertiesCommand.cxx
cmTarget.cxx cmTarget.h
Log Message:
ENH: add the IMPORT keyword to ADD_EXECUTABLE(), which generates an
"imported" executable target. This can then be used e.g. with
ADD_CUSTOM_COMMAND() to generate stuff. It adds a second container for
"imported" targets, and FindTarget() now takes an additional argument bool
useImportedTargets to specify whether you also want to search in the
imported targets or only in the "normal" targets.
Alex
Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- cmGlobalGenerator.h 18 May 2007 17:43:39 -0000 1.76
+++ cmGlobalGenerator.h 22 May 2007 14:24:59 -0000 1.77
@@ -157,7 +157,7 @@
void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
- cmTarget* FindTarget(const char* project, const char* name);
+ cmTarget* FindTarget(const char* project, const char* name, bool useImportedTargets);
/** If check to see if the target is linked to by any other
target in the project */
@@ -177,9 +177,8 @@
configuration. This is valid during generation only. */
cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; }
- void AddTarget(cmTargets::value_type &v) {
- this->TotalTargets[v.first] = &v.second;};
-
+ void AddTarget(cmTargets::value_type &v);
+
/** Support for multiple custom command outputs. */
virtual void CheckMultipleOutputs(cmMakefile* mf, bool verbose);
@@ -240,6 +239,7 @@
// this is used to improve performance
std::map<cmStdString,cmTarget *> TotalTargets;
+ std::map<cmStdString,cmTarget *> ImportedTotalTargets;
std::map<cmStdString, std::vector<cmTarget *> > TargetDependencies;
};
Index: cmGlobalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.cxx,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- cmGlobalUnixMakefileGenerator3.cxx 9 May 2007 12:25:45 -0000 1.106
+++ cmGlobalUnixMakefileGenerator3.cxx 22 May 2007 14:24:59 -0000 1.107
@@ -641,51 +641,49 @@
// simple name)
if(t->second.GetName() &&
strlen(t->second.GetName()) &&
- emitted.insert(t->second.GetName()).second)
+ emitted.insert(t->second.GetName()).second &&
+ // Handle user targets here. Global targets are handled in
+ // the local generator on a per-directory basis.
+ ((t->second.GetType() == cmTarget::EXECUTABLE) ||
+ (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
+ (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
+ (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
+ (t->second.GetType() == cmTarget::UTILITY)))
{
- // Handle user targets here. Global targets are handled in
- // the local generator on a per-directory basis.
- if((t->second.GetType() == cmTarget::EXECUTABLE) ||
- (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
- (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
- (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
- (t->second.GetType() == cmTarget::UTILITY))
- {
- // Add a rule to build the target by name.
- lg->WriteDivider(ruleFileStream);
- ruleFileStream
- << "# Target rules for targets named "
- << t->second.GetName() << "\n\n";
-
- // Write the rule.
- commands.clear();
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
- tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall
- (tmp.c_str(),t->second.GetName()));
- depends.clear();
- depends.push_back("cmake_check_build_system");
- lg->WriteMakeRule(ruleFileStream,
- "Build rule for target.",
- t->second.GetName(), depends, commands,
- true);
-
- // Add a fast rule to build the target
- std::string localName = lg->GetRelativeTargetDirectory(t->second);
- std::string makefileName;
- makefileName = localName;
- makefileName += "/build.make";
- depends.clear();
- commands.clear();
- std::string makeTargetName = localName;
- makeTargetName += "/build";
- localName = t->second.GetName();
- localName += "/fast";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
- lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
- localName.c_str(), depends, commands, true);
- }
+ // Add a rule to build the target by name.
+ lg->WriteDivider(ruleFileStream);
+ ruleFileStream
+ << "# Target rules for targets named "
+ << t->second.GetName() << "\n\n";
+
+ // Write the rule.
+ commands.clear();
+ std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
+ tmp += "Makefile2";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (tmp.c_str(),t->second.GetName()));
+ depends.clear();
+ depends.push_back("cmake_check_build_system");
+ lg->WriteMakeRule(ruleFileStream,
+ "Build rule for target.",
+ t->second.GetName(), depends, commands,
+ true);
+
+ // Add a fast rule to build the target
+ std::string localName = lg->GetRelativeTargetDirectory(t->second);
+ std::string makefileName;
+ makefileName = localName;
+ makefileName += "/build.make";
+ depends.clear();
+ commands.clear();
+ std::string makeTargetName = localName;
+ makeTargetName += "/build";
+ localName = t->second.GetName();
+ localName += "/fast";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(), makeTargetName.c_str()));
+ lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
+ localName.c_str(), depends, commands, true);
}
}
}
@@ -714,7 +712,13 @@
cmTargets& targets = lg->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
{
- if (t->second.GetName() && strlen(t->second.GetName()))
+ if (t->second.GetName()
+ && strlen(t->second.GetName())
+ && ((t->second.GetType() == cmTarget::EXECUTABLE)
+ || (t->second.GetType() == cmTarget::STATIC_LIBRARY)
+ || (t->second.GetType() == cmTarget::SHARED_LIBRARY)
+ || (t->second.GetType() == cmTarget::MODULE_LIBRARY)
+ || (t->second.GetType() == cmTarget::UTILITY)))
{
std::string makefileName;
// Add a rule to build the target by name.
@@ -722,165 +726,158 @@
makefileName = localName;
makefileName += "/build.make";
- if (((t->second.GetType() == cmTarget::EXECUTABLE) ||
- (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
- (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
- (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
- (t->second.GetType() == cmTarget::UTILITY)))
+ bool needRequiresStep =
+ this->NeedRequiresStep(lg,t->second.GetName());
+
+ lg->WriteDivider(ruleFileStream);
+ ruleFileStream
+ << "# Target rules for target "
+ << localName << "\n\n";
+
+ commands.clear();
+ if (t->second.GetType() != cmTarget::UTILITY)
{
- bool needRequiresStep =
- this->NeedRequiresStep(lg,t->second.GetName());
+ makeTargetName = localName;
+ makeTargetName += "/depend";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
- lg->WriteDivider(ruleFileStream);
- ruleFileStream
- << "# Target rules for target "
- << localName << "\n\n";
-
- commands.clear();
- if (t->second.GetType() != cmTarget::UTILITY)
+ // add requires if we need it for this generator
+ if (needRequiresStep)
{
makeTargetName = localName;
- makeTargetName += "/depend";
+ makeTargetName += "/requires";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
-
- // add requires if we need it for this generator
- if (needRequiresStep)
- {
- makeTargetName = localName;
- makeTargetName += "/requires";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
- }
+ (makefileName.c_str(),makeTargetName.c_str()));
}
- makeTargetName = localName;
- makeTargetName += "/build";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
-
- // Write the rule.
- localName += "/all";
- depends.clear();
+ }
+ makeTargetName = localName;
+ makeTargetName += "/build";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
+
+ // Write the rule.
+ localName += "/all";
+ depends.clear();
- std::string progressDir =
- lg->GetMakefile()->GetHomeOutputDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
- {
- cmOStringStream progCmd;
- progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
- // all target counts
- progCmd << lg->Convert(progressDir.c_str(),
- cmLocalGenerator::FULL,
- cmLocalGenerator::SHELL);
- progCmd << " ";
- std::vector<int> &progFiles = lg->ProgressFiles[t->first];
- for (std::vector<int>::iterator i = progFiles.begin();
- i != progFiles.end(); ++i)
- {
- progCmd << " " << *i;
- }
- commands.push_back(progCmd.str());
- }
- progressDir = "Built target ";
- progressDir += t->first;
- lg->AppendEcho(commands,progressDir.c_str());
-
- this->AppendGlobalTargetDepends(depends,t->second);
- lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
- localName.c_str(), depends, commands, true);
-
- // add the all/all dependency
- if (!exclude && !t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
- {
- depends.clear();
- depends.push_back(localName);
- commands.clear();
- lg->WriteMakeRule(ruleFileStream, "Include target in all.",
- "all", depends, commands, true);
- }
-
- // Write the rule.
- commands.clear();
- progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
-
+ std::string progressDir =
+ lg->GetMakefile()->GetHomeOutputDirectory();
+ progressDir += cmake::GetCMakeFilesDirectory();
{
- // TODO: Convert the total progress count to a make variable.
cmOStringStream progCmd;
- progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
- // # in target
+ progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
+ // all target counts
progCmd << lg->Convert(progressDir.c_str(),
- cmLocalGenerator::FULL,
- cmLocalGenerator::SHELL);
- //
- std::set<cmStdString> emitted;
- progCmd << " "
- << this->GetTargetTotalNumberOfActions(t->second,
- emitted);
+ cmLocalGenerator::FULL,
+ cmLocalGenerator::SHELL);
+ progCmd << " ";
+ std::vector<int> &progFiles = lg->ProgressFiles[t->first];
+ for (std::vector<int>::iterator i = progFiles.begin();
+ i != progFiles.end(); ++i)
+ {
+ progCmd << " " << *i;
+ }
commands.push_back(progCmd.str());
}
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
- tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall
- (tmp.c_str(),localName.c_str()));
+ progressDir = "Built target ";
+ progressDir += t->first;
+ lg->AppendEcho(commands,progressDir.c_str());
+
+ this->AppendGlobalTargetDepends(depends,t->second);
+ lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
+ localName.c_str(), depends, commands, true);
+
+ // add the all/all dependency
+ if (!exclude && !t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
{
- cmOStringStream progCmd;
- progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
- progCmd << lg->Convert(progressDir.c_str(),
- cmLocalGenerator::FULL,
- cmLocalGenerator::SHELL);
- progCmd << " 0";
- commands.push_back(progCmd.str());
- }
- depends.clear();
- depends.push_back("cmake_check_build_system");
- localName = lg->GetRelativeTargetDirectory(t->second);
- localName += "/rule";
- lg->WriteMakeRule(ruleFileStream,
- "Build rule for subdir invocation for target.",
- localName.c_str(), depends, commands, true);
-
- // Add a target with the canonical name (no prefix, suffix or path).
- commands.clear();
depends.clear();
depends.push_back(localName);
- lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- t->second.GetName(), depends, commands, true);
-
- // Add rules to prepare the target for installation.
- if(t->second.NeedRelinkBeforeInstall())
- {
- localName = lg->GetRelativeTargetDirectory(t->second);
- localName += "/preinstall";
- depends.clear();
- commands.clear();
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), localName.c_str()));
- lg->WriteMakeRule(ruleFileStream,
- "Pre-install relink rule for target.",
- localName.c_str(), depends, commands, true);
- depends.clear();
- depends.push_back(localName);
- commands.clear();
- lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
- "preinstall", depends, commands, true);
- }
-
- // add the clean rule
+ commands.clear();
+ lg->WriteMakeRule(ruleFileStream, "Include target in all.",
+ "all", depends, commands, true);
+ }
+
+ // Write the rule.
+ commands.clear();
+ progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
+ progressDir += cmake::GetCMakeFilesDirectory();
+
+ {
+ // TODO: Convert the total progress count to a make variable.
+ cmOStringStream progCmd;
+ progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
+ // # in target
+ progCmd << lg->Convert(progressDir.c_str(),
+ cmLocalGenerator::FULL,
+ cmLocalGenerator::SHELL);
+ //
+ std::set<cmStdString> emitted;
+ progCmd << " "
+ << this->GetTargetTotalNumberOfActions(t->second,
+ emitted);
+ commands.push_back(progCmd.str());
+ }
+ std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
+ tmp += "Makefile2";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (tmp.c_str(),localName.c_str()));
+ {
+ cmOStringStream progCmd;
+ progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
+ progCmd << lg->Convert(progressDir.c_str(),
+ cmLocalGenerator::FULL,
+ cmLocalGenerator::SHELL);
+ progCmd << " 0";
+ commands.push_back(progCmd.str());
+ }
+ depends.clear();
+ depends.push_back("cmake_check_build_system");
+ localName = lg->GetRelativeTargetDirectory(t->second);
+ localName += "/rule";
+ lg->WriteMakeRule(ruleFileStream,
+ "Build rule for subdir invocation for target.",
+ localName.c_str(), depends, commands, true);
+
+ // Add a target with the canonical name (no prefix, suffix or path).
+ commands.clear();
+ depends.clear();
+ depends.push_back(localName);
+ lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
+ t->second.GetName(), depends, commands, true);
+
+ // Add rules to prepare the target for installation.
+ if(t->second.NeedRelinkBeforeInstall())
+ {
localName = lg->GetRelativeTargetDirectory(t->second);
- makeTargetName = localName;
- makeTargetName += "/clean";
+ localName += "/preinstall";
depends.clear();
commands.clear();
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
- lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
- makeTargetName.c_str(), depends, commands, true);
+ (makefileName.c_str(), localName.c_str()));
+ lg->WriteMakeRule(ruleFileStream,
+ "Pre-install relink rule for target.",
+ localName.c_str(), depends, commands, true);
+ depends.clear();
+ depends.push_back(localName);
commands.clear();
- depends.push_back(makeTargetName);
- lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
- "clean", depends, commands, true);
+ lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
+ "preinstall", depends, commands, true);
}
+
+ // add the clean rule
+ localName = lg->GetRelativeTargetDirectory(t->second);
+ makeTargetName = localName;
+ makeTargetName += "/clean";
+ depends.clear();
+ commands.clear();
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(), makeTargetName.c_str()));
+ lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
+ makeTargetName.c_str(), depends, commands, true);
+ commands.clear();
+ depends.push_back(makeTargetName);
+ lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
+ "clean", depends, commands, true);
}
}
}
@@ -1060,12 +1057,12 @@
// first check the same dir as the current target
lg3 = static_cast<cmLocalUnixMakefileGenerator3 *>
(target.GetMakefile()->GetLocalGenerator());
- result = target.GetMakefile()->FindTarget(name);
+ result = target.GetMakefile()->FindTarget(name, false);
// search each local generator until a match is found
if (!result)
{
- result = this->FindTarget(0,name);
+ result = this->FindTarget(0, name, false);
if (result)
{
lg3 = static_cast<cmLocalUnixMakefileGenerator3 *>
Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- cmGlobalGenerator.cxx 18 May 2007 17:43:39 -0000 1.176
+++ cmGlobalGenerator.cxx 22 May 2007 14:24:59 -0000 1.177
@@ -625,6 +625,7 @@
this->LocalGenerators.clear();
this->TargetDependencies.clear();
this->TotalTargets.clear();
+ this->ImportedTotalTargets.clear();
this->ProjectToTargetMap.clear();
this->ProjectMap.clear();
@@ -1179,7 +1180,8 @@
cmTarget* cmGlobalGenerator::FindTarget(const char* project,
- const char* name)
+ const char* name,
+ bool useImportedTargets)
{
// if project specific
if(project)
@@ -1187,7 +1189,8 @@
std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
for(unsigned int i = 0; i < gens->size(); ++i)
{
- cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name);
+ cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name,
+ useImportedTargets);
if(ret)
{
return ret;
@@ -1197,13 +1200,22 @@
// if all projects/directories
else
{
- std::map<cmStdString,cmTarget *>::iterator i =
- this->TotalTargets.find(name);
- if (i == this->TotalTargets.end())
+ std::map<cmStdString,cmTarget *>::iterator i =
+ this->TotalTargets.find ( name );
+ if ( i != this->TotalTargets.end() )
{
- return 0;
+ return i->second;
+ }
+
+ if ( useImportedTargets )
+ {
+ std::map<cmStdString,cmTarget *>::iterator importedTarget =
+ this->ImportedTotalTargets.find ( name );
+ if ( importedTarget != this->ImportedTotalTargets.end() )
+ {
+ return importedTarget->second;
+ }
}
- return i->second;
}
return 0;
}
@@ -1549,12 +1561,12 @@
if(emitted.insert(lib->first).second)
{
cmTarget *target2 =
- target.GetMakefile()->FindTarget(lib->first.c_str());
-
+ target.GetMakefile()->FindTarget(lib->first.c_str(), false);
+
// search each local generator until a match is found
if (!target2)
{
- target2 = this->FindTarget(0,lib->first.c_str());
+ target2 = this->FindTarget(0,lib->first.c_str(), false);
}
// if a match was found then ...
@@ -1575,12 +1587,12 @@
// Don't emit the same utility twice for this target.
if(emitted.insert(*util).second)
{
- cmTarget *target2 = target.GetMakefile()->FindTarget(util->c_str());
+ cmTarget *target2 = target.GetMakefile()->FindTarget(util->c_str(), false);
// search each local generator until a match is found
if (!target2)
{
- target2 = this->FindTarget(0,util->c_str());
+ target2 = this->FindTarget(0,util->c_str(), false);
}
// if a match was found then ...
@@ -1594,3 +1606,14 @@
return result;
}
+void cmGlobalGenerator::AddTarget(cmTargets::value_type &v)
+{
+ if (v.second.IsImported())
+ {
+ this->ImportedTotalTargets[v.first] = &v.second;
+ }
+ else
+ {
+ this->TotalTargets[v.first] = &v.second;
+ }
+}
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- cmTarget.h 9 May 2007 13:35:59 -0000 1.82
+++ cmTarget.h 22 May 2007 14:24:59 -0000 1.83
@@ -44,7 +44,7 @@
/**
* Return the type of target.
*/
- TargetType GetType()
+ TargetType GetType() const
{
return this->TargetTypeValue;
}
@@ -54,6 +54,8 @@
*/
void SetType(TargetType f, const char* name);
+ void MarkAsImported();
+
///! Set/Get the name of the target
const char* GetName() const {return this->Name.c_str();}
@@ -161,6 +163,8 @@
const char *GetProperty(const char *prop);
const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
bool GetPropertyAsBool(const char *prop);
+
+ bool IsImported() const {return this->IsImportedTarget;}
/** Get the directory in which this target will be built. If the
configuration name is given then the generator will add its
@@ -327,6 +331,7 @@
void GetFullNameInternal(TargetType type, const char* config, bool implib,
std::string& outPrefix, std::string& outBase,
std::string& outSuffix);
+
void GetLibraryNamesInternal(std::string& name,
std::string& soName,
std::string& realName,
@@ -348,6 +353,19 @@
// Get the full path to the target output directory.
const char* GetOutputDir(bool implib);
+ const char* ImportedGetLocation(const char* config);
+ const char* NormalGetLocation(const char* config);
+
+ void NormalGetFullNameInternal(TargetType type, const char* config, bool implib,
+ std::string& outPrefix, std::string& outBase,
+ std::string& outSuffix);
+ void ImportedGetFullNameInternal(TargetType type, const char* config, bool implib,
+ std::string& outPrefix, std::string& outBase,
+ std::string& outSuffix);
+
+ const char* ImportedGetDirectory(const char* config, bool implib);
+ const char* NormalGetDirectory(const char* config, bool implib);
+
private:
std::string Name;
std::vector<cmCustomCommand> PreBuildCommands;
@@ -376,6 +394,7 @@
cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;
bool DLLPlatform;
+ bool IsImportedTarget;
// The cmMakefile instance that owns this target. This should
// always be set.
Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- cmMakefileTargetGenerator.cxx 16 May 2007 17:24:17 -0000 1.63
+++ cmMakefileTargetGenerator.cxx 22 May 2007 14:24:59 -0000 1.64
@@ -1194,7 +1194,7 @@
{
// Depend on other CMake targets.
if(cmTarget* tgt =
- this->GlobalGenerator->FindTarget(0, lib->first.c_str()))
+ this->GlobalGenerator->FindTarget(0, lib->first.c_str(), false))
{
if(const char* location =
tgt->GetLocation(this->LocalGenerator->ConfigurationName.c_str()))
Index: cmGetTargetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGetTargetPropertyCommand.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmGetTargetPropertyCommand.cxx 15 Mar 2006 16:02:02 -0000 1.7
+++ cmGetTargetPropertyCommand.cxx 22 May 2007 14:24:59 -0000 1.8
@@ -29,7 +29,7 @@
const char* targetName = args[1].c_str();
cmTarget *tgt = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
- ->FindTarget(0,targetName);
+ ->FindTarget(0, targetName, true);
if (tgt)
{
cmTarget& target = *tgt;
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- cmTarget.cxx 17 May 2007 15:18:23 -0000 1.141
+++ cmTarget.cxx 22 May 2007 14:24:59 -0000 1.142
@@ -38,7 +38,7 @@
this->LinkDirectoriesComputed = false;
this->HaveInstallRule = false;
this->DLLPlatform = false;
-
+ this->IsImportedTarget = false;
}
// define properties
@@ -90,7 +90,7 @@
cm->DefineProperty
("EchoString", cmProperty::TARGET,
- "A message to be displayed when the target it built.",
+ "A message to be displayed when the target is built.",
"A message to display on some generaters (such as makefiles) when "
"the target is built.");
@@ -424,8 +424,8 @@
{
std::string command = *cit->begin();
// see if we can find a target with this name
- cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget ( 0, command.c_str() );
+ cmTarget* t = this->Makefile->GetLocalGenerator()->
+ GetGlobalGenerator()->FindTarget(0, command.c_str(), false);
if ( ( t ) && ( t->GetType() ==cmTarget::EXECUTABLE ) )
{
this->AddUtility ( command.c_str() );
@@ -577,7 +577,7 @@
const std::string& currentCommand = (*it)[0];
// see if we can find a target with this name
cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, currentCommand.c_str());
+ GetGlobalGenerator()->FindTarget(0, currentCommand.c_str(), false);
if (( t) && (t->GetType()==cmTarget::EXECUTABLE))
{
automaticTargetDepends.push_back(currentCommand);
@@ -600,7 +600,7 @@
bool isUtility = false;
// see if we can find a target with this name
cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, dep.c_str());
+ GetGlobalGenerator()->FindTarget(0, dep.c_str(), false);
if(t)
{
// if we find the target and the dep was given as a full
@@ -783,7 +783,7 @@
this->Makefile->GetLocalGenerator()->GetGlobalGenerator())
{
tgt = (this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
- ->FindTarget(0, lib.c_str()));
+ ->FindTarget(0, lib.c_str(), false));
}
if(tgt)
{
@@ -1220,8 +1220,32 @@
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
}
+void cmTarget::MarkAsImported()
+{
+ this->IsImportedTarget = true;
+}
+
const char* cmTarget::GetDirectory(const char* config, bool implib)
{
+ if (this->IsImported())
+ {
+ return this->ImportedGetDirectory(config, implib);
+ }
+ else
+ {
+ return this->NormalGetDirectory(config, implib);
+ }
+}
+
+const char* cmTarget::ImportedGetDirectory(const char* config, bool implib)
+{
+ const char* location=this->GetLocation(config);
+ std::string directory=cmSystemTools::GetFilenamePath(location);
+ return directory.c_str();
+}
+
+const char* cmTarget::NormalGetDirectory(const char* config, bool implib)
+{
if(config && *config)
{
this->Directory = this->GetOutputDir(implib);
@@ -1238,6 +1262,34 @@
const char* cmTarget::GetLocation(const char* config)
{
+ if (this->IsImported())
+ {
+ return this->ImportedGetLocation(config);
+ }
+ else
+ {
+ return this->NormalGetLocation(config);
+ }
+}
+
+const char* cmTarget::ImportedGetLocation(const char* config)
+{
+ if ((config) && (strlen(config)))
+ {
+ std::string propertyName=config;
+ propertyName+="_LOCATION";
+ const char* configLocation=this->GetProperty(propertyName.c_str());
+ if ((configLocation) && (strlen(configLocation)))
+ {
+ return configLocation;
+ }
+ }
+
+ return this->GetProperty("LOCATION");
+}
+
+const char* cmTarget::NormalGetLocation(const char* config)
+{
this->Location = this->GetDirectory();
if(!this->Location.empty())
{
@@ -1283,6 +1335,11 @@
void cmTarget::ComputeObjectFiles()
{
+ if (this->IsImported())
+ {
+ return;
+ }
+
// Force the SourceFiles vector to be populated
this->GenerateSourceFilesFromSourceLists(*this->Makefile);
std::vector<std::string> dirs;
@@ -1336,33 +1393,43 @@
return 0;
}
- // watch for special "computed" properties that are dependent on other
- // properties or variables, always recompute them
- if (!strcmp(prop,"LOCATION"))
- {
- // Set the LOCATION property of the target. Note that this cannot take
- // into account the per-configuration name of the target because the
- // configuration type may not be known at CMake time. We should
- // deprecate this feature and instead support transforming an executable
- // target name given as the command part of custom commands into the
- // proper path at build time. Alternatively we could put environment
- // variable settings in all custom commands that hold the name of the
- // target for each configuration and then give a reference to the
- // variable in the location.
- this->SetProperty("LOCATION", this->GetLocation(0));
- }
-
- // Per-configuration location can be computed.
- int len = static_cast<int>(strlen(prop));
- if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
- {
- std::string configName(prop, len-9);
- this->SetProperty(prop, this->GetLocation(configName.c_str()));
- }
-
- if(strcmp(prop, "OBJECT_FILES") == 0)
+ // don't use GetLocation() for imported targets, because there this
+ // calls GetProperty() to get the location...
+ if (!this->IsImported())
+ {
+ // watch for special "computed" properties that are dependent on other
+ // properties or variables, always recompute them
+ if (!strcmp(prop,"LOCATION"))
+ {
+ // Set the LOCATION property of the target. Note that this cannot take
+ // into account the per-configuration name of the target because the
+ // configuration type may not be known at CMake time. We should
+ // deprecate this feature and instead support transforming an executable
+ // target name given as the command part of custom commands into the
+ // proper path at build time. Alternatively we could put environment
+ // variable settings in all custom commands that hold the name of the
+ // target for each configuration and then give a reference to the
+ // variable in the location.
+ this->SetProperty("LOCATION", this->GetLocation(0));
+ }
+
+ // Per-configuration location can be computed.
+ int len = static_cast<int>(strlen(prop));
+ if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
+ {
+ std::string configName(prop, len-9);
+ this->SetProperty(prop, this->GetLocation(configName.c_str()));
+ }
+
+ if(strcmp(prop, "OBJECT_FILES") == 0)
+ {
+ this->ComputeObjectFiles();
+ }
+ }
+
+ if (strcmp(prop,"IMPORTED") == 0)
{
- this->ComputeObjectFiles();
+ return this->IsImported()?"TRUE":"FALSE";
}
// the type property returns what type the target is
@@ -1607,13 +1674,48 @@
return prefix+base+suffix;
}
-//----------------------------------------------------------------------------
void cmTarget::GetFullNameInternal(TargetType type,
- const char* config,
- bool implib,
- std::string& outPrefix,
- std::string& outBase,
- std::string& outSuffix)
+ const char* config,
+ bool implib,
+ std::string& outPrefix,
+ std::string& outBase,
+ std::string& outSuffix)
+{
+ if (this->IsImported())
+ {
+ this->ImportedGetFullNameInternal(type, config, implib,
+ outPrefix, outBase, outSuffix);
+ }
+ else
+ {
+ this->NormalGetFullNameInternal(type, config, implib,
+ outPrefix, outBase, outSuffix);
+ }
+}
+
+void cmTarget::ImportedGetFullNameInternal(TargetType type,
+ const char* config,
+ bool implib,
+ std::string& outPrefix,
+ std::string& outBase,
+ std::string& outSuffix)
+{
+ // find the basename, suffix and prefix from getLocation()
+ // implib ?
+ std::string location=this->GetLocation(config);
+ outBase=cmSystemTools::GetFilenameWithoutExtension(location);
+ outSuffix = cmSystemTools::GetFilenameExtension(location);
+ outPrefix.clear();
+}
+
+
+//----------------------------------------------------------------------------
+void cmTarget::NormalGetFullNameInternal(TargetType type,
+ const char* config,
+ bool implib,
+ std::string& outPrefix,
+ std::string& outBase,
+ std::string& outSuffix)
{
// Use just the target name for non-main target types.
if(type != cmTarget::STATIC_LIBRARY &&
Index: cmAddExecutableCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddExecutableCommand.cxx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- cmAddExecutableCommand.cxx 12 Mar 2007 14:26:59 -0000 1.29
+++ cmAddExecutableCommand.cxx 22 May 2007 14:24:59 -0000 1.30
@@ -32,6 +32,7 @@
bool use_win32 = false;
bool use_macbundle = false;
bool excludeFromAll = false;
+ bool importTarget = false;
while ( s != args.end() )
{
if (*s == "WIN32")
@@ -49,11 +50,22 @@
++s;
excludeFromAll = true;
}
+ else if(*s == "IMPORT")
+ {
+ ++s;
+ importTarget = true;
+ }
else
{
break;
}
}
+
+ if (importTarget)
+ {
+ cmTarget* target = this->Makefile->AddNewTarget(cmTarget::EXECUTABLE, exename.c_str(), true);
+ return true;
+ }
if (s == args.end())
{
Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cmGlobalVisualStudio8Generator.cxx 10 Apr 2007 13:54:01 -0000 1.19
+++ cmGlobalVisualStudio8Generator.cxx 22 May 2007 14:24:59 -0000 1.20
@@ -94,7 +94,7 @@
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
no_working_directory, no_depends,
noCommandLines);
- cmTarget* tgt = mf->FindTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+ cmTarget* tgt = mf->FindTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false);
if(!tgt)
{
cmSystemTools::Error("Error adding target "
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- cmGlobalXCodeGenerator.cxx 14 May 2007 15:23:37 -0000 1.151
+++ cmGlobalXCodeGenerator.cxx 22 May 2007 14:24:59 -0000 1.152
@@ -272,7 +272,7 @@
mf->AddUtilityCommand("ALL_BUILD", true, no_depends,
no_working_directory,
"echo", "Build all projects");
- cmTarget* allbuild = mf->FindTarget("ALL_BUILD");
+ cmTarget* allbuild = mf->FindTarget("ALL_BUILD", false);
// Add XCODE depend helper
std::string dir = mf->GetCurrentOutputDirectory();
@@ -1035,8 +1035,7 @@
cc.GetDepends().begin();
d != cc.GetDepends().end(); ++d)
{
- if(!this->FindTarget(this->CurrentProject.c_str(),
- d->c_str()))
+ if(!this->FindTarget(this->CurrentProject.c_str(), d->c_str(), false))
{
// if the depend is not a target but
// is a full path then use it, if not then
@@ -1860,7 +1859,7 @@
{
// Add this dependency.
cmTarget* t = this->FindTarget(this->CurrentProject.c_str(),
- lib->first.c_str());
+ lib->first.c_str(), false);
cmXCodeObject* dptarget = this->FindXCodeTarget(t);
if(dptarget)
{
@@ -1876,7 +1875,7 @@
i != cmtarget->GetUtilities().end(); ++i)
{
cmTarget* t = this->FindTarget(this->CurrentProject.c_str(),
- i->c_str());
+ i->c_str(), false);
// if the target is in this project then make target depend
// on it. It may not be in this project if this is a sub
// project from the top.
Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- cmLocalVisualStudio6Generator.cxx 14 May 2007 15:23:37 -0000 1.123
+++ cmLocalVisualStudio6Generator.cxx 22 May 2007 14:24:59 -0000 1.124
@@ -1051,7 +1051,8 @@
// Compute the proper name to use to link this library.
std::string lib;
std::string libDebug;
- cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str());
+ cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str(),
+ false);
if(tgt)
{
lib = cmSystemTools::GetFilenameWithoutExtension
Index: cmIncludeExternalMSProjectCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeExternalMSProjectCommand.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cmIncludeExternalMSProjectCommand.cxx 12 Mar 2007 14:26:59 -0000 1.18
+++ cmIncludeExternalMSProjectCommand.cxx 22 May 2007 14:24:59 -0000 1.19
@@ -50,10 +50,8 @@
cmSystemTools::ConvertToUnixSlashes(path);
// Create a target instance for this utility.
- cmTarget target;
- target.SetType(cmTarget::UTILITY, utility_name.c_str());
- target.SetProperty("EXCLUDE_FROM_ALL","FALSE");
- target.SetMakefile(this->Makefile);
+ cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY, utility_name.c_str());
+ target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
std::vector<std::string> no_outputs;
cmCustomCommandLines commandLines;
cmCustomCommandLine commandLine;
@@ -61,13 +59,7 @@
commandLine.push_back(path);
commandLines.push_back(commandLine);
cmCustomCommand cc(no_outputs, depends, commandLines, 0, 0);
- target.GetPostBuildCommands().push_back(cc);
-
- // Add the target to the set of targets.
- cmTargets::iterator it =
- this->Makefile->GetTargets()
- .insert(cmTargets::value_type(utility_name.c_str(),target)).first;
- this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->AddTarget(*it);
+ target->GetPostBuildCommands().push_back(cc);
}
#endif
return true;
Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cmInstallCommand.cxx 19 Mar 2007 14:00:35 -0000 1.20
+++ cmInstallCommand.cxx 22 May 2007 14:24:59 -0000 1.21
@@ -252,7 +252,7 @@
else if(doing_targets)
{
// Lookup this target in the current directory.
- if(cmTarget* target = this->Makefile->FindTarget(args[i].c_str()))
+ if(cmTarget* target = this->Makefile->FindTarget(args[i].c_str(), false))
{
// Found the target. Check its type.
if(target->GetType() != cmTarget::EXECUTABLE &&
Index: cmGlobalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.cxx,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- cmGlobalVisualStudio7Generator.cxx 9 May 2007 12:25:45 -0000 1.86
+++ cmGlobalVisualStudio7Generator.cxx 22 May 2007 14:24:59 -0000 1.87
@@ -588,7 +588,9 @@
if(j->first != dspname)
{
// is the library part of this SLN ? If so add dependency
- if(this->FindTarget(this->CurrentProject.c_str(), j->first.c_str()))
+ if(this->FindTarget(this->CurrentProject.c_str(),
+ j->first.c_str()),
+ false)
{
std::string guid = this->GetGUID(j->first.c_str());
if(guid.size() == 0)
Index: cmGlobalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio6Generator.cxx,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- cmGlobalVisualStudio6Generator.cxx 9 May 2007 12:25:45 -0000 1.68
+++ cmGlobalVisualStudio6Generator.cxx 22 May 2007 14:24:59 -0000 1.69
@@ -401,7 +401,7 @@
if(j->first != dspname)
{
// is the library part of this DSW ? If so add dependency
- if(this->FindTarget(0, j->first.c_str()))
+ if(this->FindTarget(0, j->first.c_str()), false)
{
fout << "Begin Project Dependency\n";
fout << "Project_Dep_Name " << j->first.c_str() << "\n";
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.390
retrieving revision 1.391
diff -u -d -r1.390 -r1.391
--- cmMakefile.cxx 17 May 2007 21:40:59 -0000 1.390
+++ cmMakefile.cxx 22 May 2007 14:24:59 -0000 1.391
@@ -825,12 +825,10 @@
bool escapeOldStyle, const char* comment)
{
// Create a target instance for this utility.
- cmTarget target;
- target.SetMakefile(this);
- target.SetType(cmTarget::UTILITY, utilityName);
+ cmTarget* target = this->AddNewTarget(cmTarget::UTILITY, utilityName, false);
if (excludeFromAll)
{
- target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
if(!comment)
{
@@ -850,7 +848,7 @@
commandLines, comment,
workingDirectory, no_replace,
escapeOldStyle);
- target.GetSourceLists().push_back(force);
+ target->GetSourceLists().push_back(force);
// The output is not actually created so mark it symbolic.
if(cmSourceFile* sf = this->GetSource(force.c_str()))
@@ -862,11 +860,6 @@
cmSystemTools::Error("Could not get source file entry for ",
force.c_str());
}
-
- // Add the target to the set of targets.
- cmTargets::iterator it =
- this->Targets.insert(cmTargets::value_type(utilityName,target)).first;
- this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it);
}
void cmMakefile::AddDefineFlag(const char* flag)
@@ -940,7 +933,7 @@
if ( i != this->Targets.end())
{
cmTarget* tgt =
- this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0, lib);
+ this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0, lib, false);
if(tgt)
{
bool allowModules = true;
@@ -1343,53 +1336,64 @@
const std::vector<std::string> &srcs,
bool excludeFromAll)
{
- cmTarget target;
+ cmTarget* target=0;
switch (shared)
{
case 0:
- target.SetType(cmTarget::STATIC_LIBRARY, lname);
+ target=this->AddNewTarget(cmTarget::STATIC_LIBRARY, lname, false);
break;
case 1:
- target.SetType(cmTarget::SHARED_LIBRARY, lname);
+ target=this->AddNewTarget(cmTarget::SHARED_LIBRARY, lname, false);
break;
case 2:
- target.SetType(cmTarget::MODULE_LIBRARY, lname);
+ target=this->AddNewTarget(cmTarget::MODULE_LIBRARY, lname, false);
break;
default:
- target.SetType(cmTarget::STATIC_LIBRARY, lname);
+ target=this->AddNewTarget(cmTarget::STATIC_LIBRARY, lname, false);
}
- target.SetMakefile(this);
// Clear its dependencies. Otherwise, dependencies might persist
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
- target.ClearDependencyInformation( *this, lname );
+ target->ClearDependencyInformation( *this, lname );
if(excludeFromAll)
{
- target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
- target.GetSourceLists() = srcs;
- this->AddGlobalLinkInformation(lname, target);
- cmTargets::iterator it =
- this->Targets.insert(cmTargets::value_type(lname,target)).first;
- this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it);
+ target->GetSourceLists() = srcs;
+ this->AddGlobalLinkInformation(lname, *target);
}
cmTarget* cmMakefile::AddExecutable(const char *exeName,
const std::vector<std::string> &srcs,
bool excludeFromAll)
{
- cmTarget target;
- target.SetType(cmTarget::EXECUTABLE, exeName);
- target.SetMakefile(this);
+ cmTarget* target = this->AddNewTarget(cmTarget::EXECUTABLE, exeName, false);
if(excludeFromAll)
{
- target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
- target.GetSourceLists() = srcs;
- this->AddGlobalLinkInformation(exeName, target);
- cmTargets::iterator it =
- this->Targets.insert(cmTargets::value_type(exeName,target)).first;
+ target->GetSourceLists() = srcs;
+ this->AddGlobalLinkInformation(exeName, *target);
+ return target;
+}
+
+
+cmTarget* cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name, bool isImported)
+{
+ cmTargets::iterator it;
+ cmTarget target;
+ target.SetType(type, name);
+ target.SetMakefile(this);
+ if (isImported)
+ {
+ target.MarkAsImported();
+ it=this->ImportedTargets.insert(cmTargets::value_type(target.GetName(), target)).first;
+ }
+ else
+ {
+ it=this->Targets.insert(cmTargets::value_type(target.GetName(), target)).first;
+ }
this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it);
return &it->second;
}
@@ -2709,7 +2713,7 @@
return this->GetCMakeInstance()->GetProperty(prop,scope);
}
- return retVal;
+ return retVal;
}
bool cmMakefile::GetPropertyAsBool(const char* prop)
@@ -2718,16 +2722,26 @@
}
-cmTarget* cmMakefile::FindTarget(const char* name)
+cmTarget* cmMakefile::FindTarget(const char* name, bool useImportedTargets)
{
cmTargets& tgts = this->GetTargets();
-
- cmTargets::iterator i = tgts.find(name);
- if (i == tgts.end())
+
+ cmTargets::iterator i = tgts.find ( name );
+ if ( i != tgts.end() )
{
- return 0;
+ return &i->second;
}
- return &i->second;
+
+ if (useImportedTargets)
+ {
+ cmTargets::iterator impTarget = this->ImportedTargets.find(name);
+ if (impTarget != this->ImportedTargets.end())
+ {
+ return &impTarget->second;
+ }
+ }
+
+ return 0;
}
cmTest* cmMakefile::CreateTest(const char* testName)
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -d -r1.220 -r1.221
--- cmLocalGenerator.cxx 18 May 2007 15:36:23 -0000 1.220
+++ cmLocalGenerator.cxx 22 May 2007 14:24:59 -0000 1.221
@@ -148,8 +148,7 @@
if ((t->second.GetType() != cmTarget::INSTALL_FILES)
&& (t->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (t->second.GetType() != cmTarget::INSTALL_DIRECTORY)
- && (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
- && (t->second.GetPropertyAsBool("IMPORTED") == false))
+ && (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
{
std::string projectFilename;
if (this->IsMakefileGenerator == false) // only use of this variable
@@ -1733,7 +1732,7 @@
(j->second == cmTarget::GENERAL || j->second == linkType))
{
// Compute the proper name to use to link this library.
- cmTarget* tgt = this->GlobalGenerator->FindTarget(0, lib.c_str());
+ cmTarget* tgt = this->GlobalGenerator->FindTarget(0, lib.c_str(), false);
bool impexe = (tgt &&
tgt->GetType() == cmTarget::EXECUTABLE &&
tgt->GetPropertyAsBool("ENABLE_EXPORTS"));
@@ -1963,7 +1962,7 @@
}
// Look for a CMake target with the given name.
- if(cmTarget* target = this->GlobalGenerator->FindTarget(0, name.c_str()))
+ if(cmTarget* target = this->GlobalGenerator->FindTarget(0,name.c_str(),false))
{
// make sure it is not just a coincidence that the target name
// found is part of the inName
@@ -2029,8 +2028,8 @@
{
std::string outName=inName;
// Look for a CMake target with the given name.
- cmTarget* target = this->GlobalGenerator->FindTarget(0, inName);
- if ((target!=0) && (target->GetType()==cmTarget::EXECUTABLE))
+ cmTarget* target = this->GlobalGenerator->FindTarget(0, inName, true);
+ if ((target != 0) && (target->GetType() == cmTarget::EXECUTABLE))
{
outName = target->GetLocation( config );
}
Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cmInstallTargetGenerator.cxx 18 May 2007 15:57:29 -0000 1.33
+++ cmInstallTargetGenerator.cxx 22 May 2007 14:24:59 -0000 1.34
@@ -376,7 +376,7 @@
{
if(cmTarget* tgt = this->Target->GetMakefile()->
GetLocalGenerator()->GetGlobalGenerator()->
- FindTarget(0, lib.c_str()))
+ FindTarget(0, lib.c_str(), false))
{
if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
{
Index: cmGlobalVisualStudioGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmGlobalVisualStudioGenerator.cxx 10 Apr 2007 17:09:03 -0000 1.3
+++ cmGlobalVisualStudioGenerator.cxx 22 May 2007 14:24:59 -0000 1.4
@@ -104,7 +104,7 @@
target.GetUtilities().begin();
ui != target.GetUtilities().end(); ++ui)
{
- if(cmTarget* depTarget = this->FindTarget(0, ui->c_str()))
+ if(cmTarget* depTarget = this->FindTarget(0, ui->c_str(), false))
{
if(depTarget->GetType() == cmTarget::STATIC_LIBRARY ||
depTarget->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -149,7 +149,7 @@
this->CreateGUID(altNameStr.c_str());
// The intermediate target should depend on the original target.
- if(cmTarget* alt = this->FindTarget(0, altNameStr.c_str()))
+ if(cmTarget* alt = this->FindTarget(0, altNameStr.c_str(), false))
{
alt->AddUtility(target.GetName());
}
@@ -205,7 +205,7 @@
{
// The depender is a target that links. Lookup the dependee to
// see if it provides an alternative dependency name.
- if(cmTarget* depTarget = this->FindTarget(0, name))
+ if(cmTarget* depTarget = this->FindTarget(0, name, false))
{
// Check for an alternative name created by FixUtilityDepends.
if(const char* altName =
Index: cmSetTargetPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetTargetPropertiesCommand.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmSetTargetPropertiesCommand.cxx 7 Feb 2007 16:49:42 -0000 1.6
+++ cmSetTargetPropertiesCommand.cxx 22 May 2007 14:24:59 -0000 1.7
@@ -96,7 +96,7 @@
cmMakefile *mf)
{
cmTarget* target =
- mf->GetLocalGenerator()->GetGlobalGenerator()->FindTarget(0, tname);
+ mf->GetLocalGenerator()->GetGlobalGenerator()->FindTarget(0, tname, true);
if ( target)
{
// now loop through all the props and set them
Index: cmGlobalVisualStudio71Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio71Generator.cxx,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cmGlobalVisualStudio71Generator.cxx 10 Apr 2007 13:54:01 -0000 1.39
+++ cmGlobalVisualStudio71Generator.cxx 22 May 2007 14:24:59 -0000 1.40
@@ -333,7 +333,9 @@
if(j->first != dspname)
{
// is the library part of this SLN ? If so add dependency
- if(this->FindTarget(this->CurrentProject.c_str(), j->first.c_str()))
+ if(this->FindTarget(this->CurrentProject.c_str(),
+ j->first.c_str()),
+ false)
{
fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {"
<< this->GetGUID(j->first.c_str()) << "}\n";
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- cmMakefile.h 17 May 2007 21:40:59 -0000 1.203
+++ cmMakefile.h 22 May 2007 14:24:59 -0000 1.204
@@ -167,6 +167,8 @@
void AddDefineFlag(const char* definition);
void RemoveDefineFlag(const char* definition);
+ cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name, bool isImported);
+
/**
* Add an executable to the build.
*/
@@ -416,8 +418,9 @@
* Get the list of targets
*/
cmTargets &GetTargets() { return this->Targets; }
+ const cmTargets &GetImportedTargets() const { return this->ImportedTargets; }
- cmTarget* FindTarget(const char* name);
+ cmTarget* FindTarget(const char* name, bool useImportedTargets);
/**
@@ -741,6 +744,7 @@
// libraries, classes, and executables
cmTargets Targets;
+ cmTargets ImportedTargets;
std::vector<cmSourceFile*> SourceFiles;
// Tests
Index: cmAddDependenciesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddDependenciesCommand.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cmAddDependenciesCommand.cxx 7 Feb 2007 16:49:42 -0000 1.14
+++ cmAddDependenciesCommand.cxx 22 May 2007 14:24:59 -0000 1.15
@@ -32,7 +32,7 @@
cmTarget* target =
this->GetMakefile()->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, target_name.c_str());
+ GetGlobalGenerator()->FindTarget(0, target_name.c_str(), false);
if(target)
{
std::vector<std::string>::const_iterator s = args.begin();
Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- cmLocalUnixMakefileGenerator3.cxx 18 May 2007 17:43:39 -0000 1.209
+++ cmLocalUnixMakefileGenerator3.cxx 22 May 2007 14:24:59 -0000 1.210
@@ -114,7 +114,6 @@
if (tg)
{
this->TargetGenerators.push_back(tg);
-// t->second.TraceVSDependencies(empty, this->Makefile);
tg->WriteRuleFiles();
}
}
More information about the Cmake-commits
mailing list