ENH: add support for per config target LINK_FLAGS
This commit is contained in:
parent
32b63ef915
commit
3c8e899102
@ -1045,6 +1045,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||||||
{
|
{
|
||||||
linkFlags += targetLinkFlags;
|
linkFlags += targetLinkFlags;
|
||||||
linkFlags += " ";
|
linkFlags += " ";
|
||||||
|
std::string configLinkFlags = targetLinkFlags;
|
||||||
|
configLinkFlags += buildType;
|
||||||
|
targetLinkFlags = target.GetProperty(configLinkFlags.c_str());
|
||||||
|
if(targetLinkFlags)
|
||||||
|
{
|
||||||
|
linkFlags += targetLinkFlags;
|
||||||
|
linkFlags += " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmOStringStream linklibsStr;
|
cmOStringStream linklibsStr;
|
||||||
this->OutputLinkLibraries(linklibsStr, target, false);
|
this->OutputLinkLibraries(linklibsStr, target, false);
|
||||||
@ -1103,7 +1111,15 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||||||
if(targetLinkFlags)
|
if(targetLinkFlags)
|
||||||
{
|
{
|
||||||
linkFlags += targetLinkFlags;
|
linkFlags += targetLinkFlags;
|
||||||
linkFlags += " ";
|
linkFlags += " ";
|
||||||
|
std::string configLinkFlags = targetLinkFlags;
|
||||||
|
configLinkFlags += buildType;
|
||||||
|
targetLinkFlags = target.GetProperty(configLinkFlags.c_str());
|
||||||
|
if(targetLinkFlags)
|
||||||
|
{
|
||||||
|
linkFlags += targetLinkFlags;
|
||||||
|
linkFlags += " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1062,7 +1062,6 @@ void cmLocalVisualStudio6Generator
|
|||||||
libMultiLineOptionsForDebug += targetLinkFlags;
|
libMultiLineOptionsForDebug += targetLinkFlags;
|
||||||
libMultiLineOptionsForDebug += " \n";
|
libMultiLineOptionsForDebug += " \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// are there any custom rules on the target itself
|
// are there any custom rules on the target itself
|
||||||
// only if the target is a lib or exe
|
// only if the target is a lib or exe
|
||||||
@ -1185,18 +1184,38 @@ void cmLocalVisualStudio6Generator
|
|||||||
std::string flagVar = baseFlagVar + "_RELEASE";
|
std::string flagVar = baseFlagVar + "_RELEASE";
|
||||||
flagsRelease = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
flagsRelease = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||||
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
|
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
|
||||||
|
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELEASE"))
|
||||||
|
{
|
||||||
|
flagsRelease += targetLinkFlags;
|
||||||
|
flagsRelease += " ";
|
||||||
|
}
|
||||||
flagVar = baseFlagVar + "_MINSIZEREL";
|
flagVar = baseFlagVar + "_MINSIZEREL";
|
||||||
flagsMinSize = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
flagsMinSize = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||||
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
|
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
|
||||||
|
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_MINSIZEREL"))
|
||||||
|
{
|
||||||
|
flagsMinSize += targetLinkFlags;
|
||||||
|
flagsMinSize += " ";
|
||||||
|
}
|
||||||
|
|
||||||
flagVar = baseFlagVar + "_DEBUG";
|
flagVar = baseFlagVar + "_DEBUG";
|
||||||
flagsDebug = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
flagsDebug = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||||
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
|
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
|
||||||
|
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_DEBUG"))
|
||||||
|
{
|
||||||
|
flagsDebug += targetLinkFlags;
|
||||||
|
flagsDebug += " ";
|
||||||
|
}
|
||||||
|
|
||||||
flagVar = baseFlagVar + "_RELWITHDEBINFO";
|
flagVar = baseFlagVar + "_RELWITHDEBINFO";
|
||||||
flagsDebugRel = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
flagsDebugRel = this->Makefile->GetRequiredDefinition(flagVar.c_str());
|
||||||
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
|
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
|
||||||
|
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
|
||||||
|
{
|
||||||
|
flagsDebugRel += targetLinkFlags;
|
||||||
|
flagsDebugRel += " ";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if unicode is not found, then add -D_MBCS
|
// if unicode is not found, then add -D_MBCS
|
||||||
|
@ -626,7 +626,15 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||||||
extraLinkOptions += " ";
|
extraLinkOptions += " ";
|
||||||
extraLinkOptions += targetLinkFlags;
|
extraLinkOptions += targetLinkFlags;
|
||||||
}
|
}
|
||||||
|
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
|
||||||
|
std::string linkFlagsConfig = "LINK_FLAGS_";
|
||||||
|
linkFlagsConfig += configTypeUpper;
|
||||||
|
targetLinkFlags = target.GetProperty(linkFlagsConfig.c_str());
|
||||||
|
if(targetLinkFlags)
|
||||||
|
{
|
||||||
|
extraLinkOptions += " ";
|
||||||
|
extraLinkOptions += targetLinkFlags;
|
||||||
|
}
|
||||||
std::map<cmStdString, cmStdString> flagMap;
|
std::map<cmStdString, cmStdString> flagMap;
|
||||||
this->
|
this->
|
||||||
FillFlagMapFromCommandFlags(flagMap,
|
FillFlagMapFromCommandFlags(flagMap,
|
||||||
|
@ -232,7 +232,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
|
|
||||||
// Add target-specific linker flags.
|
// Add target-specific linker flags.
|
||||||
this->LocalGenerator->AppendFlags(linkFlags, this->Target->GetProperty("LINK_FLAGS"));
|
this->LocalGenerator->AppendFlags(linkFlags, this->Target->GetProperty("LINK_FLAGS"));
|
||||||
|
std::string linkFlagsConfig = "LINK_FLAGS_";
|
||||||
|
linkFlagsConfig += cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
|
||||||
|
this->LocalGenerator->AppendFlags(linkFlags,
|
||||||
|
this->Target->GetProperty(linkFlagsConfig.c_str()));
|
||||||
// Construct a list of files associated with this executable that
|
// Construct a list of files associated with this executable that
|
||||||
// may need to be cleaned.
|
// may need to be cleaned.
|
||||||
std::vector<std::string> exeCleanFiles;
|
std::vector<std::string> exeCleanFiles;
|
||||||
|
@ -109,6 +109,11 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
|
|||||||
|
|
||||||
std::string extraFlags;
|
std::string extraFlags;
|
||||||
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
|
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
|
||||||
|
std::string linkFlagsConfig = "LINK_FLAGS_";
|
||||||
|
linkFlagsConfig += cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
|
||||||
|
this->LocalGenerator->AppendFlags(extraFlags,
|
||||||
|
this->Target->GetProperty(linkFlagsConfig.c_str()));
|
||||||
|
|
||||||
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS",
|
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_SHARED_LINKER_FLAGS",
|
||||||
this->LocalGenerator->ConfigurationName.c_str());
|
this->LocalGenerator->ConfigurationName.c_str());
|
||||||
if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
|
if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
|
||||||
@ -143,6 +148,10 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
|
|||||||
|
|
||||||
std::string extraFlags;
|
std::string extraFlags;
|
||||||
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
|
this->LocalGenerator->AppendFlags(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
|
||||||
|
std::string linkFlagsConfig = "LINK_FLAGS_";
|
||||||
|
linkFlagsConfig += cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
|
||||||
|
this->LocalGenerator->AppendFlags(extraFlags,
|
||||||
|
this->Target->GetProperty(linkFlagsConfig.c_str()));
|
||||||
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS",
|
this->LocalGenerator->AddConfigVariableFlags(extraFlags, "CMAKE_MODULE_LINKER_FLAGS",
|
||||||
this->LocalGenerator->ConfigurationName.c_str());
|
this->LocalGenerator->ConfigurationName.c_str());
|
||||||
// TODO: .def files should be supported here also.
|
// TODO: .def files should be supported here also.
|
||||||
|
@ -79,7 +79,8 @@ public:
|
|||||||
"variable for executables)."
|
"variable for executables)."
|
||||||
"\n"
|
"\n"
|
||||||
"The LINK_FLAGS property can be used to add extra flags to the "
|
"The LINK_FLAGS property can be used to add extra flags to the "
|
||||||
"link step of a target. "
|
"link step of a target. LINK_FLAGS_<CONFIG> will add to the configuration "
|
||||||
|
"<CONFIG>, for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. "
|
||||||
"DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "
|
"DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "
|
||||||
"compiling sources in a shared library. "
|
"compiling sources in a shared library. "
|
||||||
"If not set here then it is set to target_EXPORTS by default "
|
"If not set here then it is set to target_EXPORTS by default "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user