cmCommonTargetGenerator: Adopt ModuleDefinitionFile member
De-duplicate the ModuleDefinitionFile and AddModuleDefinitionFlag members from the Makefile and Ninja target generators.
This commit is contained in:
parent
beee793732
commit
cdb5b65752
@ -14,6 +14,7 @@
|
|||||||
#include "cmGeneratorTarget.h"
|
#include "cmGeneratorTarget.h"
|
||||||
#include "cmGlobalCommonGenerator.h"
|
#include "cmGlobalCommonGenerator.h"
|
||||||
#include "cmLocalCommonGenerator.h"
|
#include "cmLocalCommonGenerator.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
|
|
||||||
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
|
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
|
||||||
@ -24,6 +25,7 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
|
|||||||
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
|
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
|
||||||
gt->LocalGenerator->GetGlobalGenerator()))
|
gt->LocalGenerator->GetGlobalGenerator()))
|
||||||
, ConfigName(LocalGenerator->GetConfigName())
|
, ConfigName(LocalGenerator->GetConfigName())
|
||||||
|
, ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,3 +63,27 @@ void cmCommonTargetGenerator::AddFeatureFlags(
|
|||||||
this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
|
this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
|
||||||
|
{
|
||||||
|
if(this->ModuleDefinitionFile.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Create a per-language flag variable.
|
||||||
|
const char* 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 = defFileFlag;
|
||||||
|
flag += (this->LocalGenerator->ConvertToLinkReference(
|
||||||
|
this->ModuleDefinitionFile));
|
||||||
|
this->LocalGenerator->AppendFlags(flags, flag);
|
||||||
|
}
|
||||||
|
@ -40,12 +40,18 @@ protected:
|
|||||||
const char* GetFeature(const std::string& feature);
|
const char* GetFeature(const std::string& feature);
|
||||||
bool GetFeatureAsBool(const std::string& feature);
|
bool GetFeatureAsBool(const std::string& feature);
|
||||||
|
|
||||||
|
// Helper to add flag for windows .def file.
|
||||||
|
void AddModuleDefinitionFlag(std::string& flags);
|
||||||
|
|
||||||
cmGeneratorTarget* GeneratorTarget;
|
cmGeneratorTarget* GeneratorTarget;
|
||||||
cmTarget* Target;
|
cmTarget* Target;
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
cmLocalCommonGenerator* LocalGenerator;
|
cmLocalCommonGenerator* LocalGenerator;
|
||||||
cmGlobalCommonGenerator* GlobalGenerator;
|
cmGlobalCommonGenerator* GlobalGenerator;
|
||||||
std::string ConfigName;
|
std::string ConfigName;
|
||||||
|
|
||||||
|
// The windows module definition source file (.def), if any.
|
||||||
|
std::string ModuleDefinitionFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
|
|
||||||
|
class cmCommonTargetGenerator;
|
||||||
|
|
||||||
/** \class cmLocalCommonGenerator
|
/** \class cmLocalCommonGenerator
|
||||||
* \brief Common infrastructure for Makefile and Ninja local generators.
|
* \brief Common infrastructure for Makefile and Ninja local generators.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +32,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void SetConfigName();
|
void SetConfigName();
|
||||||
std::string ConfigName;
|
std::string ConfigName;
|
||||||
|
|
||||||
|
friend class cmCommonTargetGenerator;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1668,11 +1668,9 @@ void cmMakefileTargetGenerator
|
|||||||
this->AppendTargetDepends(depends);
|
this->AppendTargetDepends(depends);
|
||||||
|
|
||||||
// Add a dependency on the link definitions file, if any.
|
// Add a dependency on the link definitions file, if any.
|
||||||
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
|
if(!this->ModuleDefinitionFile.empty())
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
|
||||||
if(!def.empty())
|
|
||||||
{
|
{
|
||||||
depends.push_back(def);
|
depends.push_back(this->ModuleDefinitionFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add user-specified dependencies.
|
// Add user-specified dependencies.
|
||||||
@ -2074,28 +2072,3 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
|
|
||||||
{
|
|
||||||
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
|
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
|
||||||
if(def.empty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Create a per-language flag variable.
|
|
||||||
const char* 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 = defFileFlag;
|
|
||||||
flag += (this->LocalGenerator->ConvertToLinkReference(def));
|
|
||||||
this->LocalGenerator->AppendFlags(flags, flag);
|
|
||||||
}
|
|
||||||
|
@ -255,9 +255,6 @@ protected:
|
|||||||
// Compute target-specific Fortran language flags.
|
// Compute target-specific Fortran language flags.
|
||||||
void AddFortranFlags(std::string& flags);
|
void AddFortranFlags(std::string& flags);
|
||||||
|
|
||||||
// Helper to add flag for windows .def file.
|
|
||||||
void AddModuleDefinitionFlag(std::string& flags);
|
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
// Convenience routines that do nothing more than forward to
|
// Convenience routines that do nothing more than forward to
|
||||||
// implementaitons
|
// implementaitons
|
||||||
|
@ -244,7 +244,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
|
|||||||
// Add a dependency on the link definitions file, if any.
|
// Add a dependency on the link definitions file, if any.
|
||||||
if(!this->ModuleDefinitionFile.empty())
|
if(!this->ModuleDefinitionFile.empty())
|
||||||
{
|
{
|
||||||
result.push_back(this->ModuleDefinitionFile);
|
result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -574,11 +574,6 @@ cmNinjaTargetGenerator
|
|||||||
{
|
{
|
||||||
this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty());
|
this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty());
|
||||||
}
|
}
|
||||||
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
|
|
||||||
if(!def.empty())
|
|
||||||
{
|
|
||||||
this->ModuleDefinitionFile = this->ConvertToNinjaPath(def);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->GetBuildFileStream() << "\n";
|
this->GetBuildFileStream() << "\n";
|
||||||
}
|
}
|
||||||
@ -728,32 +723,6 @@ cmNinjaTargetGenerator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void
|
|
||||||
cmNinjaTargetGenerator
|
|
||||||
::AddModuleDefinitionFlag(std::string& flags)
|
|
||||||
{
|
|
||||||
if(this->ModuleDefinitionFile.empty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Create a per-language flag variable.
|
|
||||||
const char* 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 = defFileFlag;
|
|
||||||
flag += (this->LocalGenerator->ConvertToLinkReference(
|
|
||||||
this->ModuleDefinitionFile));
|
|
||||||
this->LocalGenerator->AppendFlags(flags, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmNinjaTargetGenerator
|
cmNinjaTargetGenerator
|
||||||
::EnsureDirectoryExists(const std::string& path) const
|
::EnsureDirectoryExists(const std::string& path) const
|
||||||
|
@ -115,9 +115,6 @@ protected:
|
|||||||
cmNinjaDeps GetObjects() const
|
cmNinjaDeps GetObjects() const
|
||||||
{ return this->Objects; }
|
{ return this->Objects; }
|
||||||
|
|
||||||
// Helper to add flag for windows .def file.
|
|
||||||
void AddModuleDefinitionFlag(std::string& flags);
|
|
||||||
|
|
||||||
void EnsureDirectoryExists(const std::string& dir) const;
|
void EnsureDirectoryExists(const std::string& dir) const;
|
||||||
void EnsureParentDirectoryExists(const std::string& path) const;
|
void EnsureParentDirectoryExists(const std::string& path) const;
|
||||||
|
|
||||||
@ -153,9 +150,6 @@ private:
|
|||||||
|
|
||||||
typedef std::map<std::string, std::string> LanguageFlagMap;
|
typedef std::map<std::string, std::string> LanguageFlagMap;
|
||||||
LanguageFlagMap LanguageFlags;
|
LanguageFlagMap LanguageFlags;
|
||||||
|
|
||||||
// The windows module definition source file (.def), if any.
|
|
||||||
std::string ModuleDefinitionFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! cmNinjaTargetGenerator_h
|
#endif // ! cmNinjaTargetGenerator_h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user