diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 30a8bf230..194d9a233 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -50,7 +50,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) ->FindGeneratorTargetToUse(*tei); expectedTargets += sep + this->Namespace + te->Target->GetExportName(); sep = " "; - if(this->ExportedTargets.insert(te->Target).second) + if(this->ExportedTargets.insert(te).second) { this->Exports.push_back(te); } @@ -80,45 +80,44 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei != this->Exports.end(); ++tei) { cmGeneratorTarget* gte = *tei; - cmTarget* te = gte->Target; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gte); - te->AppendBuildInterfaceIncludes(); + gte->Target->AppendBuildInterfaceIncludes(); ImportPropertyMap properties; - this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, + this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_SOURCES", te, + this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); + gte, properties); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gte->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gte->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - this->PopulateInterfaceLinkLibrariesProperty(te, + this->PopulateInterfaceLinkLibrariesProperty(gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); } this->PopulateCompatibleInterfaceProperties(gte, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gte, os, properties); } // Generate import file content for each configuration. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4e8bc868c..09855422d 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -155,7 +155,7 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget *target, ImportPropertyMap &properties) { const char *input = target->GetProperty(propName); @@ -169,7 +169,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, const std::string& outputName, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector &missingTargets) @@ -206,12 +206,12 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os, //---------------------------------------------------------------------------- bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector &missingTargets) { - if(!target->IsLinkable()) + if(!target->Target->IsLinkable()) { return false; } @@ -420,7 +420,7 @@ void cmExportFileGenerator::PopulateSourcesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, gt->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); if (!checkInterfaceDirs(prepro, gt, propName)) @@ -488,7 +488,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets); if (!checkInterfaceDirs(prepro, target, propName)) @@ -502,7 +502,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector &missingTargets) @@ -574,15 +574,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { - cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", - target, properties); + gtarget, properties); std::set ifaceProperties; @@ -593,12 +592,12 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - if (target->GetType() != cmState::INTERFACE_LIBRARY) + if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; - target->GetMakefile()->GetConfigurations(configNames); + gtarget->Target->GetMakefile()->GetConfigurations(configNames); for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) @@ -611,19 +610,20 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( it != ifaceProperties.end(); ++it) { this->PopulateInterfaceProperty("INTERFACE_" + *it, - target, properties); + gtarget, properties); } } //---------------------------------------------------------------------------- -void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, +void cmExportFileGenerator::GenerateInterfaceProperties( + const cmGeneratorTarget* target, std::ostream& os, const ImportPropertyMap &properties) { if (!properties.empty()) { std::string targetName = this->Namespace; - targetName += target->GetExportName(); + targetName += target->Target->GetExportName(); os << "set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) @@ -638,12 +638,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, //---------------------------------------------------------------------------- bool cmExportFileGenerator::AddTargetNamespace(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector &missingTargets) { - cmMakefile *mf = target->GetMakefile(); + cmLocalGenerator *lg = target->GetLocalGenerator(); - cmTarget *tgt = mf->FindTargetToUse(input); + cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input); if (!tgt) { return false; @@ -655,13 +655,14 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, } if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) { - input = this->Namespace + tgt->GetExportName(); + input = this->Namespace + tgt->Target->GetExportName(); } else { std::string namespacedTarget; this->HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); + target->Target->GetMakefile(), + target->Target, tgt->Target); if (!namespacedTarget.empty()) { input = namespacedTarget; @@ -674,7 +675,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector &missingTargets, FreeTargetsReplace replace) { @@ -711,14 +712,12 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector &missingTargets) { std::string::size_type pos = 0; std::string::size_type lastPos = pos; - cmMakefile *mf = target->GetMakefile(); - while((pos = input.find("$IssueMessage(cmake::FATAL_ERROR, errorString); + target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString); } } @@ -860,7 +859,7 @@ cmExportFileGenerator preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; @@ -962,7 +961,7 @@ cmExportFileGenerator sep = ";"; std::string temp = *li; - this->AddTargetNamespace(temp, target->Target, missingTargets); + this->AddTargetNamespace(temp, target, missingTargets); link_entries += temp; } @@ -1044,12 +1043,12 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) +::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target) { // Construct the imported target name. std::string targetName = this->Namespace; - targetName += target->GetExportName(); + targetName += target->Target->GetExportName(); // Create the imported target. os << "# Create imported target " << targetName << "\n"; @@ -1078,27 +1077,27 @@ cmExportFileGenerator } // Mark the imported executable if it has exports. - if(target->IsExecutableWithExports()) + if(target->Target->IsExecutableWithExports()) { os << "set_property(TARGET " << targetName << " PROPERTY ENABLE_EXPORTS 1)\n"; } // Mark the imported library if it is a framework. - if(target->IsFrameworkOnApple()) + if(target->Target->IsFrameworkOnApple()) { os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n"; } // Mark the imported executable if it is an application bundle. - if(target->IsAppBundleOnApple()) + if(target->Target->IsAppBundleOnApple()) { os << "set_property(TARGET " << targetName << " PROPERTY MACOSX_BUNDLE 1)\n"; } - if (target->IsCFBundleOnApple()) + if (target->Target->IsCFBundleOnApple()) { os << "set_property(TARGET " << targetName << " PROPERTY BUNDLE 1)\n"; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 44f779b67..3280a03ff 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -75,7 +75,8 @@ protected: const std::string& config = ""); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); - void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); + void GenerateImportTargetCode(std::ostream& os, + cmGeneratorTarget const* target); void GenerateImportPropertyCode(std::ostream& os, const std::string& config, cmTarget const* target, ImportPropertyMap const& properties); @@ -122,19 +123,21 @@ protected: cmTarget* depender, cmTarget* dependee) = 0; void PopulateInterfaceProperty(const std::string&, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); - bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target, + bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); - void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, + void PopulateInterfaceProperty(const std::string& propName, + cmGeneratorTarget* target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); - void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, + void GenerateInterfaceProperties(cmGeneratorTarget const* target, + std::ostream& os, const ImportPropertyMap &properties); void PopulateIncludeDirectoriesInterface( cmTargetExport *target, @@ -159,7 +162,7 @@ protected: }; void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); @@ -182,20 +185,20 @@ protected: bool AppendMode; // The set of targets included in the export. - std::set ExportedTargets; + std::set ExportedTargets; private: void PopulateInterfaceProperty(const std::string&, const std::string&, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); - bool AddTargetNamespace(std::string &input, cmTarget* target, + bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target, std::vector &missingTargets); void ResolveTargetsInGeneratorExpression(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector &missingTargets); virtual void ReplaceInstallPrefix(std::string &input); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index d7ca6d529..da963f37e 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -52,7 +52,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) sep + this->Namespace + (*tei)->Target->Target->GetExportName(); sep = " "; cmTargetExport * te = *tei; - if(this->ExportedTargets.insert(te->Target->Target).second) + if(this->ExportedTargets.insert(te->Target).second) { allTargets.push_back(te); } @@ -133,12 +133,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei != allTargets.end(); ++tei) { cmGeneratorTarget* gt = (*tei)->Target; - cmTarget* te = gt->Target; requiresConfigFiles = requiresConfigFiles - || te->GetType() != cmState::INTERFACE_LIBRARY; + || gt->GetType() != cmState::INTERFACE_LIBRARY; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gt); ImportPropertyMap properties; @@ -149,32 +148,32 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gt->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gt->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - if (this->PopulateInterfaceLinkLibrariesProperty(te, + if (this->PopulateInterfaceLinkLibrariesProperty(gt, cmGeneratorExpression::InstallInterface, properties, missingTargets) && !this->ExportOld) @@ -182,11 +181,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) require2_8_12 = true; } } - if (te->GetType() == cmState::INTERFACE_LIBRARY) + if (gt->GetType() == cmState::INTERFACE_LIBRARY) { require3_0_0 = true; } - if(te->GetProperty("INTERFACE_SOURCES")) + if(gt->GetProperty("INTERFACE_SOURCES")) { // We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1 // can consume them. @@ -194,11 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); + gt, properties); this->PopulateCompatibleInterfaceProperties(gt, properties); - this->GenerateInterfaceProperties(gt->Target, os, properties); + this->GenerateInterfaceProperties(gt, os, properties); } if (require3_1_0) diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 0fafa86f1..1daa67e08 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -28,38 +28,38 @@ cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) { - std::set emitted; - std::set emittedDeps; + std::set emitted; + std::set emittedDeps; while(!this->Exports.empty()) { cmGeneratorTarget const* te = this->Exports.back(); this->Exports.pop_back(); - if (emitted.insert(te->Target).second) + if (emitted.insert(te).second) { - emittedDeps.insert(te->Target); - this->GenerateImportTargetCode(os, te->Target); + emittedDeps.insert(te); + this->GenerateImportTargetCode(os, te); ImportPropertyMap properties; #define FIND_TARGETS(PROPERTY) \ - this->FindTargets("INTERFACE_" #PROPERTY, te->Target, emittedDeps); + this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps); CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) #undef FIND_TARGETS - this->PopulateProperties(te->Target, properties, emittedDeps); + this->PopulateProperties(te, properties, emittedDeps); - this->GenerateInterfaceProperties(te->Target, os, properties); + this->GenerateInterfaceProperties(te, os, properties); } } return true; } std::string cmExportTryCompileFileGenerator::FindTargets( - const std::string& propName, - cmTarget const* tgt, - std::set &emitted) + const std::string& propName, + cmGeneratorTarget const* tgt, + std::set &emitted) { const char *prop = tgt->GetProperty(propName); if(!prop) @@ -77,24 +77,22 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmTarget dummyHead; dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe"); - dummyHead.SetMakefile(tgt->GetMakefile()); + dummyHead.SetMakefile(tgt->Target->GetMakefile()); - cmGeneratorTarget* gtgt = - tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); - cmGeneratorTarget gDummyHead(&dummyHead, gtgt->GetLocalGenerator()); + cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(gtgt->GetLocalGenerator(), this->Config, + std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead, - gtgt, &dagChecker); + tgt, &dagChecker); const std::set &allTargets = cge->GetAllTargetsSeen(); for(std::set::const_iterator li = allTargets.begin(); li != allTargets.end(); ++li) { - if(emitted.insert((*li)->Target).second) + if(emitted.insert(*li).second) { - this->Exports.push_back((*li)); + this->Exports.push_back(*li); } } return result; @@ -102,13 +100,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets( //---------------------------------------------------------------------------- void -cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, - ImportPropertyMap& properties, - std::set &emitted) +cmExportTryCompileFileGenerator::PopulateProperties( + const cmGeneratorTarget* target, + ImportPropertyMap& properties, + std::set &emitted) { - cmPropertyMap props = target->GetProperties(); - cmGeneratorTarget* gt = - target->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(target); + cmPropertyMap props = target->Target->GetProperties(); for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) { properties[i->first] = i->second.GetValue(); @@ -126,8 +123,8 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, li != depends.end(); ++li) { cmGeneratorTarget *tgt = - gt->GetLocalGenerator()->FindGeneratorTargetToUse(*li); - if(tgt && emitted.insert(tgt->Target).second) + target->GetLocalGenerator()->FindGeneratorTargetToUse(*li); + if(tgt && emitted.insert(tgt).second) { this->Exports.push_back(tgt); } diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 45077876a..19d802418 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -41,15 +41,16 @@ protected: cmTarget*, cmTarget*) {} - void PopulateProperties(cmTarget const* target, + void PopulateProperties(cmGeneratorTarget const* target, ImportPropertyMap& properties, - std::set &emitted); + std::set& emitted); std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: - std::string FindTargets(const std::string& prop, cmTarget const* tgt, - std::set &emitted); + std::string FindTargets(const std::string& prop, + const cmGeneratorTarget* tgt, + std::set& emitted); std::vector Exports;