diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 252e2312d..f901414fc 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -383,7 +383,7 @@ std::vector cmCommonTargetGenerator::GetLinkedTargetDirectories() const { std::vector dirs; - std::set emitted; + std::set emitted; if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { @@ -391,7 +391,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const for(cmComputeLinkInformation::ItemVector::const_iterator i = items.begin(); i != items.end(); ++i) { - cmTarget const* linkee = i->Target; + cmGeneratorTarget const* linkee = i->Target; if(linkee && !linkee->IsImported() // We can ignore the INTERFACE_LIBRARY items because // Target->GetLinkInformation already processed their @@ -399,13 +399,11 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const && linkee->GetType() != cmTarget::INTERFACE_LIBRARY && emitted.insert(linkee).second) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(linkee); - cmLocalGenerator* lg = gt->GetLocalGenerator(); - cmMakefile* mf = linkee->GetMakefile(); + cmLocalGenerator* lg = linkee->GetLocalGenerator(); + cmMakefile* mf = linkee->Target->GetMakefile(); std::string di = mf->GetCurrentBinaryDirectory(); di += "/"; - di += lg->GetTargetDirectory(*linkee); + di += lg->GetTargetDirectory(*linkee->Target); dirs.push_back(di); } } diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 7d20827f0..22843f170 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -320,8 +320,7 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item) int index = lei->second; LinkEntry& entry = this->EntryList[index]; entry.Item = item; - entry.Target = - item.Target ? this->GlobalGenerator->GetGeneratorTarget(item.Target) : 0; + entry.Target = item.Target; entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' && item.substr(0, 10) != "-framework"); @@ -443,9 +442,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Initialize the item entry. LinkEntry& entry = this->EntryList[lei->second]; entry.Item = dep.Item; - entry.Target = - dep.Item.Target ? - this->GlobalGenerator->GetGeneratorTarget(dep.Item.Target) : 0; + entry.Target = dep.Item.Target; // This item was added specifically because it is a dependent // shared library. It may get special treatment @@ -634,8 +631,9 @@ cmComputeLinkDepends::AddLinkEntries( } //---------------------------------------------------------------------------- -cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, - const std::string& name) +cmGeneratorTarget const* +cmComputeLinkDepends::FindTargetToLink(int depender_index, + const std::string& name) { // Look for a target in the scope of the depender. cmGeneratorTarget const* from = this->Target; @@ -647,7 +645,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, from = depender; } } - return from->Target->FindTargetToLink(name); + return from->FindTargetToLink(name); } //---------------------------------------------------------------------------- diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index fc484de15..d9760aa49 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -14,6 +14,7 @@ #include "cmStandardIncludes.h" #include "cmTarget.h" +#include "cmLinkItem.h" #include "cmGraphAdjacencyList.h" @@ -52,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set const& GetOldWrongConfigItems() const + std::set const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -72,8 +73,8 @@ private: void AddDirectLinkEntries(); template void AddLinkEntries(int depender_index, std::vector const& libs); - cmTarget const* FindTargetToLink(int depender_index, - const std::string& name); + cmGeneratorTarget const* FindTargetToLink(int depender_index, + const std::string& name); // One entry for each unique item. std::vector EntryList; @@ -150,7 +151,7 @@ private: // Record of the original link line. std::vector OriginalEntries; - std::set OldWrongConfigItems; + std::set OldWrongConfigItems; void CheckWrongConfigItem(cmLinkItem const& item); int ComponentOrderId; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c76cb7a58..bfa8c64e4 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,7 +19,6 @@ #include "cmState.h" #include "cmOutputConverter.h" #include "cmMakefile.h" -#include "cmTarget.h" #include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -471,7 +470,7 @@ std::vector const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set const& +const std::set& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -537,16 +536,16 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set::const_iterator i = wrongItems.begin(); - i != wrongItems.end(); ++i) + std::set const& wrongItems = + cld.GetOldWrongConfigItems(); + for(std::set::const_iterator i = + wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget const* tgt = *i; - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); + cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); - std::string lib = gtgt->GetFullPath(this->Config , implib, true); + std::string lib = tgt->GetFullPath(this->Config , implib, true); this->OldLinkDirItems.push_back(lib); } } @@ -658,7 +657,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); linkItem += exe; - this->Items.push_back(Item(linkItem, true, tgt->Target)); + this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); } else if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY) @@ -666,7 +665,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // Add the interface library as an item so it can be considered as part // of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore // this for the actual link line. - this->Items.push_back(Item(std::string(), true, tgt->Target)); + this->Items.push_back(Item(std::string(), true, tgt)); } else { @@ -683,8 +682,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item, this->Depends.push_back(lib); } - this->AddTargetItem(lib, tgt->Target); - this->AddLibraryRuntimeInfo(lib, tgt->Target); + this->AddTargetItem(lib, tgt); + this->AddLibraryRuntimeInfo(lib, tgt); } } else @@ -766,7 +765,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, if(tgt) { lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); - this->AddLibraryRuntimeInfo(lib, tgt->Target); + this->AddLibraryRuntimeInfo(lib, tgt); } else { @@ -1077,7 +1076,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget const* target) + cmGeneratorTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1096,10 +1095,9 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, this->SharedLibrariesLinked.insert(target); } - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); // Handle case of an imported shared library with no soname. if(this->NoSONameUsesPath && - gtgt->IsImportedSharedLibWithoutSOName(this->Config)) + target->IsImportedSharedLibWithoutSOName(this->Config)) { this->AddSharedLibNoSOName(item); return; @@ -1113,7 +1111,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, // For compatibility with CMake 2.4 include the item's directory in // the linker search path. - if(this->OldLinkDirMode && !target->IsFrameworkOnApple() && + if(this->OldLinkDirMode && !target->Target->IsFrameworkOnApple() && this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) == this->OldLinkDirMask.end()) { @@ -1777,15 +1775,14 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget const* target) + cmGeneratorTarget const* target) { - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as // @loader_path or full paths. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - if(!gtgt->HasMacOSXRpathInstallNameDir(this->Config)) + if(!target->HasMacOSXRpathInstallNameDir(this->Config)) { return; } @@ -1807,7 +1804,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = gtgt->GetSOName(this->Config); + std::string soName = target->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index b1e7e4680..5eecf7dcb 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -19,7 +19,6 @@ class cmake; class cmGlobalGenerator; class cmMakefile; -class cmTarget; class cmGeneratorTarget; class cmOrderDirectories; @@ -39,11 +38,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget const* target = 0): + Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget const* Target; + cmGeneratorTarget const* Target; }; typedef std::vector ItemVector; ItemVector const& GetItems(); @@ -57,7 +56,7 @@ public: void GetRPath(std::vector& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set const& GetSharedLibrariesLinked(); + std::set const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); @@ -71,7 +70,7 @@ private: std::vector Depends; std::vector FrameworkPaths; std::vector RuntimeSearchPath; - std::set SharedLibrariesLinked; + std::set SharedLibrariesLinked; // Context information. cmGeneratorTarget const* Target; @@ -129,7 +128,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget const* target); + void AddTargetItem(std::string const& item, const cmGeneratorTarget* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -183,7 +182,7 @@ private: bool CMP0060Warn; void AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget const* target); + const cmGeneratorTarget* target); void AddLibraryRuntimeInfo(std::string const& fullPath); }; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 18aad10e4..8f3def207 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -272,7 +272,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Loop over all utility dependencies. { - std::set const& tutils = depender->Target->GetUtilityItems(); + std::set const& tutils = depender->GetUtilityItems(); std::set emitted; // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -319,22 +319,20 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, std::set &emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; - cmTarget const* dependee = dependee_name.Target; + cmGeneratorTarget const* dependee = dependee_name.Target; // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. if(dependee && dependee->GetType() == cmTarget::EXECUTABLE && - !dependee->IsExecutableWithExports()) + !dependee->Target->IsExecutableWithExports()) { dependee = 0; } if(dependee) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(dependee); - this->AddInterfaceDepends(depender_index, gt, "", emitted); + this->AddInterfaceDepends(depender_index, dependee, "", emitted); std::vector configs; depender->Makefile->GetConfigurations(configs); for (std::vector::const_iterator it = configs.begin(); @@ -342,7 +340,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, { // A target should not depend on itself. emitted.insert(depender->GetName()); - this->AddInterfaceDepends(depender_index, gt, *it, emitted); + this->AddInterfaceDepends(depender_index, dependee, *it, emitted); } } } @@ -356,7 +354,7 @@ void cmComputeTargetDepends::AddTargetDepend( cmGeneratorTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget const* dependee = dependee_name.Target; + cmGeneratorTarget const* dependee = dependee_name.Target; if(!dependee && !linking && (depender->GetType() != cmTarget::GLOBAL_TARGET)) @@ -403,16 +401,14 @@ void cmComputeTargetDepends::AddTargetDepend( // within the project. if(linking && dependee && dependee->GetType() == cmTarget::EXECUTABLE && - !dependee->IsExecutableWithExports()) + !dependee->Target->IsExecutableWithExports()) { dependee = 0; } if(dependee) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(dependee); - this->AddTargetDepend(depender_index, gt, linking); + this->AddTargetDepend(depender_index, dependee, linking); } } @@ -426,15 +422,13 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, { // Skip IMPORTED and INTERFACE targets but follow their utility // dependencies. - std::set const& utils = dependee->Target->GetUtilityItems(); + std::set const& utils = dependee->GetUtilityItems(); for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget const* transitive_dependee = i->Target) + if(cmGeneratorTarget const* transitive_dependee = i->Target) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(transitive_dependee); - this->AddTargetDepend(depender_index, gt, false); + this->AddTargetDepend(depender_index, transitive_dependee, false); } } } diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index fed0dbc90..400fa170e 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -217,7 +217,7 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_IMPLIB"; prop += suffix; std::string value = target->GetFullPath(config, true); - target->Target->GetImplibGNUtoMS(value, value, + target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 5d530a0ef..b29429e60 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -517,8 +517,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty( //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget const* tgt, const std::string& prop, - std::set &ifaceProperties) +void getPropertyContents(cmGeneratorTarget const* tgt, + const std::string& prop, + std::set &ifaceProperties) { const char *p = tgt->GetProperty(prop); if (!p) @@ -589,11 +590,11 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( std::set 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) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 630636031..b8ec0f93d 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -254,9 +254,9 @@ void cmExtraSublimeTextGenerator:: } std::vector& flags = sourceFileFlagsIter->second; std::string flagsString = - this->ComputeFlagsForObject(*iter, lg, target, gtgt); + this->ComputeFlagsForObject(*iter, lg, gtgt); std::string definesString = - this->ComputeDefines(*iter, lg, target, gtgt); + this->ComputeDefines(*iter, lg, gtgt); flags.clear(); cmsys::RegularExpression flagRegex; // Regular expression to extract compiler flags from a string @@ -364,7 +364,6 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt) { std::string flags; @@ -389,7 +388,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, // } // Add shared-library flags if needed. - lg->AddCMP0018Flags(flags, target, language, config); + lg->AddCMP0018Flags(flags, gtgt->Target, language, config); // Add include directory flags. { @@ -404,7 +403,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, lg->AppendFlags(flags, makefile->GetDefineFlags()); // Add target-specific flags. - lg->AddCompileOptions(flags, target, language, config); + lg->AddCompileOptions(flags, gtgt->Target, language, config); // Add source file specific flags. lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); @@ -418,8 +417,8 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmExtraSublimeTextGenerator:: -ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, - cmGeneratorTarget*) +ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, + cmGeneratorTarget* target) { std::set defines; @@ -428,13 +427,13 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = target->GetExportMacro()) + if(const char* exportMacro = target->Target->GetExportMacro()) { lg->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - lg->AddCompileDefinitions(defines, target, config, language); + lg->AddCompileDefinitions(defines, target->Target, config, language); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 4173b7de3..5dd114075 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -79,11 +79,10 @@ private: */ std::string ComputeFlagsForObject(cmSourceFile *source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt); std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, - cmTarget *target, cmGeneratorTarget* gtgt); + cmGeneratorTarget* gtgt); }; #endif diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 78a5b6f78..88d10aa5b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -831,8 +831,8 @@ template std::string getLinkedTargetsContent( std::vector const &libraries, - cmTarget const* target, - cmTarget const* headTarget, + cmGeneratorTarget const* target, + cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext *context, cmGeneratorExpressionDAGChecker *dagChecker, const std::string &interfacePropertyName) @@ -858,8 +858,10 @@ getLinkedTargetsContent( { linkedTargetsContent = cmGeneratorExpressionNode::EvaluateDependentExpression(depString, - target->GetMakefile(), context, - headTarget, target, dagChecker); + target->Target->GetMakefile(), + context, + headTarget->Target, + target->Target, dagChecker); } linkedTargetsContent = cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent); @@ -1116,8 +1118,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode gtgt->GetLinkInterfaceLibraries(context->Config, gHeadTarget, true)) { linkedTargetsContent = - getLinkedTargetsContent(iface->Libraries, target, - headTarget, + getLinkedTargetsContent(iface->Libraries, gtgt, + gHeadTarget, context, &dagChecker, interfacePropertyName); } @@ -1128,8 +1130,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode gtgt->GetLinkImplementationLibraries(context->Config)) { linkedTargetsContent = - getLinkedTargetsContent(impl->Libraries, target, - target, + getLinkedTargetsContent(impl->Libraries, gtgt, + gtgt, context, &dagChecker, interfacePropertyName); } @@ -1658,7 +1660,7 @@ struct TargetFilesystemArtifactResultCreator return std::string(); } return target->GetFullPath(context->Config, - target->Target->HasImportLibrary()); + target->HasImportLibrary()); } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f3d34e304..1699362f4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -271,7 +271,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) DebugCompileFeaturesDone(false), DebugCompileDefinitionsDone(false), DebugSourcesDone(false), - LinkImplementationLanguageIsContextDependent(true) + LinkImplementationLanguageIsContextDependent(true), + UtilityItemsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -509,7 +510,8 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const return 0; } -static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, +static void handleSystemIncludesDep(cmMakefile *mf, + cmGeneratorTarget const* depTgt, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker, @@ -523,7 +525,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, cmSystemTools::ExpandListArgument(ge.Parse(dirs) ->Evaluate(mf, config, false, headTarget->Target, - depTgt, dagChecker), result); + depTgt->Target, dagChecker), result); } if (!depTgt->IsImported() || excludeImported) { @@ -537,7 +539,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, cmSystemTools::ExpandListArgument(ge.Parse(dirs) ->Evaluate(mf, config, false, headTarget->Target, - depTgt, dagChecker), result); + depTgt->Target, dagChecker), result); } } @@ -760,7 +762,25 @@ cmGeneratorTarget::GetExpectedXamlSources(std::set& srcs, { XamlData data; IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData) - srcs = data.ExpectedXamlSources; + srcs = data.ExpectedXamlSources; +} + +std::set const& cmGeneratorTarget::GetUtilityItems() const +{ + if(!this->UtilityItemsDone) + { + this->UtilityItemsDone = true; + std::set const& utilities = this->Target->GetUtilities(); + for(std::set::const_iterator i = utilities.begin(); + i != utilities.end(); ++i) + { + cmTarget* tgt = this->Makefile->FindTargetToUse(*i); + cmGeneratorTarget* gt = tgt ? this->GlobalGenerator + ->GetGeneratorTarget(tgt) : 0; + this->UtilityItems.insert(cmLinkItem(*i, gt)); + } + } + return this->UtilityItems; } //---------------------------------------------------------------------------- @@ -864,9 +884,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, &dagChecker), result); } - std::vector const& deps = + std::vector const& deps = this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator + for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { handleSystemIncludesDep(this->Makefile, *li, config, this, @@ -1711,15 +1731,12 @@ public: } return; } - if(!this->Visited.insert(item.Target).second) + if(!this->Visited.insert(item.Target->Target).second) { return; } - cmGeneratorTarget* gtgt = - this->Target->GetLocalGenerator()->GetGlobalGenerator() - ->GetGeneratorTarget(item.Target); cmLinkInterface const* iface = - gtgt->GetLinkInterface(this->Config, this->HeadTarget); + item.Target->GetLinkInterface(this->Config, this->HeadTarget); if(!iface) { return; } for(std::vector::const_iterator @@ -2050,15 +2067,14 @@ void processILibs(const std::string& config, cmGeneratorTarget const* headTarget, cmLinkItem const& item, cmGlobalGenerator* gg, - std::vector& tgts, - std::set& emitted) + std::vector& tgts, + std::set& emitted) { if (item.Target && emitted.insert(item.Target).second) { tgts.push_back(item.Target); - cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target); if(cmLinkInterfaceLibraries const* iface = - gt->GetLinkInterfaceLibraries(config, headTarget, true)) + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) { for(std::vector::const_iterator it = iface->Libraries.begin(); @@ -2071,7 +2087,7 @@ void processILibs(const std::string& config, } //---------------------------------------------------------------------------- -const std::vector& +const std::vector& cmGeneratorTarget::GetLinkImplementationClosure( const std::string& config) const { @@ -2080,7 +2096,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( if(!tgts.Done) { tgts.Done = true; - std::set emitted; + std::set emitted; cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config); @@ -3615,10 +3631,10 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.Done = true; compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = + std::vector const& deps = this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) + for(std::vector::const_iterator li = + deps.begin(); li != deps.end(); ++li) { #define CM_READ_COMPATIBLE_INTERFACE(X, x) \ if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ @@ -3735,7 +3751,7 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, //---------------------------------------------------------------------------- template void checkPropertyConsistency(cmGeneratorTarget const* depender, - cmTarget const* dependee, + cmGeneratorTarget const* dependee, const std::string& propName, std::set &emitted, const std::string& config, @@ -3751,7 +3767,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, std::vector props; cmSystemTools::ExpandListArgument(prop, props); std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); pdir += "/Help/prop_tgt/"; for(std::vector::iterator pi = props.begin(); @@ -3964,18 +3980,20 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) //---------------------------------------------------------------------------- template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); +PropertyType getTypedProperty(cmGeneratorTarget const* tgt, + const std::string& prop); //---------------------------------------------------------------------------- template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +bool getTypedProperty(cmGeneratorTarget const* tgt, + const std::string& prop) { return tgt->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- template<> -const char *getTypedProperty(cmTarget const* tgt, +const char *getTypedProperty(cmGeneratorTarget const* tgt, const std::string& prop) { return tgt->GetProperty(prop); @@ -4105,7 +4123,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt->Target, p); + PropertyType propContent = getTypedProperty(tgt, p); const bool explicitlySet = tgt->Target->GetProperties() .find(p) != tgt->Target->GetProperties().end(); @@ -4114,7 +4132,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - std::vector const& deps = + std::vector const& deps = tgt->GetLinkImplementationClosure(config); if(deps.empty()) @@ -4141,7 +4159,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, } std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = + for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -4151,11 +4169,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, // target itself has a POSITION_INDEPENDENT_CODE which disagrees // with a dependency. - cmTarget const* theTarget = *li; + cmGeneratorTarget const* theTarget = *li; - const bool ifaceIsSet = theTarget->GetProperties() + const bool ifaceIsSet = theTarget->Target->GetProperties() .find(interfaceProperty) - != theTarget->GetProperties().end(); + != theTarget->Target->GetProperties().end(); PropertyType ifacePropContent = getTypedProperty(theTarget, interfaceProperty); @@ -4410,7 +4428,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector const& names, { continue; } - items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name))); + items.push_back(cmLinkItem(name, this->FindTargetToLink(name))); } } @@ -4473,7 +4491,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, return &hm.begin()->second; } - cmOptionalLinkInterface& iface = hm[head->Target]; + cmOptionalLinkInterface& iface = hm[head]; if(!iface.LibrariesDone) { iface.LibrariesDone = true; @@ -4625,7 +4643,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, return &hm.begin()->second; } - cmOptionalLinkInterface& iface = hm[head->Target]; + cmOptionalLinkInterface& iface = hm[head]; if(!iface.LibrariesDone) { iface.LibrariesDone = true; @@ -5062,7 +5080,7 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, return &hm.begin()->second; } - cmOptionalLinkInterface& iface = hm[headTarget->Target]; + cmOptionalLinkInterface& iface = hm[headTarget]; if(!iface.AllDone) { iface.AllDone = true; @@ -5381,7 +5399,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( - cmLinkImplItem(name, this->Target->FindTargetToLink(name), + cmLinkImplItem(name, this->FindTargetToLink(name), *btIt, evaluated != *le)); } @@ -5413,11 +5431,47 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back( - cmLinkItem(name, this->Target->FindTargetToLink(name))); + cmLinkItem(name, this->FindTargetToLink(name))); } } } +//---------------------------------------------------------------------------- +cmGeneratorTarget* +cmGeneratorTarget::FindTargetToLink(std::string const& name) const +{ + cmTarget const* tgt = this->Makefile->FindTargetToUse(name); + + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(tgt && tgt->GetType() == cmTarget::EXECUTABLE && + !tgt->IsExecutableWithExports()) + { + tgt = 0; + } + + if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY) + { + std::ostringstream e; + e << "Target \"" << this->GetName() << "\" links to " + "OBJECT library \"" << tgt->GetName() << "\" but this is not " + "allowed. " + "One may link only to STATIC or SHARED libraries, or to executables " + "with the ENABLE_EXPORTS property set."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->GetBacktrace()); + tgt = 0; + } + + if (!tgt) + { + return 0; + } + return this->GlobalGenerator->GetGeneratorTarget(tgt); +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const @@ -5429,3 +5483,47 @@ cmGeneratorTarget::GetPDBDirectory(const std::string& config) const } return ""; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasImplibGNUtoMS() const +{ + return this->HasImportLibrary() + && this->GetPropertyAsBool("GNUtoMS"); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName, + std::string& out, const char* newExt) const +{ + if(this->HasImplibGNUtoMS() && + gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") + { + out = gnuName.substr(0, gnuName.size()-6); + out += newExt? newExt : ".lib"; + return true; + } + return false; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasImportLibrary() const +{ + return (this->Target->IsDLLPlatform() && + (this->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->IsExecutableWithExports())); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSupportDirectory() const +{ + std::string dir = this->Makefile->GetCurrentBinaryDirectory(); + dir += cmake::GetCMakeFilesDirectory(); + dir += "/"; + dir += this->GetName(); +#if defined(__VMS) + dir += "_dir"; +#else + dir += ".dir"; +#endif + return dir; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 799110c4f..258c55629 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,8 @@ public: void GetExpectedXamlSources(std::set&, const std::string& config) const; + std::setconst& GetUtilityItems() const; + void ComputeObjectMapping(); const char* GetFeature(const std::string& feature, @@ -214,6 +216,8 @@ public: cmOptionalLinkImplementation& impl, const cmGeneratorTarget* head) const; + cmGeneratorTarget* FindTargetToLink(std::string const& name) const; + // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough @@ -386,6 +390,20 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; + /** Does this target have a GNU implib to convert to MS format? */ + bool HasImplibGNUtoMS() const; + + /** Convert the given GNU import library name (.dll.a) to a name with a new + extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ + bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, + const char* newExt = 0) const; + + /** Return whether or not the target has a DLL import library. */ + bool HasImportLibrary() const; + + /** Get a build-tree directory in which to place target support files. */ + std::string GetSupportDirectory() const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -473,7 +491,7 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); - struct LinkImplClosure: public std::vector + struct LinkImplClosure: public std::vector { LinkImplClosure(): Done(false) {} bool Done; @@ -537,6 +555,7 @@ private: typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; + mutable std::set UtilityItems; mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; @@ -544,13 +563,14 @@ private: mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; + mutable bool UtilityItemsDone; bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; public: - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; + const std::vector& + GetLinkImplementationClosure(const std::string& config) const; mutable std::map MaxLanguageStandards; std::map const& diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 765a53833..6750611d2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2893,13 +2893,14 @@ void cmGlobalGenerator::WriteSummary() { continue; } - this->WriteSummary(ti->second); - fout << ti->second->GetSupportDirectory() << "\n"; + cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second); + this->WriteSummary(gt); + fout << gt->GetSupportDirectory() << "\n"; } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::WriteSummary(cmTarget* target) +void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) { // Place the labels file in a per-target support directory. std::string dir = target->GetSupportDirectory(); @@ -2942,17 +2943,15 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) fout << "# Source files and their labels\n"; std::vector sources; std::vector configs; - target->GetMakefile()->GetConfigurations(configs); + target->Target->GetMakefile()->GetConfigurations(configs); if (configs.empty()) { configs.push_back(""); } - cmGeneratorTarget* gt = - this->GetGeneratorTarget(target); for(std::vector::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { - gt->GetSourceFiles(sources, *ci); + target->GetSourceFiles(sources, *ci); } std::vector::const_iterator sourcesEnd = cmRemoveDuplicates(sources); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b22c695b2..55e376669 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -458,7 +458,7 @@ private: void WriteRuleHashes(std::string const& pfile); void WriteSummary(); - void WriteSummary(cmTarget* target); + void WriteSummary(cmGeneratorTarget* target); void FinalizeTargetCompileInfo(); virtual void ForceLinkerLanguages(); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 2ea36fb86..c2a18af64 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -135,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -199,7 +199,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -387,7 +387,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, if(nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, + if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; @@ -416,7 +416,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, if(nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, + if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; @@ -563,12 +563,12 @@ cmInstallTargetGenerator std::map install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set const& sharedLibs + std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set::const_iterator j = sharedLibs.begin(); - j != sharedLibs.end(); ++j) + for(std::set::const_iterator j + = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget const* tgt = *j; + cmGeneratorTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) @@ -576,20 +576,17 @@ cmInstallTargetGenerator continue; } - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); - std::string for_install = gtgt->GetInstallNameDirForInstallTree(); + std::string for_build = tgt->GetInstallNameDirForBuildTree(config); + std::string for_install = tgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to // create the mapping. std::string fname = - this->GetInstallFilename(tgt, config, NameSO); + this->GetInstallFilename(tgt->Target, config, NameSO); // Map from the build-tree install_name. for_build += fname; diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 10dd465f8..b875cc03d 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -15,7 +15,7 @@ #include "cmListFileCache.h" -class cmTarget; +class cmGeneratorTarget; // Basic information about each link item. class cmLinkItem: public std::string @@ -24,9 +24,9 @@ class cmLinkItem: public std::string public: cmLinkItem(): std_string(), Target(0) {} cmLinkItem(const std_string& n, - cmTarget const* t): std_string(n), Target(t) {} + cmGeneratorTarget const* t): std_string(n), Target(t) {} cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} - cmTarget const* Target; + cmGeneratorTarget const* Target; }; class cmLinkImplItem: public cmLinkItem @@ -34,7 +34,7 @@ class cmLinkImplItem: public cmLinkItem public: cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} cmLinkImplItem(std::string const& n, - cmTarget const* t, + cmGeneratorTarget const* t, cmListFileBacktrace const& bt, bool fromGenex): cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} @@ -97,7 +97,7 @@ struct cmOptionalLinkInterface: public cmLinkInterface }; struct cmHeadToLinkInterfaceMap: - public std::map + public std::map { }; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index f6b907e24..2d2de5f47 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -259,7 +259,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { exeCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, @@ -361,7 +361,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.CMTarget = this->Target; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 3b3f63e2d..8b60a23b6 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { libCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, @@ -572,7 +572,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string name_of_def_file = - this->Target->GetSupportDirectory(); + this->GeneratorTarget->GetSupportDirectory(); name_of_def_file += std::string("/") + this->Target->GetName(); name_of_def_file += ".def"; @@ -643,7 +643,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.CMTarget = this->Target; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f17f66db6..4ddcac626 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -557,7 +557,8 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { - targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; + targetFullPathCompilePDB = + this->GeneratorTarget->GetSupportDirectory() + "/"; } } @@ -594,7 +595,7 @@ cmMakefileTargetGenerator cmLocalGenerator::NONE, cmLocalGenerator::SHELL); vars.Object = shellObj.c_str(); - std::string objectDir = this->Target->GetSupportDirectory(); + std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -1517,7 +1518,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( const std::string& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); - if(this->Target->HasImplibGNUtoMS()) + if(this->GeneratorTarget->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2a6c4149f..c64fe5063 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -492,9 +492,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() { if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { - std::string dllname = targetOutput; std::string name_of_def_file - = target.GetSupportDirectory(); + = gt.GetSupportDirectory(); name_of_def_file += "/" + target.GetName(); name_of_def_file += ".def "; vars["LINK_FLAGS"] += " /DEF:"; @@ -559,7 +558,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); - if(target.HasImportLibrary()) + if(genTarget.HasImportLibrary()) { byproducts.push_back(targetOutputImplib); } @@ -582,7 +581,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["TARGET_PDB"] = base + suffix + dbg_suffix; } - const std::string objPath = GetTarget()->GetSupportDirectory(); + const std::string objPath = GetGeneratorTarget()->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( this->ConvertToNinjaPath(objPath), cmLocalGenerator::SHELL); @@ -634,7 +633,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); std::string name_of_def_file - = target.GetSupportDirectory(); + = gt.GetSupportDirectory(); name_of_def_file += "/" + target.GetName(); name_of_def_file += ".def"; std::string cmd = cmakeCommand; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index dcd7bd80b..4080d9000 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -298,7 +298,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { - compilePdbPath = this->Target->GetSupportDirectory() + "/"; + compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/"; } } @@ -567,7 +567,7 @@ cmNinjaTargetGenerator std::string const language = source->GetLanguage(); std::string const sourceFileName = language=="RC" ? source->GetFullPath() : this->GetSourceFilePath(source); - std::string const objectDir = this->Target->GetSupportDirectory(); + std::string const objectDir = this->GeneratorTarget->GetSupportDirectory(); std::string const objectFileName = this->GetObjectFilePath(source); std::string const objectFileDir = cmSystemTools::GetFilenamePath(objectFileName); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 378f13254..6e3f65ff7 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -64,7 +64,7 @@ static void SetupSourceFiles(cmGeneratorTarget const* target, std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFile); - std::string rcc_output_dir = target->Target->GetSupportDirectory(); + std::string rcc_output_dir = target->GetSupportDirectory(); cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); std::string rcc_output_file = rcc_output_dir; rcc_output_file += "/qrc_" + basename + ".cpp"; @@ -833,7 +833,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFile); - std::string rcc_output_dir = target->Target->GetSupportDirectory(); + std::string rcc_output_dir = target->GetSupportDirectory(); cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); std::string rcc_output_file = rcc_output_dir; rcc_output_file += "/qrc_" + basename + ".cpp"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3de7efed2..b8beb5c29 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -67,12 +67,10 @@ public: cmTargetInternals() : Backtrace() { - this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace() { - this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -82,9 +80,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - std::set UtilityItems; - bool UtilityItemsDone; - std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -363,22 +358,6 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( return &i->second; } -//---------------------------------------------------------------------------- -std::set const& cmTarget::GetUtilityItems() const -{ - if(!this->Internal->UtilityItemsDone) - { - this->Internal->UtilityItemsDone = true; - for(std::set::const_iterator i = this->Utilities.begin(); - i != this->Utilities.end(); ++i) - { - this->Internal->UtilityItems.insert( - cmLinkItem(*i, this->Makefile->FindTargetToUse(*i))); - } - } - return this->Internal->UtilityItems; -} - //---------------------------------------------------------------------------- void cmTarget::FinishConfigure() { @@ -402,21 +381,6 @@ cmListFileBacktrace const& cmTarget::GetBacktrace() const return this->Internal->Backtrace; } -//---------------------------------------------------------------------------- -std::string cmTarget::GetSupportDirectory() const -{ - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); - dir += cmake::GetCMakeFilesDirectory(); - dir += "/"; - dir += this->Name; -#if defined(__VMS) - dir += "_dir"; -#else - dir += ".dir"; -#endif - return dir; -} - //---------------------------------------------------------------------------- bool cmTarget::IsExecutableWithExports() const { @@ -2219,26 +2183,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, vName += this->IsApple? suffix : std::string(); } -//---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() const -{ - return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) const -{ - if(this->HasImplibGNUtoMS() && - gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") - { - out = gnuName.substr(0, gnuName.size()-6); - out += newExt? newExt : ".lib"; - return true; - } - return false; -} - //---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) @@ -2690,37 +2634,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } -//---------------------------------------------------------------------------- -cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const -{ - cmTarget const* tgt = this->Makefile->FindTargetToUse(name); - - // Skip targets that will not really be linked. This is probably a - // name conflict between an external library and an executable - // within the project. - if(tgt && tgt->GetType() == cmTarget::EXECUTABLE && - !tgt->IsExecutableWithExports()) - { - tgt = 0; - } - - if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY) - { - std::ostringstream e; - e << "Target \"" << this->GetName() << "\" links to " - "OBJECT library \"" << tgt->GetName() << "\" but this is not " - "allowed. " - "One may link only to STATIC or SHARED libraries, or to executables " - "with the ENABLE_EXPORTS property set."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - tgt = 0; - } - - // Return the target found, if any. - return tgt; -} - //---------------------------------------------------------------------------- std::string cmTarget::CheckCMP0004(std::string const& item) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 16d01219a..01261ed52 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,7 +16,6 @@ #include "cmPropertyMap.h" #include "cmPolicies.h" #include "cmListFileCache.h" -#include "cmLinkItem.h" #include #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -206,7 +205,6 @@ public: void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::setconst& GetUtilities() const { return this->Utilities; } - std::setconst& GetUtilityItems() const; cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ @@ -225,8 +223,6 @@ public: void GetObjectLibrariesCMP0026(std::vector& objlibs) const; - cmTarget const* FindTargetToLink(std::string const& name) const; - /** Strip off leading and trailing whitespace from an item named in the link dependencies of this target. */ std::string CheckCMP0004(std::string const& item) const; @@ -244,14 +240,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS() const; - - /** Convert the given GNU import library name (.dll.a) to a name with a new - extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ - bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -274,9 +262,6 @@ public: /** Return whether or not the target is for a DLL platform. */ bool IsDLLPlatform() const { return this->DLLPlatform; } - /** Return whether or not the target has a DLL import library. */ - bool HasImportLibrary() const; - /** Return whether this target is a shared library Framework on Apple. */ bool IsFrameworkOnApple() const; @@ -297,9 +282,6 @@ public: /** Get a backtrace from the creation of the target. */ cmListFileBacktrace const& GetBacktrace() const; - /** Get a build-tree directory in which to place target support files. */ - std::string GetSupportDirectory() const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -475,6 +457,9 @@ private: void MaybeInvalidatePropertyCache(const std::string& prop); + /** Return whether or not the target has a DLL import library. */ + bool HasImportLibrary() const; + // Internal representation details. friend class cmTargetInternals; friend class cmGeneratorTarget;