Merge topic 'use-generator-target'

29886ce7 cmTarget: Use a simpler delete algorithm.
197f4de1 cmTarget: Split storage of compile definitions from genexes.
44e071ae cmTarget: Split storage of compile features from genexes.
772ecef4 cmTarget: Split storage of compile options from genexes.
1f54bc1c cmTarget: Split storage of include directories from genexes.
7568199b cmTarget: Request only the link libraries where needed.
10040601 cmLinkImplementationLibraries: Move to namespace scope.
d9da6ee2 cmLinkItem: Split to separate file.
27252b24 cmComputeLinkInformation: Simplify generator object access.
This commit is contained in:
Brad King 2015-08-11 08:47:08 -04:00 committed by CMake Topic Stage
commit 6e5953e9a4
12 changed files with 212 additions and 167 deletions

View File

@ -288,6 +288,7 @@ set(SRCS
cmInstallDirectoryGenerator.h cmInstallDirectoryGenerator.h
cmInstallDirectoryGenerator.cxx cmInstallDirectoryGenerator.cxx
cmLinkedTree.h cmLinkedTree.h
cmLinkItem.h
cmListFileCache.cxx cmListFileCache.cxx
cmListFileCache.h cmListFileCache.h
cmListFileLexer.c cmListFileLexer.c

View File

@ -14,6 +14,7 @@
#include "cmComputeLinkDepends.h" #include "cmComputeLinkDepends.h"
#include "cmOrderDirectories.h" #include "cmOrderDirectories.h"
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmState.h" #include "cmState.h"
#include "cmOutputConverter.h" #include "cmOutputConverter.h"
@ -248,7 +249,8 @@ cmComputeLinkInformation
// Store context information. // Store context information.
this->Target = target; this->Target = target;
this->Makefile = this->Target->Target->GetMakefile(); this->Makefile = this->Target->Target->GetMakefile();
this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->GlobalGenerator =
this->Target->GetLocalGenerator()->GetGlobalGenerator();
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// Check whether to recognize OpenBSD-style library versioned names. // Check whether to recognize OpenBSD-style library versioned names.
@ -540,9 +542,7 @@ bool cmComputeLinkInformation::Compute()
i != wrongItems.end(); ++i) i != wrongItems.end(); ++i)
{ {
cmTarget const* tgt = *i; cmTarget const* tgt = *i;
cmGeneratorTarget *gtgt = tgt->GetMakefile() cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt);
->GetGlobalGenerator()
->GetGeneratorTarget(tgt);
bool implib = bool implib =
(this->UseImportLibrary && (this->UseImportLibrary &&
(tgt->GetType() == cmTarget::SHARED_LIBRARY)); (tgt->GetType() == cmTarget::SHARED_LIBRARY));
@ -646,9 +646,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
if(tgt && tgt->IsLinkable()) if(tgt && tgt->IsLinkable())
{ {
cmGeneratorTarget *gtgt = tgt->GetMakefile() cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt);
->GetGlobalGenerator()
->GetGeneratorTarget(tgt);
// This is a CMake target. Ask the target for its real name. // This is a CMake target. Ask the target for its real name.
if(impexe && this->LoaderFlag) if(impexe && this->LoaderFlag)
{ {
@ -762,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
return; return;
} }
cmGeneratorTarget *gtgt = 0; cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt);
// Get a full path to the dependent shared library. // Get a full path to the dependent shared library.
// Add it to the runtime path computation so that the target being // Add it to the runtime path computation so that the target being
@ -1812,9 +1810,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
// Try to get the soname of the library. Only files with this name // Try to get the soname of the library. Only files with this name
// could possibly conflict. // could possibly conflict.
cmGeneratorTarget *gtgt = target->GetMakefile() cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target);
->GetGlobalGenerator()
->GetGeneratorTarget(target);
std::string soName = gtgt->GetSOName(this->Config); std::string soName = gtgt->GetSOName(this->Config);
const char* soname = soName.empty()? 0 : soName.c_str(); const char* soname = soName.empty()? 0 : soName.c_str();

View File

@ -1120,7 +1120,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
else if(!interfacePropertyName.empty()) else if(!interfacePropertyName.empty())
{ {
if(cmTarget::LinkImplementationLibraries const* impl = if(cmLinkImplementationLibraries const* impl =
target->GetLinkImplementationLibraries(context->Config)) target->GetLinkImplementationLibraries(context->Config))
{ {
linkedTargetsContent = linkedTargetsContent =

View File

@ -1507,7 +1507,7 @@ cmGeneratorTarget::GetLinkImplementationClosure(
tgts.Done = true; tgts.Done = true;
std::set<cmTarget const*> emitted; std::set<cmTarget const*> emitted;
cmTarget::LinkImplementationLibraries const* impl cmLinkImplementationLibraries const* impl
= this->Target->GetLinkImplementationLibraries(config); = this->Target->GetLinkImplementationLibraries(config);
for(std::vector<cmLinkImplItem>::const_iterator for(std::vector<cmLinkImplItem>::const_iterator

View File

@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
cmTarget* t = &ti->second; cmTarget* t = &ti->second;
t->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt; this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt; generatorTargets[t] = gt;

View File

@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
no_working_directory, no_depends, no_working_directory, no_depends,
noCommandLines); noCommandLines);
tgt->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
mf->AddGeneratorTarget(tgt, gt); mf->AddGeneratorTarget(tgt, gt);

View File

@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute()
AddUtilityCommand("ALL_BUILD", true, no_working_dir, AddUtilityCommand("ALL_BUILD", true, no_working_dir,
no_depends, no_commands, false, no_depends, no_commands, false,
"Build all projects"); "Build all projects");
allBuild->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt);

View File

@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends,
no_working_directory, no_working_directory,
"echo", "Build all projects"); "echo", "Build all projects");
allbuild->Compute();
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
mf->AddGeneratorTarget(allbuild, allBuildGt); mf->AddGeneratorTarget(allbuild, allBuildGt);
@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
true, no_depends, true, no_depends,
no_working_directory, no_working_directory,
"make", "-f", file.c_str()); "make", "-f", file.c_str());
check->Compute();
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
mf->AddGeneratorTarget(check, checkGt); mf->AddGeneratorTarget(check, checkGt);
} }

59
Source/cmLinkItem.h Normal file
View File

@ -0,0 +1,59 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2004-2015 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmLinkItem_h
#define cmLinkItem_h
#include "cmListFileCache.h"
class cmTarget;
// Basic information about each link item.
class cmLinkItem: public std::string
{
typedef std::string std_string;
public:
cmLinkItem(): std_string(), Target(0) {}
cmLinkItem(const std_string& n,
cmTarget const* t): std_string(n), Target(t) {}
cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
cmTarget const* Target;
};
class cmLinkImplItem: public cmLinkItem
{
public:
cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {}
cmLinkImplItem(std::string const& n,
cmTarget const* t,
cmListFileBacktrace const& bt,
bool fromGenex):
cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {}
cmLinkImplItem(cmLinkImplItem const& r):
cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {}
cmListFileBacktrace Backtrace;
bool FromGenex;
};
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
struct cmLinkImplementationLibraries
{
// Libraries linked directly in this configuration.
std::vector<cmLinkImplItem> Libraries;
// Libraries linked directly in other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
};
#endif

View File

@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
/*byproducts=*/rcc_output, depends, /*byproducts=*/rcc_output, depends,
commandLines, false, autogenComment.c_str()); commandLines, false, autogenComment.c_str());
autogenTarget->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
makefile->AddGeneratorTarget(autogenTarget, gt); makefile->AddGeneratorTarget(autogenTarget, gt);

View File

@ -168,10 +168,18 @@ public:
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
cmLinkImplItem const& LinkImplItem; cmLinkImplItem const& LinkImplItem;
}; };
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<std::string> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries; std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
std::vector<TargetPropertyEntry*> CompileFeaturesEntries; std::vector<TargetPropertyEntry*> IncludeDirectoriesItems;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<std::string> CompileOptionsEntries;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
std::vector<TargetPropertyEntry*> CompileOptionsItems;
std::vector<std::string> CompileFeaturesEntries;
std::vector<cmListFileBacktrace> CompileFeaturesBacktraces;
std::vector<TargetPropertyEntry*> CompileFeaturesItems;
std::vector<std::string> CompileDefinitionsEntries;
std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
std::vector<TargetPropertyEntry*> CompileDefinitionsItems;
std::vector<TargetPropertyEntry*> SourceEntries; std::vector<TargetPropertyEntry*> SourceEntries;
std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries; std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries;
@ -182,14 +190,6 @@ public:
cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
//----------------------------------------------------------------------------
static void deleteAndClear(
std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
{
cmDeleteAll(entries);
entries.clear();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTargetInternals::~cmTargetInternals() cmTargetInternals::~cmTargetInternals()
{ {
@ -366,13 +366,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const cmBacktraceRange parentIncludesBts = const cmBacktraceRange parentIncludesBts =
this->Makefile->GetIncludeDirectoriesBacktraces(); this->Makefile->GetIncludeDirectoriesBacktraces();
cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); this->Internal->IncludeDirectoriesEntries.insert(
for (cmStringRange::const_iterator it this->Internal->IncludeDirectoriesEntries.end(),
= parentIncludes.begin(); parentIncludes.begin(), parentIncludes.end());
it != parentIncludes.end(); ++it, ++btIt) this->Internal->IncludeDirectoriesBacktraces.insert(
{ this->Internal->IncludeDirectoriesBacktraces.end(),
this->InsertInclude(*it, *btIt); parentIncludesBts.begin(), parentIncludesBts.end());
}
const std::set<std::string> parentSystemIncludes = const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories(); this->Makefile->GetSystemIncludeDirectories();
@ -384,13 +384,12 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const cmBacktraceRange parentOptionsBts = const cmBacktraceRange parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces(); this->Makefile->GetCompileOptionsBacktraces();
btIt = parentOptionsBts.begin(); this->Internal->CompileOptionsEntries.insert(
for (cmStringRange::const_iterator it this->Internal->CompileOptionsEntries.end(),
= parentOptions.begin(); parentOptions.begin(), parentOptions.end());
it != parentOptions.end(); ++it, ++btIt) this->Internal->CompileOptionsBacktraces.insert(
{ this->Internal->CompileOptionsBacktraces.end(),
this->InsertCompileOption(*it, *btIt); parentOptionsBts.begin(), parentOptionsBts.end());
}
} }
if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY)
@ -438,6 +437,44 @@ void cmTarget::SetMakefile(cmMakefile* mf)
} }
} }
void CreatePropertyGeneratorExpressions(
std::vector<std::string> const& entries,
std::vector<cmListFileBacktrace> const& backtraces,
std::vector<cmTargetInternals::TargetPropertyEntry*>& items)
{
std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
for (std::vector<std::string>::const_iterator it = entries.begin();
it != entries.end(); ++it, ++btIt)
{
cmGeneratorExpression ge(*btIt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
items.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
}
void cmTarget::Compute()
{
CreatePropertyGeneratorExpressions(
this->Internal->IncludeDirectoriesEntries,
this->Internal->IncludeDirectoriesBacktraces,
this->Internal->IncludeDirectoriesItems);
CreatePropertyGeneratorExpressions(
this->Internal->CompileOptionsEntries,
this->Internal->CompileOptionsBacktraces,
this->Internal->CompileOptionsItems);
CreatePropertyGeneratorExpressions(
this->Internal->CompileFeaturesEntries,
this->Internal->CompileFeaturesBacktraces,
this->Internal->CompileFeaturesItems);
CreatePropertyGeneratorExpressions(
this->Internal->CompileDefinitionsEntries,
this->Internal->CompileDefinitionsBacktraces,
this->Internal->CompileDefinitionsItems);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{ {
@ -765,7 +802,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
this->LinkImplementationLanguageIsContextDependent = false; this->LinkImplementationLanguageIsContextDependent = false;
} }
deleteAndClear(linkInterfaceSourcesEntries); cmDeleteAll(linkInterfaceSourcesEntries);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1666,39 +1703,35 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
} }
else if(prop == "INCLUDE_DIRECTORIES") else if(prop == "INCLUDE_DIRECTORIES")
{ {
this->Internal->IncludeDirectoriesEntries.clear();
this->Internal->IncludeDirectoriesBacktraces.clear();
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
deleteAndClear(this->Internal->IncludeDirectoriesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->IncludeDirectoriesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
} }
else if(prop == "COMPILE_OPTIONS") else if(prop == "COMPILE_OPTIONS")
{ {
this->Internal->CompileOptionsEntries.clear();
this->Internal->CompileOptionsBacktraces.clear();
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileOptionsBacktraces.push_back(lfbt);
deleteAndClear(this->Internal->CompileOptionsEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->CompileOptionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
} }
else if(prop == "COMPILE_FEATURES") else if(prop == "COMPILE_FEATURES")
{ {
this->Internal->CompileFeaturesEntries.clear();
this->Internal->CompileFeaturesBacktraces.clear();
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
deleteAndClear(this->Internal->CompileFeaturesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->CompileFeaturesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
} }
else if(prop == "COMPILE_DEFINITIONS") else if(prop == "COMPILE_DEFINITIONS")
{ {
this->Internal->CompileDefinitionsEntries.clear();
this->Internal->CompileDefinitionsBacktraces.clear();
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
deleteAndClear(this->Internal->CompileDefinitionsEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->CompileDefinitionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
} }
else if(prop == "EXPORT_NAME" && this->IsImported()) else if(prop == "EXPORT_NAME" && this->IsImported())
{ {
@ -1764,31 +1797,27 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
else if(prop == "INCLUDE_DIRECTORIES") else if(prop == "INCLUDE_DIRECTORIES")
{ {
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
this->Internal->IncludeDirectoriesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
} }
else if(prop == "COMPILE_OPTIONS") else if(prop == "COMPILE_OPTIONS")
{ {
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileOptionsBacktraces.push_back(lfbt);
this->Internal->CompileOptionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
} }
else if(prop == "COMPILE_FEATURES") else if(prop == "COMPILE_FEATURES")
{ {
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
this->Internal->CompileFeaturesEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
} }
else if(prop == "COMPILE_DEFINITIONS") else if(prop == "COMPILE_DEFINITIONS")
{ {
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt); this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
this->Internal->CompileDefinitionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
} }
else if(prop == "EXPORT_NAME" && this->IsImported()) else if(prop == "EXPORT_NAME" && this->IsImported())
{ {
@ -1887,14 +1916,16 @@ void cmTarget::InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt, cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(bt); std::vector<std::string>::iterator position =
before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end();
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmListFileBacktrace>::iterator btPosition =
= before ? this->Internal->IncludeDirectoriesEntries.begin() before ? this->Internal->IncludeDirectoriesBacktraces.begin()
: this->Internal->IncludeDirectoriesEntries.end(); : this->Internal->IncludeDirectoriesBacktraces.end();
this->Internal->IncludeDirectoriesEntries.insert(position, this->Internal->IncludeDirectoriesEntries.insert(position, entry);
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1902,24 +1933,24 @@ void cmTarget::InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt, cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(bt); std::vector<std::string>::iterator position =
before ? this->Internal->CompileOptionsEntries.begin()
: this->Internal->CompileOptionsEntries.end();
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmListFileBacktrace>::iterator btPosition =
= before ? this->Internal->CompileOptionsEntries.begin() before ? this->Internal->CompileOptionsBacktraces.begin()
: this->Internal->CompileOptionsEntries.end(); : this->Internal->CompileOptionsBacktraces.end();
this->Internal->CompileOptionsEntries.insert(position, this->Internal->CompileOptionsEntries.insert(position, entry);
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); this->Internal->CompileOptionsBacktraces.insert(btPosition, bt);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::InsertCompileDefinition(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry,
cmListFileBacktrace const& bt) cmListFileBacktrace const& bt)
{ {
cmGeneratorExpression ge(bt); this->Internal->CompileDefinitionsEntries.push_back(entry);
this->Internal->CompileDefinitionsBacktraces.push_back(bt);
this->Internal->CompileDefinitionsEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry)));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2083,7 +2114,7 @@ cmTarget::GetIncludeDirectories(const std::string& config,
} }
processIncludeDirectories(this, processIncludeDirectories(this,
this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesItems,
includes, includes,
uniqueIncludes, uniqueIncludes,
&dagChecker, &dagChecker,
@ -2099,7 +2130,8 @@ cmTarget::GetIncludeDirectories(const std::string& config,
if(this->Makefile->IsOn("APPLE")) if(this->Makefile->IsOn("APPLE"))
{ {
LinkImplementation const* impl = this->GetLinkImplementation(config); cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config);
for(std::vector<cmLinkImplItem>::const_iterator for(std::vector<cmLinkImplItem>::const_iterator
it = impl->Libraries.begin(); it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it) it != impl->Libraries.end(); ++it)
@ -2132,7 +2164,7 @@ cmTarget::GetIncludeDirectories(const std::string& config,
debugIncludes, debugIncludes,
language); language);
deleteAndClear(linkInterfaceIncludeDirectoriesEntries); cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
return includes; return includes;
} }
@ -2229,7 +2261,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
} }
processCompileOptions(this, processCompileOptions(this,
this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsItems,
result, result,
uniqueOptions, uniqueOptions,
&dagChecker, &dagChecker,
@ -2253,7 +2285,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
debugOptions, debugOptions,
language); language);
deleteAndClear(linkInterfaceCompileOptionsEntries); cmDeleteAll(linkInterfaceCompileOptionsEntries);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2300,7 +2332,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
} }
processCompileDefinitions(this, processCompileDefinitions(this,
this->Internal->CompileDefinitionsEntries, this->Internal->CompileDefinitionsItems,
list, list,
uniqueOptions, uniqueOptions,
&dagChecker, &dagChecker,
@ -2355,7 +2387,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
debugDefines, debugDefines,
language); language);
deleteAndClear(linkInterfaceCompileDefinitionsEntries); cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2401,7 +2433,7 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
} }
processCompileFeatures(this, processCompileFeatures(this,
this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesItems,
result, result,
uniqueFeatures, uniqueFeatures,
&dagChecker, &dagChecker,
@ -2422,7 +2454,7 @@ void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
config, config,
debugFeatures); debugFeatures);
deleteAndClear(linkInterfaceCompileFeaturesEntries); cmDeleteAll(linkInterfaceCompileFeaturesEntries);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2707,22 +2739,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
return messageType != cmake::FATAL_ERROR; return messageType != cmake::FATAL_ERROR;
} }
//----------------------------------------------------------------------------
static void MakePropertyList(std::string& output,
std::vector<cmTargetInternals::TargetPropertyEntry*> const& values)
{
output = "";
std::string sep;
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = values.begin(), end = values.end();
it != end; ++it)
{
output += sep;
output += (*it)->ge->GetInput();
sep = ";";
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const std::string& prop) const const char *cmTarget::GetProperty(const std::string& prop) const
{ {
@ -2898,7 +2914,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
static std::string output; static std::string output;
MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
return output.c_str(); return output.c_str();
} }
else if(prop == propCOMPILE_FEATURES) else if(prop == propCOMPILE_FEATURES)
@ -2909,7 +2925,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
static std::string output; static std::string output;
MakePropertyList(output, this->Internal->CompileFeaturesEntries); output = cmJoin(this->Internal->CompileFeaturesEntries, ";");
return output.c_str(); return output.c_str();
} }
else if(prop == propCOMPILE_OPTIONS) else if(prop == propCOMPILE_OPTIONS)
@ -2920,7 +2936,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
static std::string output; static std::string output;
MakePropertyList(output, this->Internal->CompileOptionsEntries); output = cmJoin(this->Internal->CompileOptionsEntries, ";");
return output.c_str(); return output.c_str();
} }
else if(prop == propCOMPILE_DEFINITIONS) else if(prop == propCOMPILE_DEFINITIONS)
@ -2931,7 +2947,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
static std::string output; static std::string output;
MakePropertyList(output, this->Internal->CompileDefinitionsEntries); output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
return output.c_str(); return output.c_str();
} }
else if (prop == propIMPORTED) else if (prop == propIMPORTED)
@ -3381,7 +3397,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const
{ {
return false; return false;
} }
if(LinkImplementationLibraries const* impl = if(cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config)) this->GetLinkImplementationLibraries(config))
{ {
return !impl->Libraries.empty(); return !impl->Libraries.empty();
@ -4331,7 +4347,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
// to the link implementation. // to the link implementation.
{ {
// The link implementation is the default link interface. // The link implementation is the default link interface.
cmTarget::LinkImplementationLibraries const* impl = cmLinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget);
iface.Libraries.insert(iface.Libraries.end(), iface.Libraries.insert(iface.Libraries.end(),
impl->Libraries.begin(), impl->Libraries.end()); impl->Libraries.begin(), impl->Libraries.end());
@ -4431,7 +4447,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
|| thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD)
{ {
// The link implementation is the default link interface. // The link implementation is the default link interface.
cmTarget::LinkImplementationLibraries const* cmLinkImplementationLibraries const*
impl = thisTarget->GetLinkImplementationLibrariesInternal(config, impl = thisTarget->GetLinkImplementationLibrariesInternal(config,
headTarget); headTarget);
iface.ImplementationIsInterface = true; iface.ImplementationIsInterface = true;
@ -4482,7 +4498,7 @@ void cmTargetInternals::AddInterfaceEntries(
cmTarget const* thisTarget, std::string const& config, cmTarget const* thisTarget, std::string const& config,
std::string const& prop, std::vector<TargetPropertyEntry*>& entries) std::string const& prop, std::vector<TargetPropertyEntry*>& entries)
{ {
if(cmTarget::LinkImplementationLibraries const* impl = if(cmLinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibraries(config)) thisTarget->GetLinkImplementationLibraries(config))
{ {
for (std::vector<cmLinkImplItem>::const_iterator for (std::vector<cmLinkImplItem>::const_iterator
@ -4532,14 +4548,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget::LinkImplementationLibraries const* cmLinkImplementationLibraries const*
cmTarget::GetLinkImplementationLibraries(const std::string& config) const cmTarget::GetLinkImplementationLibraries(const std::string& config) const
{ {
return this->GetLinkImplementationLibrariesInternal(config, this); return this->GetLinkImplementationLibrariesInternal(config, this);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget::LinkImplementationLibraries const* cmLinkImplementationLibraries const*
cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
cmTarget const* head) const cmTarget const* head) const
{ {
@ -4804,10 +4820,10 @@ cmTargetInternalPointer
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTargetInternalPointer::~cmTargetInternalPointer() cmTargetInternalPointer::~cmTargetInternalPointer()
{ {
cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); cmDeleteAll(this->Pointer->IncludeDirectoriesItems);
cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileOptionsItems);
cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileFeaturesItems);
cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->CompileDefinitionsItems);
cmDeleteAll(this->Pointer->SourceEntries); cmDeleteAll(this->Pointer->SourceEntries);
delete this->Pointer; delete this->Pointer;
} }

View File

@ -16,6 +16,7 @@
#include "cmPropertyMap.h" #include "cmPropertyMap.h"
#include "cmPolicies.h" #include "cmPolicies.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmLinkItem.h"
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
@ -52,32 +53,6 @@ class cmTarget;
class cmGeneratorTarget; class cmGeneratorTarget;
class cmTargetTraceDependencies; class cmTargetTraceDependencies;
// Basic information about each link item.
class cmLinkItem: public std::string
{
typedef std::string std_string;
public:
cmLinkItem(): std_string(), Target(0) {}
cmLinkItem(const std_string& n,
cmTarget const* t): std_string(n), Target(t) {}
cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
cmTarget const* Target;
};
class cmLinkImplItem: public cmLinkItem
{
public:
cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {}
cmLinkImplItem(std::string const& n,
cmTarget const* t,
cmListFileBacktrace const& bt,
bool fromGenex):
cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {}
cmLinkImplItem(cmLinkImplItem const& r):
cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {}
cmListFileBacktrace Backtrace;
bool FromGenex;
};
class cmTargetInternals; class cmTargetInternals;
class cmTargetInternalPointer class cmTargetInternalPointer
{ {
@ -157,6 +132,8 @@ public:
void AddPostBuildCommand(cmCustomCommand const &cmd) void AddPostBuildCommand(cmCustomCommand const &cmd)
{this->PostBuildCommands.push_back(cmd);} {this->PostBuildCommands.push_back(cmd);}
void Compute();
/** /**
* Get the list of the source files used by this target * Get the list of the source files used by this target
*/ */
@ -293,18 +270,7 @@ public:
cmTarget const* headTarget, cmTarget const* headTarget,
bool usage_requirements_only) const; bool usage_requirements_only) const;
/** The link implementation specifies the direct library struct LinkImplementation: public cmLinkImplementationLibraries
dependencies needed by the object files of the target. */
struct LinkImplementationLibraries
{
// Libraries linked directly in this configuration.
std::vector<cmLinkImplItem> Libraries;
// Libraries linked directly in other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
};
struct LinkImplementation: public LinkImplementationLibraries
{ {
// Languages whose runtime libraries must be linked. // Languages whose runtime libraries must be linked.
std::vector<std::string> Languages; std::vector<std::string> Languages;
@ -312,7 +278,7 @@ public:
LinkImplementation const* LinkImplementation const*
GetLinkImplementation(const std::string& config) const; GetLinkImplementation(const std::string& config) const;
LinkImplementationLibraries const* cmLinkImplementationLibraries const*
GetLinkImplementationLibraries(const std::string& config) const; GetLinkImplementationLibraries(const std::string& config) const;
cmTarget const* FindTargetToLink(std::string const& name) const; cmTarget const* FindTargetToLink(std::string const& name) const;
@ -631,7 +597,7 @@ private:
GetImportLinkInterface(const std::string& config, cmTarget const* head, GetImportLinkInterface(const std::string& config, cmTarget const* head,
bool usage_requirements_only) const; bool usage_requirements_only) const;
LinkImplementationLibraries const* cmLinkImplementationLibraries const*
GetLinkImplementationLibrariesInternal(const std::string& config, GetLinkImplementationLibrariesInternal(const std::string& config,
cmTarget const* head) const; cmTarget const* head) const;