export: Only generate and install configuration files if needed.

The modern way to create configuration dependent content is using
generator expressions in the main export file.  The only non-deprecated
property still generated in the configuration-specific files are
IMPORTED_LOCATION_<CONFIG>

INTERFACE_LIBRARY targets have no location, and no need for those
files.
This commit is contained in:
Stephen Kelly 2013-12-26 08:19:33 +01:00
parent 0de81bba8c
commit af3d3b88be
1 changed files with 15 additions and 6 deletions

View File

@ -115,12 +115,17 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool require2_8_12 = false; bool require2_8_12 = false;
bool require3_0_0 = false; bool require3_0_0 = false;
bool requiresConfigFiles = false;
// Create all the imported targets. // Create all the imported targets.
for(std::vector<cmTargetExport*>::const_iterator for(std::vector<cmTargetExport*>::const_iterator
tei = allTargets.begin(); tei = allTargets.begin();
tei != allTargets.end(); ++tei) tei != allTargets.end(); ++tei)
{ {
cmTarget* te = (*tei)->Target; cmTarget* te = (*tei)->Target;
requiresConfigFiles = requiresConfigFiles
|| te->GetType() != cmTarget::INTERFACE_LIBRARY;
this->GenerateImportTargetCode(os, te); this->GenerateImportTargetCode(os, te);
ImportPropertyMap properties; ImportPropertyMap properties;
@ -197,15 +202,19 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
} }
this->GenerateImportedFileCheckLoop(os); this->GenerateImportedFileCheckLoop(os);
// Generate an import file for each configuration.
bool result = true; bool result = true;
for(std::vector<std::string>::const_iterator // Generate an import file for each configuration.
ci = this->Configurations.begin(); // Don't do this if we only export INTERFACE_LIBRARY targets.
ci != this->Configurations.end(); ++ci) if (requiresConfigFiles)
{ {
if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) for(std::vector<std::string>::const_iterator
ci = this->Configurations.begin();
ci != this->Configurations.end(); ++ci)
{ {
result = false; if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
{
result = false;
}
} }
} }