cmTarget: Move link type enum out.

Remove a reason for generate time code to depend on the cmTarget header/type.
This commit is contained in:
Stephen Kelly 2015-10-10 13:56:36 +02:00
parent 2ee1cb85e8
commit 482b3811e4
15 changed files with 72 additions and 67 deletions

View File

@ -373,13 +373,13 @@ void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt,
switch (libtype)
{
case CM_LIBRARY_GENERAL:
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::GENERAL);
mf->AddLinkLibraryForTarget(tgt,value, GENERAL_LibraryType);
break;
case CM_LIBRARY_DEBUG:
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::DEBUG);
mf->AddLinkLibraryForTarget(tgt,value, DEBUG_LibraryType);
break;
case CM_LIBRARY_OPTIMIZED:
mf->AddLinkLibraryForTarget(tgt,value, cmTarget::OPTIMIZED);
mf->AddLinkLibraryForTarget(tgt,value, OPTIMIZED_LibraryType);
break;
}
}

View File

@ -482,24 +482,24 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// Look for entries meant for this configuration.
std::vector<cmLinkItem> actual_libs;
cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
bool haveLLT = false;
for(std::vector<std::string>::const_iterator di = deplist.begin();
di != deplist.end(); ++di)
{
if(*di == "debug")
{
llt = cmTarget::DEBUG;
llt = DEBUG_LibraryType;
haveLLT = true;
}
else if(*di == "optimized")
{
llt = cmTarget::OPTIMIZED;
llt = OPTIMIZED_LibraryType;
haveLLT = true;
}
else if(*di == "general")
{
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
haveLLT = true;
}
else if(!di->empty())
@ -517,17 +517,17 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
{
if(strcmp(val, "debug") == 0)
{
llt = cmTarget::DEBUG;
llt = DEBUG_LibraryType;
}
else if(strcmp(val, "optimized") == 0)
{
llt = cmTarget::OPTIMIZED;
llt = OPTIMIZED_LibraryType;
}
}
}
// If the library is meant for this link type then use it.
if(llt == cmTarget::GENERAL || llt == this->LinkType)
if(llt == GENERAL_LibraryType || llt == this->LinkType)
{
cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
actual_libs.push_back(item);
@ -539,7 +539,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
}
// Reset the link type until another explicit type is given.
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
haveLLT = false;
}
}

View File

@ -155,7 +155,7 @@ private:
void CheckWrongConfigItem(cmLinkItem const& item);
int ComponentOrderId;
cmTarget::LinkLibraryType LinkType;
cmTargetLinkLibraryType LinkType;
bool HasConfig;
bool DebugMode;
bool OldLinkDirMode;

View File

@ -120,15 +120,15 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
std::string ltValue;
switch(li->second)
{
case cmTarget::GENERAL:
case GENERAL_LibraryType:
valueNew += "general;";
ltValue = "general";
break;
case cmTarget::DEBUG:
case DEBUG_LibraryType:
valueNew += "debug;";
ltValue = "debug";
break;
case cmTarget::OPTIMIZED:
case OPTIMIZED_LibraryType:
valueNew += "optimized;";
ltValue = "optimized";
break;

View File

@ -5416,13 +5416,13 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
this->MaxLanguageStandards);
}
cmTarget::LinkLibraryType linkType = this->Target->ComputeLinkType(config);
cmTargetLinkLibraryType linkType = this->Target->ComputeLinkType(config);
cmTarget::LinkLibraryVectorType const& oldllibs =
this->Target->GetOriginalLinkLibraries();
for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
li != oldllibs.end(); ++li)
{
if(li->second != cmTarget::GENERAL && li->second != linkType)
if(li->second != GENERAL_LibraryType && li->second != linkType)
{
std::string name = this->Target->CheckCMP0004(li->first);
if(name == this->GetName() || name.empty())

View File

@ -34,7 +34,7 @@ bool cmLinkLibrariesCommand
return false;
}
this->Makefile->AddLinkLibrary(*i,
cmTarget::DEBUG);
DEBUG_LibraryType);
}
else if (*i == "optimized")
{
@ -46,7 +46,7 @@ bool cmLinkLibrariesCommand
return false;
}
this->Makefile->AddLinkLibrary(*i,
cmTarget::OPTIMIZED);
OPTIMIZED_LibraryType);
}
else
{

View File

@ -1145,7 +1145,7 @@ void cmLocalVisualStudio6Generator
libDebug =
this->ConvertToOutputFormat(libDebug.c_str(), SHELL);
if (j->second == cmTarget::GENERAL)
if (j->second == GENERAL_LibraryType)
{
libOptions += " ";
libOptions += lib;
@ -1156,7 +1156,7 @@ void cmLocalVisualStudio6Generator
libMultiLineOptionsForDebug += libDebug;
libMultiLineOptionsForDebug += "\n";
}
if (j->second == cmTarget::DEBUG)
if (j->second == DEBUG_LibraryType)
{
libDebugOptions += " ";
libDebugOptions += lib;
@ -1165,7 +1165,7 @@ void cmLocalVisualStudio6Generator
libMultiLineDebugOptions += libDebug;
libMultiLineDebugOptions += "\n";
}
if (j->second == cmTarget::OPTIMIZED)
if (j->second == OPTIMIZED_LibraryType)
{
libOptimizedOptions += " ";
libOptimizedOptions += lib;

View File

@ -1400,7 +1400,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
}
void cmMakefile::AddLinkLibrary(const std::string& lib,
cmTarget::LinkLibraryType llt)
cmTargetLinkLibraryType llt)
{
cmTarget::LibraryID tmp;
tmp.first = lib;
@ -1410,7 +1410,7 @@ void cmMakefile::AddLinkLibrary(const std::string& lib,
void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
const std::string& lib,
cmTarget::LinkLibraryType llt)
cmTargetLinkLibraryType llt)
{
cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end())
@ -1471,7 +1471,7 @@ void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
void cmMakefile::AddLinkLibrary(const std::string& lib)
{
this->AddLinkLibrary(lib,cmTarget::GENERAL);
this->AddLinkLibrary(lib,GENERAL_LibraryType);
}
void cmMakefile::InitializeFromParent(cmMakefile* parent)

View File

@ -219,9 +219,9 @@ public:
* Add a link library to the build.
*/
void AddLinkLibrary(const std::string&);
void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
void AddLinkLibrary(const std::string&, cmTargetLinkLibraryType type);
void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
cmTarget::LinkLibraryType type);
cmTargetLinkLibraryType type);
void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
/**

View File

@ -123,4 +123,10 @@ static thisClass* SafeDownCast(cmObject *c) \
} \
class cmTypeMacro_UseTrailingSemicolon
enum cmTargetLinkLibraryType {
GENERAL_LibraryType,
DEBUG_LibraryType,
OPTIMIZED_LibraryType
};
#endif

View File

@ -632,13 +632,13 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const
}
//----------------------------------------------------------------------------
cmTarget::LinkLibraryType cmTarget::ComputeLinkType(
cmTargetLinkLibraryType cmTarget::ComputeLinkType(
const std::string& config) const
{
// No configuration is always optimized.
if(config.empty())
{
return cmTarget::OPTIMIZED;
return OPTIMIZED_LibraryType;
}
// Get the list of configurations considered to be DEBUG.
@ -650,10 +650,10 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(
if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
debugConfigs.end())
{
return cmTarget::DEBUG;
return DEBUG_LibraryType;
}
// The current configuration is not a debug configuration.
return cmTarget::OPTIMIZED;
return OPTIMIZED_LibraryType;
}
//----------------------------------------------------------------------------
@ -693,9 +693,9 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) const
//----------------------------------------------------------------------------
std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt) const
cmTargetLinkLibraryType llt) const
{
if (llt == GENERAL)
if (llt == GENERAL_LibraryType)
{
return value;
}
@ -716,7 +716,7 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
configString = "$<OR:" + configString + ">";
}
if (llt == OPTIMIZED)
if (llt == OPTIMIZED_LibraryType)
{
configString = "$<NOT:" + configString + ">";
}
@ -773,13 +773,14 @@ void cmTarget::GetTllSignatureTraces(std::ostringstream &s,
void cmTarget::AddLinkLibrary(cmMakefile& mf,
const std::string& target,
const std::string& lib,
LinkLibraryType llt)
cmTargetLinkLibraryType llt)
{
cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
{
const bool isNonImportedTarget = tgt && !tgt->IsImported();
const std::string libName = (isNonImportedTarget && llt != GENERAL)
const std::string libName =
(isNonImportedTarget && llt != GENERAL_LibraryType)
? targetNameGenex(lib)
: lib;
this->AppendProperty("LINK_LIBRARIES",
@ -822,13 +823,13 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
}
switch (llt)
{
case cmTarget::GENERAL:
case GENERAL_LibraryType:
dependencies += "general";
break;
case cmTarget::DEBUG:
case DEBUG_LibraryType:
dependencies += "debug";
break;
case cmTarget::OPTIMIZED:
case OPTIMIZED_LibraryType:
dependencies += "optimized";
break;
}
@ -1162,7 +1163,7 @@ void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf,
// Parse the dependency information, which is a set of
// type, library pairs separated by ";". There is always a trailing ";".
cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
std::string depline = deps;
std::string::size_type start = 0;
std::string::size_type end;
@ -1174,22 +1175,22 @@ void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf,
{
if (l == "debug")
{
llt = cmTarget::DEBUG;
llt = DEBUG_LibraryType;
}
else if (l == "optimized")
{
llt = cmTarget::OPTIMIZED;
llt = OPTIMIZED_LibraryType;
}
else if (l == "general")
{
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
}
else
{
LibraryID lib2(l,llt);
this->InsertDependencyForVS6( dep_map, lib, lib2);
this->GatherDependenciesForVS6( mf, lib2, dep_map);
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
}
}
start = end+1; // skip the ;

View File

@ -140,17 +140,15 @@ public:
cmSourceFile* AddSourceCMP0049(const std::string& src);
cmSourceFile* AddSource(const std::string& src);
enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
//* how we identify a library, by name and type
typedef std::pair<std::string, LinkLibraryType> LibraryID;
typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID;
typedef std::vector<LibraryID > LinkLibraryVectorType;
const LinkLibraryVectorType &GetOriginalLinkLibraries() const
{return this->OriginalLinkLibraries;}
/** Compute the link type to use for the given configuration. */
LinkLibraryType ComputeLinkType(const std::string& config) const;
cmTargetLinkLibraryType ComputeLinkType(const std::string& config) const;
/**
* Clear the dependency information recorded for this target, if any.
@ -161,7 +159,7 @@ public:
bool NameResolvesToFramework(const std::string& libname) const;
void AddLinkLibrary(cmMakefile& mf,
const std::string& target, const std::string& lib,
LinkLibraryType llt);
cmTargetLinkLibraryType llt);
enum TLLSignature {
KeywordTLLSignature,
PlainTLLSignature
@ -297,7 +295,7 @@ public:
void AppendBuildInterfaceIncludes();
std::string GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt) const;
cmTargetLinkLibraryType llt) const;
void AddSystemIncludeDirectories(const std::set<std::string> &incs);
std::set<std::string> const & GetSystemIncludeDirectories() const

View File

@ -136,7 +136,7 @@ bool cmTargetLinkLibrariesCommand
}
// Keep track of link configuration specifiers.
cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
bool haveLLT = false;
// Start with primary linking and switch to link interface
@ -242,27 +242,27 @@ bool cmTargetLinkLibrariesCommand
{
if(haveLLT)
{
this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::DEBUG);
this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType);
}
llt = cmTarget::DEBUG;
llt = DEBUG_LibraryType;
haveLLT = true;
}
else if(args[i] == "optimized")
{
if(haveLLT)
{
this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::OPTIMIZED);
this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType);
}
llt = cmTarget::OPTIMIZED;
llt = OPTIMIZED_LibraryType;
haveLLT = true;
}
else if(args[i] == "general")
{
if(haveLLT)
{
this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::GENERAL);
this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType);
}
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
haveLLT = true;
}
else if(haveLLT)
@ -282,7 +282,7 @@ bool cmTargetLinkLibrariesCommand
// specifed that a library is both debug and optimized. (this check is
// only there for backwards compatibility when mixing projects built
// with old versions of CMake and new)
llt = cmTarget::GENERAL;
llt = GENERAL_LibraryType;
std::string linkType = args[0];
linkType += "_LINK_TYPE";
const char* linkTypeString =
@ -291,11 +291,11 @@ bool cmTargetLinkLibrariesCommand
{
if(strcmp(linkTypeString, "debug") == 0)
{
llt = cmTarget::DEBUG;
llt = DEBUG_LibraryType;
}
if(strcmp(linkTypeString, "optimized") == 0)
{
llt = cmTarget::OPTIMIZED;
llt = OPTIMIZED_LibraryType;
}
}
if (!this->HandleLibrary(args[i], llt))
@ -350,7 +350,7 @@ cmTargetLinkLibrariesCommand
//----------------------------------------------------------------------------
bool
cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
cmTarget::LinkLibraryType llt)
cmTargetLinkLibraryType llt)
{
if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY
&& this->CurrentProcessingState != ProcessingKeywordLinkInterface)
@ -469,7 +469,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
std::string prop;
// Include this library in the link interface for the target.
if(llt == cmTarget::DEBUG || llt == cmTarget::GENERAL)
if(llt == DEBUG_LibraryType || llt == GENERAL_LibraryType)
{
// Put in the DEBUG configuration interfaces.
for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
@ -480,7 +480,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
this->Target->AppendProperty(prop, lib.c_str());
}
}
if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL)
if(llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType)
{
// Put in the non-DEBUG configuration interfaces.
this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str());

View File

@ -62,7 +62,7 @@ private:
ProcessingState CurrentProcessingState;
bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt);
bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt);
};

View File

@ -477,7 +477,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
++libIt)
{
mf->AddLinkLibraryForTarget(targetName, *libIt,
cmTarget::GENERAL);
GENERAL_LibraryType);
}