cmTarget: Make the source files depend on the config.

Disallow the use of config-specific source files with
the Visual Studio and Xcode generators. They don't have
any way to represent the condition currently.

Use the same common-config API in cmQtAutoGenerators. While
it accepts config-specific files, it doesn't have to support
multiple configurations yet.

Loop over the configs in cmTargetTraceDependencies
and cmGlobalGenerator::WriteSummary and consume all source
files.

Loop over the configs in cmComputeTargetDepends and compute the
object library dependencies for each config.
This commit is contained in:
Stephen Kelly 2014-02-13 17:25:00 +01:00
parent df753df94b
commit e6971df6ab
44 changed files with 492 additions and 138 deletions

View File

@ -213,16 +213,25 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// deal with config-specific dependencies. // deal with config-specific dependencies.
{ {
std::set<std::string> emitted; std::set<std::string> emitted;
{
cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator() cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator()
->GetGlobalGenerator() ->GetGlobalGenerator()
->GetGeneratorTarget(depender); ->GetGeneratorTarget(depender);
std::vector<cmSourceFile const*> objectFiles;
gt->GetExternalObjects(objectFiles); std::vector<std::string> configs;
for(std::vector<cmSourceFile const*>::const_iterator depender->GetMakefile()->GetConfigurations(configs);
it = objectFiles.begin(); it != objectFiles.end(); ++it) if (configs.empty())
{ {
std::string objLib = (*it)->GetObjectLibrary(); configs.push_back("");
}
for (std::vector<std::string>::const_iterator it = configs.begin();
it != configs.end(); ++it)
{
std::vector<cmSourceFile const*> objectFiles;
gt->GetExternalObjects(objectFiles, *it);
for(std::vector<cmSourceFile const*>::const_iterator
oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
{
std::string objLib = (*oi)->GetObjectLibrary();
if (!objLib.empty() && emitted.insert(objLib).second) if (!objLib.empty() && emitted.insert(objLib).second)
{ {
if(depender->GetType() != cmTarget::EXECUTABLE && if(depender->GetType() != cmTarget::EXECUTABLE &&
@ -240,16 +249,6 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
const_cast<cmTarget*>(depender)->AddUtility(objLib); const_cast<cmTarget*>(depender)->AddUtility(objLib);
} }
} }
}
std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
for (std::vector<std::string>::const_iterator it = configs.begin();
it != configs.end(); ++it)
{
std::vector<std::string> tlibs; std::vector<std::string> tlibs;
depender->GetDirectLinkLibraries(*it, tlibs, depender); depender->GetDirectLinkLibraries(*it, tlibs, depender);

View File

@ -399,7 +399,8 @@ void cmExtraCodeBlocksGenerator
case cmTarget::UTILITY: // can have sources since 2.6.3 case cmTarget::UTILITY: // can have sources since 2.6.3
{ {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
ti->second.GetSourceFiles(sources); ti->second.GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++) si!=sources.end(); si++)
{ {

View File

@ -214,7 +214,8 @@ void cmExtraCodeLiteGenerator
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
{ {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
ti->second.GetSourceFiles(sources); ti->second.GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++) si!=sources.end(); si++)
{ {

View File

@ -560,7 +560,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
// get the files from the source lists then add them to the groups // get the files from the source lists then add them to the groups
cmTarget* tgt = const_cast<cmTarget*>(&ti->second); cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
std::vector<cmSourceFile*> files; std::vector<cmSourceFile*> files;
tgt->GetSourceFiles(files); tgt->GetSourceFiles(files,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
sfIt != files.end(); sfIt != files.end();
sfIt++) sfIt++)

View File

@ -238,7 +238,8 @@ void cmExtraSublimeTextGenerator::
cmGeneratorTarget *gtgt = this->GlobalGenerator cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target); ->GetGeneratorTarget(target);
std::vector<cmSourceFile*> sourceFiles; std::vector<cmSourceFile*> sourceFiles;
target->GetSourceFiles(sourceFiles); target->GetSourceFiles(sourceFiles,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
std::vector<cmSourceFile*>::const_iterator sourceFilesEnd = std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
sourceFiles.end(); sourceFiles.end();
for (std::vector<cmSourceFile*>::const_iterator iter = for (std::vector<cmSourceFile*>::const_iterator iter =

View File

@ -133,7 +133,7 @@ void cmFLTKWrapUICommand::FinalPass()
return; return;
} }
std::vector<cmSourceFile*> srcs; std::vector<cmSourceFile*> srcs;
target->GetSourceFiles(srcs); target->GetSourceFiles(srcs, "");
bool found = false; bool found = false;
for (unsigned int i = 0; i < srcs.size(); ++i) for (unsigned int i = 0; i < srcs.size(); ++i)
{ {

View File

@ -1272,7 +1272,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
} }
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources); gt->GetObjectSources(objectSources, context->Config);
std::map<cmSourceFile const*, std::string> mapping; std::map<cmSourceFile const*, std::string> mapping;
for(std::vector<cmSourceFile const*>::const_iterator it for(std::vector<cmSourceFile const*>::const_iterator it

View File

@ -289,7 +289,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ #define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
{ \ { \
std::vector<cmSourceFile*> sourceFiles; \ std::vector<cmSourceFile*> sourceFiles; \
this->Target->GetSourceFiles(sourceFiles); \ this->Target->GetSourceFiles(sourceFiles, config); \
TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \ TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \
for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \ for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
si != sourceFiles.end(); ++si) \ si != sourceFiles.end(); ++si) \
@ -308,7 +308,8 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget cmGeneratorTarget
::GetObjectSources(std::vector<cmSourceFile const*> &data) const ::GetObjectSources(std::vector<cmSourceFile const*> &data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(ObjectSources); IMPLEMENT_VISIT(ObjectSources);
@ -332,8 +333,19 @@ void cmGeneratorTarget::ComputeObjectMapping()
{ {
return; return;
} }
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
for(std::vector<std::string>::const_iterator ci = configs.begin();
ci != configs.end(); ++ci)
{
std::vector<cmSourceFile const*> sourceFiles; std::vector<cmSourceFile const*> sourceFiles;
this->GetObjectSources(sourceFiles); this->GetObjectSources(sourceFiles, *ci);
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -360,7 +372,8 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGeneratorTarget void cmGeneratorTarget
::GetIDLSources(std::vector<cmSourceFile const*>& data) const ::GetIDLSources(std::vector<cmSourceFile const*>& data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(IDLSources); IMPLEMENT_VISIT(IDLSources);
} }
@ -368,14 +381,16 @@ void cmGeneratorTarget
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget cmGeneratorTarget
::GetHeaderSources(std::vector<cmSourceFile const*>& data) const ::GetHeaderSources(std::vector<cmSourceFile const*>& data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(HeaderSources); IMPLEMENT_VISIT(HeaderSources);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGeneratorTarget void cmGeneratorTarget
::GetExtraSources(std::vector<cmSourceFile const*>& data) const ::GetExtraSources(std::vector<cmSourceFile const*>& data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(ExtraSources); IMPLEMENT_VISIT(ExtraSources);
} }
@ -383,7 +398,8 @@ void cmGeneratorTarget
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget cmGeneratorTarget
::GetCustomCommands(std::vector<cmSourceFile const*>& data) const ::GetCustomCommands(std::vector<cmSourceFile const*>& data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(CustomCommands); IMPLEMENT_VISIT(CustomCommands);
} }
@ -391,14 +407,16 @@ cmGeneratorTarget
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget cmGeneratorTarget
::GetExternalObjects(std::vector<cmSourceFile const*>& data) const ::GetExternalObjects(std::vector<cmSourceFile const*>& data,
const std::string& config) const
{ {
IMPLEMENT_VISIT(ExternalObjects); IMPLEMENT_VISIT(ExternalObjects);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
const std::string& config) const
{ {
ResxData data; ResxData data;
IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
@ -407,7 +425,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGeneratorTarget void cmGeneratorTarget
::GetResxSources(std::vector<cmSourceFile const*>& srcs) const ::GetResxSources(std::vector<cmSourceFile const*>& srcs,
const std::string& config) const
{ {
ResxData data; ResxData data;
IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
@ -517,13 +536,15 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const
{ {
this->Target->GetSourceFiles(files); this->Target->GetSourceFiles(files, config);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetModuleDefinitionFile() const std::string
cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const
{ {
std::string data; std::string data;
IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string) IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string)
@ -532,10 +553,11 @@ std::string cmGeneratorTarget::GetModuleDefinitionFile() const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
const std::string &config) const
{ {
std::vector<cmSourceFile const*> objectFiles; std::vector<cmSourceFile const*> objectFiles;
this->GetExternalObjects(objectFiles); this->GetExternalObjects(objectFiles, config);
std::vector<cmTarget*> objectLibraries; std::vector<cmTarget*> objectLibraries;
std::set<cmTarget*> emitted; std::set<cmTarget*> emitted;
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
@ -559,7 +581,7 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
cmGeneratorTarget* ogt = cmGeneratorTarget* ogt =
this->GlobalGenerator->GetGeneratorTarget(objLib); this->GlobalGenerator->GetGeneratorTarget(objLib);
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
ogt->GetObjectSources(objectSources); ogt->GetObjectSources(objectSources, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si = objectSources.begin();
si != objectSources.end(); ++si) si != objectSources.end(); ++si)
@ -615,11 +637,22 @@ cmTargetTraceDependencies
if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
{ {
std::vector<std::string> sources; std::vector<std::string> sources;
this->Target->GetSourceFiles(sources); std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
for(std::vector<std::string>::const_iterator ci = configs.begin();
ci != configs.end(); ++ci)
{
this->Target->GetSourceFiles(sources, *ci);
}
std::set<std::string> emitted;
for(std::vector<std::string>::const_iterator si = sources.begin(); for(std::vector<std::string>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {
if(this->SourcesQueued.insert(*si).second) if(emitted.insert(*si).second && this->SourcesQueued.insert(*si).second)
{ {
this->SourceQueue.push(*si); this->SourceQueue.push(*si);
this->Makefile->GetOrCreateSource(*si); this->Makefile->GetOrCreateSource(*si);

View File

@ -30,21 +30,30 @@ public:
std::string GetName() const; std::string GetName() const;
const char *GetProperty(const std::string& prop) const; const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files) const; void GetSourceFiles(std::vector<cmSourceFile*>& files,
const std::string& config) const;
void GetObjectSources(std::vector<cmSourceFile const*> &) const; void GetObjectSources(std::vector<cmSourceFile const*> &,
const std::string& config) const;
const std::string& GetObjectName(cmSourceFile const* file); const std::string& GetObjectName(cmSourceFile const* file);
bool HasExplicitObjectName(cmSourceFile const* file) const; bool HasExplicitObjectName(cmSourceFile const* file) const;
void AddExplicitObjectName(cmSourceFile const* sf); void AddExplicitObjectName(cmSourceFile const* sf);
void GetResxSources(std::vector<cmSourceFile const*>&) const; void GetResxSources(std::vector<cmSourceFile const*>&,
void GetIDLSources(std::vector<cmSourceFile const*>&) const; const std::string& config) const;
void GetExternalObjects(std::vector<cmSourceFile const*>&) const; void GetIDLSources(std::vector<cmSourceFile const*>&,
void GetHeaderSources(std::vector<cmSourceFile const*>&) const; const std::string& config) const;
void GetExtraSources(std::vector<cmSourceFile const*>&) const; void GetExternalObjects(std::vector<cmSourceFile const*>&,
void GetCustomCommands(std::vector<cmSourceFile const*>&) const; const std::string& config) const;
void GetExpectedResxHeaders(std::set<std::string>&) const; void GetHeaderSources(std::vector<cmSourceFile const*>&,
const std::string& config) const;
void GetExtraSources(std::vector<cmSourceFile const*>&,
const std::string& config) const;
void GetCustomCommands(std::vector<cmSourceFile const*>&,
const std::string& config) const;
void GetExpectedResxHeaders(std::set<std::string>&,
const std::string& config) const;
void ComputeObjectMapping(); void ComputeObjectMapping();
@ -53,14 +62,15 @@ public:
cmLocalGenerator* LocalGenerator; cmLocalGenerator* LocalGenerator;
cmGlobalGenerator const* GlobalGenerator; cmGlobalGenerator const* GlobalGenerator;
std::string GetModuleDefinitionFile() const; std::string GetModuleDefinitionFile(const std::string& config) const;
/** Full path with trailing slash to the top-level directory /** Full path with trailing slash to the top-level directory
holding object files for this target. Includes the build holding object files for this target. Includes the build
time config name placeholder if needed for the generator. */ time config name placeholder if needed for the generator. */
std::string ObjectDirectory; std::string ObjectDirectory;
void UseObjectLibraries(std::vector<std::string>& objs) const; void UseObjectLibraries(std::vector<std::string>& objs,
const std::string& config) const;
void GetAppleArchs(const std::string& config, void GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const; std::vector<std::string>& archVec) const;

View File

@ -2900,10 +2900,25 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
// List the source files with any per-source labels. // List the source files with any per-source labels.
fout << "# Source files and their labels\n"; fout << "# Source files and their labels\n";
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources); std::vector<std::string> configs;
target->GetMakefile()->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
for(std::vector<std::string>::const_iterator ci = configs.begin();
ci != configs.end(); ++ci)
{
target->GetSourceFiles(sources, *ci);
}
std::set<cmSourceFile*> emitted;
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {
if (!emitted.insert(*si).second)
{
continue;
}
cmSourceFile* sf = *si; cmSourceFile* sf = *si;
fout << sf->GetFullPath() << "\n"; fout << sf->GetFullPath() << "\n";
if(const char* svalue = sf->GetProperty("LABELS")) if(const char* svalue = sf->GetProperty("LABELS"))

View File

@ -139,7 +139,8 @@ bool cmGlobalKdevelopGenerator
ti != targets.end(); ti++) ti != targets.end(); ti++)
{ {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
ti->second.GetSourceFiles(sources); ti->second.GetSourceFiles(sources, ti->second.GetMakefile()
->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++) si!=sources.end(); si++)
{ {

View File

@ -1081,7 +1081,8 @@ bool cmGlobalUnixMakefileGenerator3
::NeedRequiresStep(cmTarget const& target) ::NeedRequiresStep(cmTarget const& target)
{ {
std::set<std::string> languages; std::set<std::string> languages;
target.GetLanguages(languages); target.GetLanguages(languages,
target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::set<std::string>::const_iterator l = languages.begin(); for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l) l != languages.end(); ++l)
{ {

View File

@ -815,7 +815,15 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{ {
// check to see if this is a fortran build // check to see if this is a fortran build
std::set<std::string> languages; std::set<std::string> languages;
target.GetLanguages(languages); {
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
if (!target.GetConfigCommonSourceFiles(sources))
{
return false;
}
}
target.GetLanguages(languages, "");
if(languages.size() == 1) if(languages.size() == 1)
{ {
if(*languages.begin() == "Fortran") if(*languages.begin() == "Fortran")

View File

@ -984,7 +984,10 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// organize the sources // organize the sources
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes); if (!cmtarget.GetConfigCommonSourceFiles(classes))
{
return;
}
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
gtgt->ComputeObjectMapping(); gtgt->ComputeObjectMapping();
@ -1043,7 +1046,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// the externalObjFiles above, except each one is not a cmSourceFile // the externalObjFiles above, except each one is not a cmSourceFile
// within the target.) // within the target.)
std::vector<std::string> objs; std::vector<std::string> objs;
gtgt->UseObjectLibraries(objs); gtgt->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
{ {
@ -1359,7 +1362,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
} }
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes); if (!cmtarget.GetConfigCommonSourceFiles(classes))
{
return;
}
// add all the sources // add all the sources
std::vector<cmCustomCommand> commands; std::vector<cmCustomCommand> commands;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@ -2439,7 +2445,11 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
if(cmtarget.GetType() == cmTarget::UTILITY) if(cmtarget.GetType() == cmTarget::UTILITY)
{ {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
cmtarget.GetSourceFiles(sources); if (!cmtarget.GetConfigCommonSourceFiles(sources))
{
return 0;
}
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
@ -2808,7 +2818,7 @@ void cmGlobalXCodeGenerator
std::string linkObjs; std::string linkObjs;
const char* sep = ""; const char* sep = "";
std::vector<std::string> objs; std::vector<std::string> objs;
this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs); this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
{ {
@ -2943,8 +2953,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
} }
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes); if (!cmtarget.GetConfigCommonSourceFiles(classes))
{
return;
}
// Put cmSourceFile instances in proper groups: // Put cmSourceFile instances in proper groups:
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
s != classes.end(); s++) s != classes.end(); s++)
@ -2962,7 +2974,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
// Put OBJECT_LIBRARY objects in proper groups: // Put OBJECT_LIBRARY objects in proper groups:
std::vector<std::string> objs; std::vector<std::string> objs;
this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
{ {

View File

@ -662,7 +662,8 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
std::vector<std::string> objVector; std::vector<std::string> objVector;
// Add all the sources outputs to the depends of the target // Add all the sources outputs to the depends of the target
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes); target.GetSourceFiles(classes,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
@ -1644,7 +1645,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{ {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources); target->GetSourceFiles(sources, buildType);
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
@ -1692,7 +1693,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += this->Makefile->GetSafeDefinition(build);
linkFlags += " "; linkFlags += " ";
} }
std::string linkLanguage = target->Target->GetLinkerLanguage(); std::string linkLanguage = target->Target->GetLinkerLanguage(buildType);
if(linkLanguage.empty()) if(linkLanguage.empty())
{ {
cmSystemTools::Error cmSystemTools::Error

View File

@ -200,7 +200,8 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
continue; continue;
} }
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources); gt->GetObjectSources(objectSources, this->Makefile
->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// Compute full path to object file directory for this target. // Compute full path to object file directory for this target.
std::string dir; std::string dir;
dir += gt->Makefile->GetCurrentOutputDirectory(); dir += gt->Makefile->GetCurrentOutputDirectory();
@ -1262,7 +1263,8 @@ cmLocalUnixMakefileGenerator3
{ {
// Get the set of source languages in the target. // Get the set of source languages in the target.
std::set<std::string> languages; std::set<std::string> languages;
target.GetLanguages(languages); target.GetLanguages(languages,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
fout << "\n" fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n" << "# Per-language clean rules from dependency scanning.\n"
<< "foreach(lang"; << "foreach(lang";

View File

@ -317,7 +317,10 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes); if (!target.GetConfigCommonSourceFiles(classes))
{
return;
}
// now all of the source files have been properly assigned to the target // now all of the source files have been properly assigned to the target
// now stick them into source groups using the reg expressions // now stick them into source groups using the reg expressions
@ -1269,7 +1272,20 @@ void cmLocalVisualStudio6Generator
if(targetBuilds) if(targetBuilds)
{ {
// Get the language to use for linking. // Get the language to use for linking.
const std::string& linkLanguage = target.GetLinkerLanguage(); std::vector<std::string> configs;
target.GetMakefile()->GetConfigurations(configs);
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& linkLanguage = target.GetLinkerLanguage(*it);
for ( ; it != configs.end(); ++it)
{
const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
if (configLinkLanguage != linkLanguage)
{
cmSystemTools::Error
("Linker language must not vary by configuration for target: ",
target.GetName().c_str());
}
}
if(linkLanguage.empty()) if(linkLanguage.empty())
{ {
cmSystemTools::Error cmSystemTools::Error
@ -1691,7 +1707,20 @@ void cmLocalVisualStudio6Generator
if(target.GetType() >= cmTarget::EXECUTABLE && if(target.GetType() >= cmTarget::EXECUTABLE &&
target.GetType() <= cmTarget::OBJECT_LIBRARY) target.GetType() <= cmTarget::OBJECT_LIBRARY)
{ {
const std::string& linkLanguage = target.GetLinkerLanguage(); std::vector<std::string> configs;
target.GetMakefile()->GetConfigurations(configs);
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& linkLanguage = target.GetLinkerLanguage(*it);
for ( ; it != configs.end(); ++it)
{
const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
if (configLinkLanguage != linkLanguage)
{
cmSystemTools::Error
("Linker language must not vary by configuration for target: ",
target.GetName().c_str());
}
}
if(linkLanguage.empty()) if(linkLanguage.empty())
{ {
cmSystemTools::Error cmSystemTools::Error
@ -1889,7 +1918,7 @@ void cmLocalVisualStudio6Generator
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target); this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs; std::vector<std::string> objs;
gt->UseObjectLibraries(objs); gt->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
{ {

View File

@ -1330,7 +1330,7 @@ cmLocalVisualStudio7GeneratorInternals
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
lg->GetGlobalGenerator()->GetGeneratorTarget(t); lg->GetGlobalGenerator()->GetGeneratorTarget(t);
std::vector<std::string> objs; std::vector<std::string> objs;
gt->UseObjectLibraries(objs); gt->UseObjectLibraries(objs, "");
const char* sep = isep? isep : ""; const char* sep = isep? isep : "";
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
@ -1397,7 +1397,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
this->ModuleDefinitionFile = ""; this->ModuleDefinitionFile = "";
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes); if (!target.GetConfigCommonSourceFiles(classes))
{
return;
}
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
@ -1438,7 +1441,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target); this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs; std::vector<std::string> objs;
gt->UseObjectLibraries(objs); gt->UseObjectLibraries(objs, "");
if(!objs.empty()) if(!objs.empty())
{ {
// TODO: Separate sub-filter for each object library used? // TODO: Separate sub-filter for each object library used?

View File

@ -128,14 +128,15 @@ void cmMakefileTargetGenerator::CreateRuleFile()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetBuildRules() void cmMakefileTargetGenerator::WriteTargetBuildRules()
{ {
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
// write the custom commands for this target // write the custom commands for this target
// Look for files registered for cleaning in this directory. // Look for files registered for cleaning in this directory.
if(const char* additional_clean_files = if(const char* additional_clean_files =
this->Makefile->GetProperty this->Makefile->GetProperty
("ADDITIONAL_MAKE_CLEAN_FILES")) ("ADDITIONAL_MAKE_CLEAN_FILES"))
{ {
const std::string& config =
this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmListFileBacktrace lfbt; cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt); cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
@ -154,7 +155,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object // First generate the object rule files. Save a list of all object
// files for this target. // files for this target.
std::vector<cmSourceFile const*> customCommands; std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands); this->GeneratorTarget->GetCustomCommands(customCommands, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin(); si = customCommands.begin();
si != customCommands.end(); ++si) si != customCommands.end(); ++si)
@ -177,17 +178,17 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
} }
} }
std::vector<cmSourceFile const*> headerSources; std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources); this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements( this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, headerSources,
this->MacOSXContentGenerator); this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> extraSources; std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources); this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements( this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, extraSources,
this->MacOSXContentGenerator); this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> externalObjects; std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects); this->GeneratorTarget->GetExternalObjects(externalObjects, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin(); si = externalObjects.begin();
si != externalObjects.end(); ++si) si != externalObjects.end(); ++si)
@ -195,7 +196,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
this->ExternalObjects.push_back((*si)->GetFullPath()); this->ExternalObjects.push_back((*si)->GetFullPath());
} }
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources); this->GeneratorTarget->GetObjectSources(objectSources, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si) si = objectSources.begin(); si != objectSources.end(); ++si)
{ {
@ -344,7 +345,8 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{ {
// write language flags for target // write language flags for target
std::set<std::string> languages; std::set<std::string> languages;
this->Target->GetLanguages(languages); this->Target->GetLanguages(languages,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes // put the compiler in the rules.make file so that if it changes
// things rebuild // things rebuild
for(std::set<std::string>::const_iterator l = languages.begin(); for(std::set<std::string>::const_iterator l = languages.begin();
@ -1173,7 +1175,8 @@ cmMakefileTargetGenerator
{ {
// Depend on all custom command outputs. // Depend on all custom command outputs.
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
this->Target->GetSourceFiles(sources); this->Target->GetSourceFiles(sources,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {
@ -1670,7 +1673,8 @@ void cmMakefileTargetGenerator
this->AppendTargetDepends(depends); this->AppendTargetDepends(depends);
// Add a dependency on the link definitions file, if any. // Add a dependency on the link definitions file, if any.
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
if(!def.empty()) if(!def.empty())
{ {
depends.push_back(def); depends.push_back(def);
@ -2064,7 +2068,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
{ {
std::vector<std::string> includes; std::vector<std::string> includes;
const std::string& config = const std::string& config =
this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes, this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget, this->GeneratorTarget,
"C", config); "C", config);
@ -2083,7 +2087,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{ {
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
if(def.empty()) if(def.empty())
{ {
return; return;

View File

@ -111,7 +111,8 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
#endif #endif
std::set<std::string> languages; std::set<std::string> languages;
this->GetTarget()->GetLanguages(languages); this->GetTarget()->GetLanguages(languages,
this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::set<std::string>::const_iterator l = languages.begin(); for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); l != languages.end();
++l) ++l)

View File

@ -485,8 +485,9 @@ cmNinjaTargetGenerator
<< this->GetTargetName() << this->GetTargetName()
<< "\n\n"; << "\n\n";
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
std::vector<cmSourceFile const*> customCommands; std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands); this->GeneratorTarget->GetCustomCommands(customCommands, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin(); si = customCommands.begin();
si != customCommands.end(); ++si) si != customCommands.end(); ++si)
@ -495,17 +496,17 @@ cmNinjaTargetGenerator
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
} }
std::vector<cmSourceFile const*> headerSources; std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources); this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements( this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, headerSources,
this->MacOSXContentGenerator); this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> extraSources; std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources); this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements( this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, extraSources,
this->MacOSXContentGenerator); this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> externalObjects; std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects); this->GeneratorTarget->GetExternalObjects(externalObjects, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin(); si = externalObjects.begin();
si != externalObjects.end(); ++si) si != externalObjects.end(); ++si)
@ -513,13 +514,13 @@ cmNinjaTargetGenerator
this->Objects.push_back(this->GetSourceFilePath(*si)); this->Objects.push_back(this->GetSourceFilePath(*si));
} }
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources); this->GeneratorTarget->GetObjectSources(objectSources, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si) si = objectSources.begin(); si != objectSources.end(); ++si)
{ {
this->WriteObjectBuildStatement(*si); this->WriteObjectBuildStatement(*si);
} }
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
if(!def.empty()) if(!def.empty())
{ {
this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
@ -565,7 +566,8 @@ cmNinjaTargetGenerator
// Add order-only dependencies on custom command outputs. // Add order-only dependencies on custom command outputs.
std::vector<cmSourceFile const*> customCommands; std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands); std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GeneratorTarget->GetCustomCommands(customCommands, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin(); si = customCommands.begin();
si != customCommands.end(); ++si) si != customCommands.end(); ++si)

View File

@ -46,7 +46,9 @@ void cmNinjaUtilityTargetGenerator::Generate()
} }
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
this->GetTarget()->GetSourceFiles(sources); std::string config = this->GetMakefile()
->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GetTarget()->GetSourceFiles(sources, config);
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {

View File

@ -472,7 +472,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
const char* sepHeaders = ""; const char* sepHeaders = "";
std::vector<cmSourceFile*> srcFiles; std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles); target->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = ""; const char *skipMocSep = "";
const char *skipUicSep = ""; const char *skipUicSep = "";
@ -862,7 +862,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmMakefile *makefile = target->GetMakefile(); cmMakefile *makefile = target->GetMakefile();
std::vector<cmSourceFile*> srcFiles; std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles); target->GetConfigCommonSourceFiles(srcFiles);
std::string rccFileFiles; std::string rccFileFiles;
std::string rccFileOptions; std::string rccFileOptions;

View File

@ -543,7 +543,8 @@ bool cmTarget::IsBundleOnApple() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<std::string> &files) const void cmTarget::GetSourceFiles(std::vector<std::string> &files,
const std::string& config) const
{ {
assert(this->GetType() != INTERFACE_LIBRARY); assert(this->GetType() != INTERFACE_LIBRARY);
for(std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator for(std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
@ -552,7 +553,7 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files) const
{ {
std::vector<std::string> srcs; std::vector<std::string> srcs;
cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile,
"", config,
false, false,
this), this),
srcs); srcs);
@ -580,10 +581,68 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const bool
cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
{
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& firstConfig = *it;
this->GetSourceFiles(files, firstConfig);
for ( ; it != configs.end(); ++it)
{
std::vector<cmSourceFile*> configFiles;
this->GetSourceFiles(configFiles, *it);
if (configFiles != files)
{
std::string firstConfigFiles;
const char* sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
{
firstConfigFiles += sep;
firstConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
fi != configFiles.end(); ++fi)
{
thisConfigFiles += sep;
thisConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
cmOStringStream e;
e << "Target \"" << this->Name << "\" has source files which vary by "
"configuration. This is not supported by the \""
<< this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GetName()
<< "\" generator.\n"
"Config \"" << firstConfig << "\":\n"
" " << firstConfigFiles << "\n"
"Config \"" << *it << "\":\n"
" " << thisConfigFiles << "\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const
{ {
std::vector<std::string> srcs; std::vector<std::string> srcs;
this->GetSourceFiles(srcs); this->GetSourceFiles(srcs, config);
std::set<cmSourceFile*> emitted; std::set<cmSourceFile*> emitted;
@ -4993,10 +5052,11 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::GetLanguages(std::set<std::string>& languages) const void cmTarget::GetLanguages(std::set<std::string>& languages,
const std::string& config) const
{ {
std::vector<cmSourceFile*> sourceFiles; std::vector<cmSourceFile*> sourceFiles;
this->GetSourceFiles(sourceFiles); this->GetSourceFiles(sourceFiles, config);
for(std::vector<cmSourceFile*>::const_iterator for(std::vector<cmSourceFile*>::const_iterator
i = sourceFiles.begin(); i != sourceFiles.end(); ++i) i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
{ {
@ -5037,7 +5097,7 @@ void cmTarget::GetLanguages(std::set<std::string>& languages) const
cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator() cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator() ->GetGlobalGenerator()
->GetGeneratorTarget(this); ->GetGeneratorTarget(this);
gt->GetExternalObjects(externalObjects); gt->GetExternalObjects(externalObjects, config);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
i = externalObjects.begin(); i != externalObjects.end(); ++i) i = externalObjects.begin(); i != externalObjects.end(); ++i)
{ {
@ -5051,7 +5111,7 @@ void cmTarget::GetLanguages(std::set<std::string>& languages) const
for(std::vector<cmTarget*>::const_iterator for(std::vector<cmTarget*>::const_iterator
i = objectLibraries.begin(); i != objectLibraries.end(); ++i) i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
{ {
(*i)->GetLanguages(languages); (*i)->GetLanguages(languages, config);
} }
} }
@ -5990,7 +6050,7 @@ cmTarget::GetLinkImplementation(const std::string& config,
// Compute the link implementation for this configuration. // Compute the link implementation for this configuration.
LinkImplementation impl; LinkImplementation impl;
this->ComputeLinkImplementation(config, impl, head); this->ComputeLinkImplementation(config, impl, head);
this->ComputeLinkImplementationLanguages(impl); this->ComputeLinkImplementationLanguages(config, impl);
// Store the information for this configuration. // Store the information for this configuration.
cmTargetInternals::LinkImplMapType::value_type entry(key, impl); cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
@ -5998,7 +6058,7 @@ cmTarget::GetLinkImplementation(const std::string& config,
} }
else if (i->second.Languages.empty()) else if (i->second.Languages.empty())
{ {
this->ComputeLinkImplementationLanguages(i->second); this->ComputeLinkImplementationLanguages(config, i->second);
} }
return &i->second; return &i->second;
@ -6111,12 +6171,13 @@ void cmTarget::ComputeLinkImplementation(const std::string& config,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const cmTarget::ComputeLinkImplementationLanguages(const std::string& config,
LinkImplementation& impl) const
{ {
// This target needs runtime libraries for its source languages. // This target needs runtime libraries for its source languages.
std::set<std::string> languages; std::set<std::string> languages;
// Get languages used in our source files. // Get languages used in our source files.
this->GetLanguages(languages); this->GetLanguages(languages, config);
// Copy the set of langauges to the link implementation. // Copy the set of langauges to the link implementation.
for(std::set<std::string>::iterator li = languages.begin(); for(std::set<std::string>::iterator li = languages.begin();
li != languages.end(); ++li) li != languages.end(); ++li)

View File

@ -135,8 +135,11 @@ public:
/** /**
* Get the list of the source files used by this target * Get the list of the source files used by this target
*/ */
void GetSourceFiles(std::vector<std::string> &files) const; void GetSourceFiles(std::vector<std::string> &files,
void GetSourceFiles(std::vector<cmSourceFile*> &files) const; const std::string& config) const;
void GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const;
bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
/** /**
* Add sources to the target. * Add sources to the target.
@ -465,7 +468,8 @@ public:
// when source file properties are changed and we do not have enough // when source file properties are changed and we do not have enough
// information to forward these property changes to the targets // information to forward these property changes to the targets
// until we have per-target object file properties. // until we have per-target object file properties.
void GetLanguages(std::set<std::string>& languages) const; void GetLanguages(std::set<std::string>& languages,
const std::string& config) const;
/** Return whether this target is an executable with symbol exports /** Return whether this target is an executable with symbol exports
enabled. */ enabled. */
@ -738,7 +742,8 @@ private:
void ComputeLinkImplementation(const std::string& config, void ComputeLinkImplementation(const std::string& config,
LinkImplementation& impl, LinkImplementation& impl,
cmTarget const* head) const; cmTarget const* head) const;
void ComputeLinkImplementationLanguages(LinkImplementation& impl) const; void ComputeLinkImplementationLanguages(const std::string& config,
LinkImplementation& impl) const;
void ComputeLinkClosure(const std::string& config, LinkClosure& lc, void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
cmTarget const* head) const; cmTarget const* head) const;

View File

@ -379,7 +379,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
{ {
std::vector<cmSourceFile const*> resxObjs; std::vector<cmSourceFile const*> resxObjs;
this->GeneratorTarget->GetResxSources(resxObjs); this->GeneratorTarget->GetResxSources(resxObjs, "");
if(!resxObjs.empty()) if(!resxObjs.empty())
{ {
this->WriteString("<ItemGroup>\n", 1); this->WriteString("<ItemGroup>\n", 1);
@ -553,7 +553,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{ {
this->SourcesVisited.clear(); this->SourcesVisited.clear();
std::vector<cmSourceFile const*> customCommands; std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands); this->GeneratorTarget->GetCustomCommands(customCommands, "");
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin(); si = customCommands.begin();
si != customCommands.end(); ++si) si != customCommands.end(); ++si)
@ -704,7 +704,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::vector<cmSourceGroup> sourceGroups = std::vector<cmSourceGroup> sourceGroups =
this->Makefile->GetSourceGroups(); this->Makefile->GetSourceGroups();
std::vector<cmSourceFile*> classes; std::vector<cmSourceFile*> classes;
this->Target->GetSourceFiles(classes); if (!this->Target->GetConfigCommonSourceFiles(classes))
{
return;
}
std::set<cmSourceGroup*> groupsUsed; std::set<cmSourceGroup*> groupsUsed;
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
@ -749,7 +752,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
} }
std::vector<cmSourceFile const*> resxObjs; std::vector<cmSourceFile const*> resxObjs;
this->GeneratorTarget->GetResxSources(resxObjs); this->GeneratorTarget->GetResxSources(resxObjs, "");
if(!resxObjs.empty()) if(!resxObjs.empty())
{ {
this->WriteString("<ItemGroup>\n", 1); this->WriteString("<ItemGroup>\n", 1);
@ -768,7 +771,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// Add object library contents as external objects. // Add object library contents as external objects.
std::vector<std::string> objs; std::vector<std::string> objs;
this->GeneratorTarget->UseObjectLibraries(objs); this->GeneratorTarget->UseObjectLibraries(objs, "");
if(!objs.empty()) if(!objs.empty())
{ {
this->WriteString("<ItemGroup>\n", 1); this->WriteString("<ItemGroup>\n", 1);
@ -1005,14 +1008,14 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
this->WriteString("<ItemGroup>\n", 1); this->WriteString("<ItemGroup>\n", 1);
std::vector<cmSourceFile const*> headerSources; std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources); this->GeneratorTarget->GetHeaderSources(headerSources, "");
this->WriteSources("ClInclude", headerSources); this->WriteSources("ClInclude", headerSources);
std::vector<cmSourceFile const*> idlSources; std::vector<cmSourceFile const*> idlSources;
this->GeneratorTarget->GetIDLSources(idlSources); this->GeneratorTarget->GetIDLSources(idlSources, "");
this->WriteSources("Midl", idlSources); this->WriteSources("Midl", idlSources);
std::vector<cmSourceFile const*> objectSources; std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources); this->GeneratorTarget->GetObjectSources(objectSources, "");
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si = objectSources.begin();
si != objectSources.end(); ++si) si != objectSources.end(); ++si)
@ -1053,7 +1056,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
} }
std::vector<cmSourceFile const*> externalObjects; std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects); this->GeneratorTarget->GetExternalObjects(externalObjects, "");
for(std::vector<cmSourceFile const*>::iterator for(std::vector<cmSourceFile const*>::iterator
si = externalObjects.begin(); si = externalObjects.begin();
si != externalObjects.end(); ) si != externalObjects.end(); )
@ -1088,12 +1091,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
} }
std::vector<cmSourceFile const*> extraSources; std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources); this->GeneratorTarget->GetExtraSources(extraSources, "");
this->WriteSources("None", extraSources); this->WriteSources("None", extraSources);
// Add object library contents as external objects. // Add object library contents as external objects.
std::vector<std::string> objs; std::vector<std::string> objs;
this->GeneratorTarget->UseObjectLibraries(objs); this->GeneratorTarget->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi) oi = objs.begin(); oi != objs.end(); ++oi)
{ {
@ -1694,7 +1697,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ImportLibrary", imLib.c_str());
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
linkOptions.Parse(flags.c_str()); linkOptions.Parse(flags.c_str());
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
if(!def.empty()) if(!def.empty())
{ {
linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
@ -1924,7 +1927,7 @@ bool cmVisualStudio10TargetGenerator::
IsResxHeader(const std::string& headerFile) IsResxHeader(const std::string& headerFile)
{ {
std::set<std::string> expectedResxHeaders; std::set<std::string> expectedResxHeaders;
this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders); this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
std::set<std::string>::const_iterator it = std::set<std::string>::const_iterator it =
expectedResxHeaders.find(headerFile); expectedResxHeaders.find(headerFile);

View File

@ -278,6 +278,10 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(AliasTarget AliasTarget) ADD_TEST_MACRO(AliasTarget AliasTarget)
ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(StagingPrefix StagingPrefix)
ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
ADD_TEST_MACRO(ConfigSources ConfigSources)
endif()
set_tests_properties(EmptyLibrary PROPERTIES set_tests_properties(EmptyLibrary PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
ADD_TEST_MACRO(CrossCompile CrossCompile) ADD_TEST_MACRO(CrossCompile CrossCompile)

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.0)
project(ConfigSources)
add_executable(ConfigSources
$<$<CONFIG:Debug>:main.cpp>
$<$<CONFIG:Release>:does_not_exist.cpp>
)

View File

@ -0,0 +1,5 @@
int main(int argc, char** argv)
{
return 0;
}

View File

@ -64,9 +64,15 @@ add_custom_command(
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
) )
message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" AND NOT CMAKE_CONFIGURATION_TYPES)
set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>)
add_definitions(-DTEST_DEBUG_CLASS)
endif()
add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
test.qrc second_resource.qrc resourcetester.cpp generated.cpp test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs}
) )
set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")

View File

@ -0,0 +1,9 @@
#include "debug_class.h"
#include "ui_debug_class.h"
DebugClass::DebugClass(QWidget *parent)
: QWidget(parent), ui(new Ui::DebugClass)
{
ui->setupUi(this);
}

View File

@ -0,0 +1,20 @@
#include <QWidget>
namespace Ui
{
class DebugClass;
}
class DebugClass : public QWidget
{
Q_OBJECT
public:
explicit DebugClass(QWidget *parent = 0);
signals:
void someSignal();
private:
Ui::DebugClass *ui;
};

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DebugClass</class>
<widget class="QWidget" name="DebugClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>DebugClass</string>
</property>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>82</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>40</x>
<y>70</y>
<width>94</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>debug_class.ui</file>
</qresource>
</RCC>

View File

@ -51,6 +51,11 @@
#include "yaf.h" #include "yaf.h"
#include "libC.h" #include "libC.h"
#include "resourcetester.h" #include "resourcetester.h"
#ifdef TEST_DEBUG_CLASS
#include "debug_class.h"
#include <iostream>
#endif
int main(int argv, char **args) int main(int argv, char **args)
{ {
@ -81,5 +86,9 @@ int main(int argv, char **args)
QTimer::singleShot(0, &rt, SLOT(doTest())); QTimer::singleShot(0, &rt, SLOT(doTest()));
#ifdef TEST_DEBUG_CLASS
std::cout << DebugClass::staticMetaObject.className() << std::endl;
#endif
return app.exec(); return app.exec();
} }

View File

@ -18,6 +18,10 @@ void ResourceTester::doTest()
qApp->exit(EXIT_FAILURE); qApp->exit(EXIT_FAILURE);
if (!QFile::exists(":/main.cpp")) if (!QFile::exists(":/main.cpp"))
qApp->exit(EXIT_FAILURE); qApp->exit(EXIT_FAILURE);
#ifdef TEST_DEBUG_CLASS
if (!QFile::exists(":/debug_class.ui"))
qApp->exit(EXIT_FAILURE);
#endif
QTimer::singleShot(0, qApp, SLOT(quit())); QTimer::singleShot(0, qApp, SLOT(quit()));
} }

View File

@ -51,6 +51,7 @@ add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages) add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary) add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetSources)
add_RunCMake_test(find_dependency) add_RunCMake_test(find_dependency)
if(NOT WIN32) if(NOT WIN32)
add_RunCMake_test(PositionIndependentCode) add_RunCMake_test(PositionIndependentCode)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,14 @@
CMake Error in CMakeLists.txt:
Target "somelib" has source files which vary by configuration. This is not
supported by the "[^"]+" generator.
Config "Debug":
.*/Tests/RunCMake/TargetSources/empty_1.cpp
.*/Tests/RunCMake/TargetSources/empty_2.cpp
.*/Tests/RunCMake/TargetSources/CMakeLists.txt
Config "Release":
.*/Tests/RunCMake/TargetSources/empty_1.cpp
.*/Tests/RunCMake/TargetSources/CMakeLists.txt

View File

@ -0,0 +1,2 @@
add_library(somelib empty_1.cpp $<$<CONFIG:Debug>:empty_2.cpp>)

View File

@ -0,0 +1,6 @@
include(RunCMake)
if(RunCMake_GENERATOR MATCHES Xcode
OR RunCMake_GENERATOR MATCHES "Visual Studio")
run_cmake(ConfigNotAllowed)
endif()

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
int empty()
{
return 0;
}

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
int empty()
{
return 0;
}