ENH: Added global TargetManifest computation between Configure and Generate steps. This allows generators to know what other targets will exist on disk when the build completes.
This commit is contained in:
parent
cddedaa7d8
commit
2301a025ea
|
@ -701,8 +701,6 @@ void cmGlobalGenerator::Generate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate project files
|
|
||||||
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
{
|
{
|
||||||
cmTargets* targets = &(this->LocalGenerators[i]->GetMakefile()->GetTargets());
|
cmTargets* targets = &(this->LocalGenerators[i]->GetMakefile()->GetTargets());
|
||||||
|
@ -711,6 +709,17 @@ void cmGlobalGenerator::Generate()
|
||||||
{
|
{
|
||||||
(*targets)[tit->first] = tit->second;
|
(*targets)[tit->first] = tit->second;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the manifest of main targets generated.
|
||||||
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
|
{
|
||||||
|
this->LocalGenerators[i]->GenerateTargetManifest(this->TargetManifest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate project files
|
||||||
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
|
{
|
||||||
this->LocalGenerators[i]->Generate();
|
this->LocalGenerators[i]->Generate();
|
||||||
this->LocalGenerators[i]->GenerateInstallRules();
|
this->LocalGenerators[i]->GenerateInstallRules();
|
||||||
this->LocalGenerators[i]->GenerateTestFiles();
|
this->LocalGenerators[i]->GenerateTestFiles();
|
||||||
|
|
|
@ -171,6 +171,10 @@ public:
|
||||||
const char* suffix,
|
const char* suffix,
|
||||||
std::string& dir);
|
std::string& dir);
|
||||||
|
|
||||||
|
/** Get the manifest of all targets that will be built for each
|
||||||
|
configuration. This is valid during generation only. */
|
||||||
|
cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Fill the ProjectMap, this must be called after LocalGenerators
|
// Fill the ProjectMap, this must be called after LocalGenerators
|
||||||
// has been populated.
|
// has been populated.
|
||||||
|
@ -205,6 +209,10 @@ protected:
|
||||||
// Set of named installation components requested by the project.
|
// Set of named installation components requested by the project.
|
||||||
std::set<cmStdString> InstallComponents;
|
std::set<cmStdString> InstallComponents;
|
||||||
|
|
||||||
|
// Manifest of all targets that will be built for each configuration.
|
||||||
|
// This is computed just before local generators generate.
|
||||||
|
cmTargetManifest TargetManifest;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// If you add a new map here, make sure it is copied
|
// If you add a new map here, make sure it is copied
|
||||||
// in EnableLanguagesFromGenerator
|
// in EnableLanguagesFromGenerator
|
||||||
|
|
|
@ -391,6 +391,63 @@ void cmLocalGenerator::GenerateInstallRules()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::GenerateTargetManifest(cmTargetManifest& manifest)
|
||||||
|
{
|
||||||
|
// Collect the set of configuration types.
|
||||||
|
std::vector<std::string> configNames;
|
||||||
|
if(const char* configurationTypes =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
|
||||||
|
{
|
||||||
|
cmSystemTools::ExpandListArgument(configurationTypes, configNames);
|
||||||
|
}
|
||||||
|
else if(const char* buildType =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
|
||||||
|
{
|
||||||
|
if(*buildType)
|
||||||
|
{
|
||||||
|
configNames.push_back(buildType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add our targets to the manifest for each configuration.
|
||||||
|
cmTargets& targets = this->Makefile->GetTargets();
|
||||||
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
||||||
|
{
|
||||||
|
cmTarget& target = t->second;
|
||||||
|
cmTarget::TargetType type = target.GetType();
|
||||||
|
if(type == cmTarget::STATIC_LIBRARY ||
|
||||||
|
type == cmTarget::SHARED_LIBRARY ||
|
||||||
|
type == cmTarget::MODULE_LIBRARY ||
|
||||||
|
type == cmTarget::EXECUTABLE)
|
||||||
|
{
|
||||||
|
if(configNames.empty())
|
||||||
|
{
|
||||||
|
manifest[""].insert(target.GetFullPath(0, false));
|
||||||
|
if(type == cmTarget::SHARED_LIBRARY &&
|
||||||
|
this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
|
||||||
|
{
|
||||||
|
manifest[""].insert(target.GetFullPath(0, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(std::vector<std::string>::iterator ci = configNames.begin();
|
||||||
|
ci != configNames.end(); ++ci)
|
||||||
|
{
|
||||||
|
const char* config = ci->c_str();
|
||||||
|
manifest[config].insert(target.GetFullPath(config, false));
|
||||||
|
if(type == cmTarget::SHARED_LIBRARY &&
|
||||||
|
this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
|
||||||
|
{
|
||||||
|
manifest[config].insert(target.GetFullPath(config, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
||||||
const char* lang,
|
const char* lang,
|
||||||
cmSourceFile& source,
|
cmSourceFile& source,
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
class cmGlobalGenerator;
|
class cmGlobalGenerator;
|
||||||
class cmTarget;
|
class cmTarget;
|
||||||
|
class cmTargetManifest;
|
||||||
class cmSourceFile;
|
class cmSourceFile;
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +65,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void GenerateTestFiles();
|
virtual void GenerateTestFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a manifest of target files that will be built.
|
||||||
|
*/
|
||||||
|
virtual void GenerateTargetManifest(cmTargetManifest&);
|
||||||
|
|
||||||
///! Get the makefile for this generator
|
///! Get the makefile for this generator
|
||||||
cmMakefile *GetMakefile() {
|
cmMakefile *GetMakefile() {
|
||||||
|
|
|
@ -346,4 +346,7 @@ private:
|
||||||
|
|
||||||
typedef std::map<cmStdString,cmTarget> cmTargets;
|
typedef std::map<cmStdString,cmTarget> cmTargets;
|
||||||
|
|
||||||
|
class cmTargetSet: public std::set<cmStdString> {};
|
||||||
|
class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue