mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
cmLocalGenerator: Adopt AppendModuleDefinitionFlag method
Migrate from `cmCommonTargetGenerator::AddModuleDefinitionFlag`.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalCommonGenerator.h"
|
||||
#include "cmLinkLineComputer.h"
|
||||
#include "cmLocalCommonGenerator.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
@@ -47,33 +46,6 @@ cmValue cmCommonTargetGenerator::GetFeature(const std::string& feature,
|
||||
return this->GeneratorTarget->GetFeature(feature, config);
|
||||
}
|
||||
|
||||
void cmCommonTargetGenerator::AddModuleDefinitionFlag(
|
||||
cmLinkLineComputer* linkLineComputer, std::string& flags,
|
||||
const std::string& config)
|
||||
{
|
||||
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
|
||||
this->GeneratorTarget->GetModuleDefinitionInfo(config);
|
||||
if (!mdi || mdi->DefFile.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Create a per-language flag variable.
|
||||
cmValue defFileFlag =
|
||||
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
if (!defFileFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Append the flag and value. Use ConvertToLinkReference to help
|
||||
// vs6's "cl -link" pass it to the linker.
|
||||
std::string flag =
|
||||
cmStrCat(*defFileFlag,
|
||||
this->LocalCommonGenerator->ConvertToOutputFormat(
|
||||
linkLineComputer->ConvertToLinkReference(mdi->DefFile),
|
||||
cmOutputConverter::SHELL));
|
||||
this->LocalCommonGenerator->AppendFlags(flags, flag);
|
||||
}
|
||||
|
||||
void cmCommonTargetGenerator::AppendFortranFormatFlags(
|
||||
std::string& flags, cmSourceFile const& source)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
class cmGeneratorTarget;
|
||||
class cmGlobalCommonGenerator;
|
||||
class cmLinkLineComputer;
|
||||
class cmLocalCommonGenerator;
|
||||
class cmMakefile;
|
||||
class cmSourceFile;
|
||||
@@ -33,10 +32,6 @@ protected:
|
||||
// Feature query methods.
|
||||
cmValue GetFeature(const std::string& feature, const std::string& config);
|
||||
|
||||
// Helper to add flag for windows .def file.
|
||||
void AddModuleDefinitionFlag(cmLinkLineComputer* linkLineComputer,
|
||||
std::string& flags, const std::string& config);
|
||||
|
||||
cmGeneratorTarget* GeneratorTarget;
|
||||
cmMakefile* Makefile;
|
||||
cmLocalCommonGenerator* LocalCommonGenerator;
|
||||
|
||||
@@ -3137,6 +3137,32 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags(
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AppendModuleDefinitionFlag(
|
||||
std::string& flags, cmGeneratorTarget const* target,
|
||||
cmLinkLineComputer* linkLineComputer, std::string const& config)
|
||||
{
|
||||
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
|
||||
target->GetModuleDefinitionInfo(config);
|
||||
if (!mdi || mdi->DefFile.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
cmValue defFileFlag =
|
||||
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
if (!defFileFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Append the flag and value. Use ConvertToLinkReference to help
|
||||
// vs6's "cl -link" pass it to the linker.
|
||||
std::string flag =
|
||||
cmStrCat(*defFileFlag,
|
||||
this->ConvertToOutputFormat(
|
||||
linkLineComputer->ConvertToLinkReference(mdi->DefFile),
|
||||
cmOutputConverter::SHELL));
|
||||
this->AppendFlags(flags, flag);
|
||||
}
|
||||
|
||||
bool cmLocalGenerator::AppendLWYUFlags(std::string& flags,
|
||||
const cmGeneratorTarget* target,
|
||||
const std::string& lang)
|
||||
|
||||
@@ -178,6 +178,10 @@ public:
|
||||
cmGeneratorTarget* target,
|
||||
const std::string& config,
|
||||
const std::string& lang);
|
||||
void AppendModuleDefinitionFlag(std::string& flags,
|
||||
cmGeneratorTarget const* target,
|
||||
cmLinkLineComputer* linkLineComputer,
|
||||
std::string const& config);
|
||||
bool AppendLWYUFlags(std::string& flags, const cmGeneratorTarget* target,
|
||||
const std::string& lang);
|
||||
|
||||
|
||||
@@ -407,8 +407,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
||||
this->LocalGenerator,
|
||||
this->LocalGenerator->GetStateSnapshot().GetDirectory());
|
||||
|
||||
this->AddModuleDefinitionFlag(linkLineComputer.get(), linkFlags,
|
||||
this->GetConfigName());
|
||||
this->LocalGenerator->AppendModuleDefinitionFlag(
|
||||
linkFlags, this->GeneratorTarget, linkLineComputer.get(),
|
||||
this->GetConfigName());
|
||||
}
|
||||
|
||||
this->LocalGenerator->AppendIPOLinkerFlags(
|
||||
|
||||
@@ -175,8 +175,9 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
||||
this->LocalGenerator,
|
||||
this->LocalGenerator->GetStateSnapshot().GetDirectory());
|
||||
|
||||
this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags,
|
||||
this->GetConfigName());
|
||||
this->LocalGenerator->AppendModuleDefinitionFlag(
|
||||
extraFlags, this->GeneratorTarget, linkLineComputer.get(),
|
||||
this->GetConfigName());
|
||||
|
||||
this->UseLWYU = this->LocalGenerator->AppendLWYUFlags(
|
||||
extraFlags, this->GeneratorTarget, linkLanguage);
|
||||
@@ -209,8 +210,9 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
||||
this->LocalGenerator,
|
||||
this->LocalGenerator->GetStateSnapshot().GetDirectory());
|
||||
|
||||
this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags,
|
||||
this->GetConfigName());
|
||||
this->LocalGenerator->AppendModuleDefinitionFlag(
|
||||
extraFlags, this->GeneratorTarget, linkLineComputer.get(),
|
||||
this->GetConfigName());
|
||||
|
||||
this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
|
||||
}
|
||||
|
||||
@@ -1164,8 +1164,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
|
||||
this->addPoolNinjaVariable("JOB_POOL_LINK", gt, vars);
|
||||
|
||||
this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"],
|
||||
config);
|
||||
localGen.AppendModuleDefinitionFlag(vars["LINK_FLAGS"], gt,
|
||||
linkLineComputer.get(), config);
|
||||
|
||||
this->UseLWYU = this->GetLocalGenerator()->AppendLWYUFlags(
|
||||
vars["LINK_FLAGS"], this->GetGeneratorTarget(),
|
||||
|
||||
Reference in New Issue
Block a user