Refactor `.def` file lookup

Return a `cmSourceFile const*` from GetModuleDefinitionFile so that
callers can get more information than just the path to the file.
This commit is contained in:
Tim Grothe 2015-11-02 15:24:25 +01:00 committed by Brad King
parent adfc8a677e
commit 247c168b98
7 changed files with 23 additions and 15 deletions

View File

@ -81,7 +81,7 @@ void cmCommonTargetGenerator::AddFeatureFlags(
//----------------------------------------------------------------------------
void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
if(this->ModuleDefinitionFile.empty())
if(!this->ModuleDefinitionFile)
{
return;
}
@ -98,7 +98,7 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference(
this->ModuleDefinitionFile));
this->ModuleDefinitionFile->GetFullPath()));
this->LocalGenerator->AppendFlags(flags, flag);
}

View File

@ -54,7 +54,7 @@ protected:
std::string ConfigName;
// The windows module definition source file (.def), if any.
std::string ModuleDefinitionFile;
cmSourceFile const* ModuleDefinitionFile;
// Target-wide Fortran module output directory.
bool FortranModuleDirectoryComputed;

View File

@ -2095,12 +2095,18 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
}
//----------------------------------------------------------------------------
std::string
cmSourceFile const*
cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const
{
std::string data;
IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string)
return data;
std::vector<cmSourceFile const*> data;
IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile,
COMMA std::vector<cmSourceFile const*>)
if(!data.empty())
{
return data.front();
}
return 0;
}
bool cmGeneratorTarget::IsDLLPlatform() const

View File

@ -220,7 +220,7 @@ public:
cmLocalGenerator* LocalGenerator;
cmGlobalGenerator const* GlobalGenerator;
std::string GetModuleDefinitionFile(const std::string& config) const;
cmSourceFile const* GetModuleDefinitionFile(const std::string& config) const;
/** Return whether or not the target is for a DLL platform. */
bool IsDLLPlatform() const;

View File

@ -1497,9 +1497,9 @@ void cmMakefileTargetGenerator
this->AppendTargetDepends(depends);
// Add a dependency on the link definitions file, if any.
if(!this->ModuleDefinitionFile.empty())
if(this->ModuleDefinitionFile)
{
depends.push_back(this->ModuleDefinitionFile);
depends.push_back(this->ModuleDefinitionFile->GetFullPath());
}
// Add a dependency on user-specified manifest files, if any.

View File

@ -195,9 +195,10 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath());
// Add a dependency on the link definitions file, if any.
if(!this->ModuleDefinitionFile.empty())
if(this->ModuleDefinitionFile)
{
result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile));
result.push_back(this->ConvertToNinjaPath(
this->ModuleDefinitionFile->GetFullPath()));
}
// Add a dependency on user-specified manifest files, if any.

View File

@ -2642,10 +2642,11 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
if(this->MSTools)
{
std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
if(!def.empty())
if (cmSourceFile const* defsrc =
this->GeneratorTarget->GetModuleDefinitionFile(""))
{
linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
linkOptions.AddFlag("ModuleDefinitionFile",
defsrc->GetFullPath().c_str());
}
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries",
"%(IgnoreSpecificDefaultLibraries)");