From f9146f6b90d381a70bdb6a3c97742e3a53bb6235 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 16 Sep 2012 01:35:08 +0200 Subject: Port cmLocalGenerator::GetTargetFlags to cmGeneratorTarget. --- Source/cmLocalGenerator.cxx | 39 +++++++++++++------------- Source/cmLocalGenerator.h | 5 ++-- Source/cmMakefileExecutableTargetGenerator.cxx | 3 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmake.cxx | 3 +- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 006be05..c6dfed8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -679,7 +679,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, std::string linkLibs; // should be set std::string flags; // should be set std::string linkFlags; // should be set - this->GetTargetFlags(linkLibs, flags, linkFlags, *target.Target); + this->GetTargetFlags(linkLibs, flags, linkFlags, &target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; vars.Objects = objs.c_str(); @@ -1451,7 +1451,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& flags, std::string& linkFlags, - cmTarget& target) + cmGeneratorTarget* target) { std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -1459,12 +1459,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library - switch(target.GetType()) + switch(target->GetType()) { case cmTarget::STATIC_LIBRARY: { const char* targetLinkFlags = - target.GetProperty("STATIC_LIBRARY_FLAGS"); + target->GetProperty("STATIC_LIBRARY_FLAGS"); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1474,7 +1474,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string build = "STATIC_LIBRARY_FLAGS_"; build += buildType; - targetLinkFlags = target.GetProperty(build.c_str()); + targetLinkFlags = target->GetProperty(build.c_str()); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1500,7 +1500,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { - const std::vector& sources = target.GetSourceFiles(); + const std::vector& sources = target->GetSourceFiles(); for(std::vector::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -1515,7 +1515,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } } - const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); + const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1525,7 +1525,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1533,7 +1533,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } cmOStringStream linklibsStr; - this->OutputLinkLibraries(linklibsStr, target, false); + this->OutputLinkLibraries(linklibsStr, *target, false); linkLibs = linklibsStr.str(); } break; @@ -1549,17 +1549,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; } - const char* linkLanguage = target.GetLinkerLanguage(); + const char* linkLanguage = target->Target->GetLinkerLanguage(); if(!linkLanguage) { cmSystemTools::Error ("CMake can not determine linker language for target:", - target.GetName()); + target->Target->GetName()); return; } this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, target, false); + this->OutputLinkLibraries(linklibs, *target, false); linkLibs = linklibs.str(); if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) @@ -1569,7 +1569,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; } - if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) + if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") ) { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); @@ -1581,7 +1581,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } - if (target.IsExecutableWithExports()) + if (target->Target->IsExecutableWithExports()) { std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; exportFlagVar += linkLanguage; @@ -1591,7 +1591,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition(exportFlagVar.c_str()); linkFlags += " "; } - const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); + const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1601,7 +1601,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1653,12 +1653,11 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) * to the name of the library. This will not link a library against itself. */ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, - cmTarget& tgt, + cmGeneratorTarget& tgt, bool relink) { const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(&tgt); - cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; @@ -1679,7 +1678,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; linkFlagsVar += linkLanguage; linkFlagsVar += "_FLAGS"; - if( gtgt->GetType() == cmTarget::EXECUTABLE ) + if( tgt.GetType() == cmTarget::EXECUTABLE ) { linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); linkLibs += " "; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index e371e40..6ab8067 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -335,11 +335,12 @@ public: void GetTargetFlags(std::string& linkLibs, std::string& flags, std::string& linkFlags, - cmTarget&target); + cmGeneratorTarget* target); protected: ///! put all the libraries for a target on into the given stream - virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); + virtual void OutputLinkLibraries(std::ostream&, cmGeneratorTarget&, + bool relink); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index d1c5b62..ca5f26a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -319,7 +319,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Collect up flags to link in needed libraries. cmOStringStream linklibs; - this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink); + this->LocalGenerator->OutputLinkLibraries(linklibs, *this->GeneratorTarget, + relink); // Construct object file lists that may be needed to expand the // rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index cc7d9c7..368d6fc 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -546,7 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { this->LocalGenerator - ->OutputLinkLibraries(linklibs, *this->Target, relink); + ->OutputLinkLibraries(linklibs, *this->GeneratorTarget, relink); } // Construct object file lists that may be needed to expand the diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 082e9f3..6f991e2 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -423,7 +423,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], - *this->GetTarget()); + this->GetGeneratorTarget()); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c6787b9..e559fe0 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -630,7 +630,8 @@ bool cmake::FindPackage(const std::vector& args) std::string linkLibs; std::string flags; std::string linkFlags; - lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); + cmGeneratorTarget gtgt(tgt); + lg->GetTargetFlags(linkLibs, flags, linkFlags, >gt); printf("%s\n", linkLibs.c_str() ); -- cgit v0.12