diff options
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 139 |
1 files changed, 67 insertions, 72 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9a7d73f..e8a2e6a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -18,7 +18,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmTarget.h" #include "cmTargetExport.h" #include "cmVersion.h" #include "cmComputeLinkInformation.h" @@ -155,7 +154,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 +168,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<std::string> &missingTargets) @@ -206,7 +205,7 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os, //---------------------------------------------------------------------------- bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -241,12 +240,14 @@ static bool isSubDirectory(const char* a, const char* b) //---------------------------------------------------------------------------- static bool checkInterfaceDirs(const std::string &prepro, - cmTarget *target, const std::string& prop) + cmGeneratorTarget *target, const std::string& prop) { const char* installDir = - target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); - const char* topSourceDir = target->GetMakefile()->GetHomeDirectory(); - const char* topBinaryDir = target->GetMakefile()->GetHomeOutputDirectory(); + target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + const char* topSourceDir = + target->GetLocalGenerator()->GetSourceDirectory(); + const char* topBinaryDir = + target->GetLocalGenerator()->GetBinaryDirectory(); std::vector<std::string> parts; cmGeneratorExpression::Split(prepro, parts); @@ -298,7 +299,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } bool inBinary = isSubDirectory(li->c_str(), topBinaryDir); bool inSource = isSubDirectory(li->c_str(), topSourceDir); @@ -329,7 +330,7 @@ static bool checkInterfaceDirs(const std::string &prepro, "a subdirectory of the " << (inBinary ? "build" : "source") << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir) << "\"" << std::endl; - target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING, + target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING, s.str()); } case cmPolicies::OLD: @@ -352,7 +353,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } if (!inSourceBuild) { @@ -361,7 +362,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } } } @@ -396,11 +397,11 @@ void cmExportFileGenerator::PopulateSourcesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget* gt = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_SOURCES"; - const char *input = target->GetProperty(propName); + const char *input = gt->GetProperty(propName); if (!input) { @@ -418,10 +419,10 @@ void cmExportFileGenerator::PopulateSourcesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); - if (!checkInterfaceDirs(prepro, target, propName)) + if (!checkInterfaceDirs(prepro, gt, propName)) { return; } @@ -436,7 +437,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget *target = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; @@ -450,18 +451,18 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); - std::string exportDirs = cge->Evaluate(target->GetMakefile(), "", + std::string exportDirs = cge->Evaluate(target->GetLocalGenerator(), "", false, target); if (cge->GetHadContextSensitiveCondition()) { - cmMakefile* mf = target->GetMakefile(); + cmLocalGenerator* lg = target->GetLocalGenerator(); std::ostringstream e; e << "Target \"" << target->GetName() << "\" is installed with " "INCLUDES DESTINATION set to a context sensitive path. Paths which " "depend on the configuration, policy values or the link interface are " "not supported. Consider using target_include_directories instead."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -500,7 +501,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -511,8 +512,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty( //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget const* tgt, const std::string& prop, - std::set<std::string> &ifaceProperties) +void getPropertyContents(cmGeneratorTarget const* tgt, + const std::string& prop, + std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); if (!p) @@ -533,11 +535,11 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, if (!info) { - cmMakefile* mf = target->Target->GetMakefile(); + cmLocalGenerator* lg = target->GetLocalGenerator(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -571,31 +573,30 @@ 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<std::string> ifaceProperties; - getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN", + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MIN", ifaceProperties); - getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX", + getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector<std::string> configNames; - target->GetMakefile()->GetConfigurations(configNames); + gtarget->Target->GetMakefile()->GetConfigurations(configNames); for (std::vector<std::string>::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) @@ -608,12 +609,13 @@ 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) { @@ -635,12 +637,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, //---------------------------------------------------------------------------- bool cmExportFileGenerator::AddTargetNamespace(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { - cmMakefile *mf = target->GetMakefile(); + cmLocalGenerator *lg = target->GetLocalGenerator(); - cmTarget *tgt = mf->FindTargetToUse(input); + cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input); if (!tgt) { return false; @@ -658,7 +660,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, { std::string namespacedTarget; this->HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); + target, tgt); if (!namespacedTarget.empty()) { input = namespacedTarget; @@ -671,7 +673,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets, FreeTargetsReplace replace) { @@ -708,14 +710,12 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { std::string::size_type pos = 0; std::string::size_type lastPos = pos; - cmMakefile *mf = target->GetMakefile(); - while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) { std::string::size_type nameStartPos = pos + @@ -776,7 +776,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( if (!errorString.empty()) { - mf->IssueMessage(cmake::FATAL_ERROR, errorString); + target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString); } } @@ -797,7 +797,7 @@ cmExportFileGenerator { // Add the transitive link dependencies for this configuration. cmLinkInterface const* iface = target->GetLinkInterface(config, - target->Target); + target); if (!iface) { return; @@ -830,20 +830,18 @@ cmExportFileGenerator } const bool newCMP0022Behavior = - target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::WARN - && target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::OLD; + target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && target->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(newCMP0022Behavior && !this->ExportOld) { - cmMakefile *mf = target->Target->GetMakefile(); + cmLocalGenerator *lg = target->GetLocalGenerator(); std::ostringstream e; e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, " "but also has old-style LINK_INTERFACE_LIBRARIES properties " "populated, but it was exported without the " "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties"; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -857,7 +855,7 @@ cmExportFileGenerator preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; @@ -878,13 +876,10 @@ cmExportFileGenerator cmMakefile* mf = target->Makefile; // Add the soname for unix shared libraries. - if(target->GetType() == cmTarget::SHARED_LIBRARY || - target->GetType() == cmTarget::MODULE_LIBRARY) + if(target->GetType() == cmState::SHARED_LIBRARY || + target->GetType() == cmState::MODULE_LIBRARY) { - // Check whether this is a DLL platform. - bool dll_platform = - (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW")); - if(!dll_platform) + if(!target->IsDLLPlatform()) { std::string prop; std::string value; @@ -909,7 +904,7 @@ cmExportFileGenerator // Add the transitive link dependencies for this configuration. if(cmLinkInterface const* iface = - target->GetLinkInterface(config, target->Target)) + target->GetLinkInterface(config, target)) { this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", @@ -959,7 +954,7 @@ cmExportFileGenerator sep = ";"; std::string temp = *li; - this->AddTargetNamespace(temp, target->Target, missingTargets); + this->AddTargetNamespace(temp, target, missingTargets); link_entries += temp; } @@ -1041,7 +1036,7 @@ 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; @@ -1052,22 +1047,22 @@ cmExportFileGenerator os << "# Create imported target " << targetName << "\n"; switch(target->GetType()) { - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: os << "add_executable(" << targetName << " IMPORTED)\n"; break; - case cmTarget::STATIC_LIBRARY: + case cmState::STATIC_LIBRARY: os << "add_library(" << targetName << " STATIC IMPORTED)\n"; break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: os << "add_library(" << targetName << " SHARED IMPORTED)\n"; break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: os << "add_library(" << targetName << " MODULE IMPORTED)\n"; break; - case cmTarget::UNKNOWN_LIBRARY: + case cmState::UNKNOWN_LIBRARY: os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n"; break; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: os << "add_library(" << targetName << " INTERFACE IMPORTED)\n"; break; default: // should never happen @@ -1107,7 +1102,7 @@ cmExportFileGenerator void cmExportFileGenerator ::GenerateImportPropertyCode(std::ostream& os, const std::string& config, - cmTarget const* target, + cmGeneratorTarget const* target, ImportPropertyMap const& properties) { // Construct the imported target name. @@ -1227,7 +1222,7 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, +::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations) { |