mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 13:50:10 -05:00
Add STATIC_LIBRARY_FLAGS_<CONFIG> property (#10768)
This is a per-configuration version of STATIC_LIBRARY_FLAGS.
This commit is contained in:
@@ -1381,11 +1381,43 @@ void cmLocalVisualStudio6Generator
|
||||
cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
|
||||
}
|
||||
std::string staticLibOptions;
|
||||
std::string staticLibOptionsDebug;
|
||||
std::string staticLibOptionsRelease;
|
||||
std::string staticLibOptionsMinSizeRel;
|
||||
std::string staticLibOptionsRelWithDebInfo;
|
||||
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
||||
{
|
||||
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
||||
{
|
||||
staticLibOptions = libflags;
|
||||
staticLibOptionsDebug = libflags;
|
||||
staticLibOptionsRelease = libflags;
|
||||
staticLibOptionsMinSizeRel = libflags;
|
||||
staticLibOptionsRelWithDebInfo = libflags;
|
||||
}
|
||||
if(const char* libflagsDebug =
|
||||
target.GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"))
|
||||
{
|
||||
staticLibOptionsDebug += " ";
|
||||
staticLibOptionsDebug = libflagsDebug;
|
||||
}
|
||||
if(const char* libflagsRelease =
|
||||
target.GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"))
|
||||
{
|
||||
staticLibOptionsRelease += " ";
|
||||
staticLibOptionsRelease = libflagsRelease;
|
||||
}
|
||||
if(const char* libflagsMinSizeRel =
|
||||
target.GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"))
|
||||
{
|
||||
staticLibOptionsMinSizeRel += " ";
|
||||
staticLibOptionsMinSizeRel = libflagsMinSizeRel;
|
||||
}
|
||||
if(const char* libflagsRelWithDebInfo =
|
||||
target.GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"))
|
||||
{
|
||||
staticLibOptionsRelWithDebInfo += " ";
|
||||
staticLibOptionsRelWithDebInfo = libflagsRelWithDebInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1417,6 +1449,14 @@ void cmLocalVisualStudio6Generator
|
||||
mfcFlag);
|
||||
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
||||
{
|
||||
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG",
|
||||
staticLibOptionsDebug.c_str());
|
||||
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE",
|
||||
staticLibOptionsRelease.c_str());
|
||||
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL",
|
||||
staticLibOptionsMinSizeRel.c_str());
|
||||
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO",
|
||||
staticLibOptionsRelWithDebInfo.c_str());
|
||||
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
|
||||
staticLibOptions.c_str());
|
||||
}
|
||||
|
||||
@@ -915,7 +915,20 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||
}
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"" << tool << "\"\n";
|
||||
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
||||
|
||||
std::string libflags;
|
||||
if(const char* flags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
||||
{
|
||||
libflags += flags;
|
||||
}
|
||||
std::string libFlagsConfig = "STATIC_LIBRARY_FLAGS_";
|
||||
libFlagsConfig += configTypeUpper;
|
||||
if(const char* flagsConfig = target.GetProperty(libFlagsConfig.c_str()))
|
||||
{
|
||||
libflags += " ";
|
||||
libflags += flagsConfig;
|
||||
}
|
||||
if(!libflags.empty())
|
||||
{
|
||||
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
|
||||
}
|
||||
|
||||
@@ -122,6 +122,10 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||
std::string extraFlags;
|
||||
this->LocalGenerator->AppendFlags
|
||||
(extraFlags,this->Target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
||||
std::string staticLibraryFlagsConfig = "STATIC_LIBRARY_FLAGS_";
|
||||
staticLibraryFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
|
||||
this->LocalGenerator->AppendFlags
|
||||
(extraFlags, this->Target->GetProperty(staticLibraryFlagsConfig.c_str()));
|
||||
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -707,6 +707,11 @@ void cmTarget::DefineProperties(cmake *cm)
|
||||
"Extra flags to use when linking static libraries.",
|
||||
"Extra flags to use when linking a static library.");
|
||||
|
||||
cm->DefineProperty
|
||||
("STATIC_LIBRARY_FLAGS_<CONFIG>", cmProperty::TARGET,
|
||||
"Per-configuration flags for creating a static library.",
|
||||
"This is the configuration-specific version of STATIC_LIBRARY_FLAGS.");
|
||||
|
||||
cm->DefineProperty
|
||||
("SUFFIX", cmProperty::TARGET,
|
||||
"What comes after the library name.",
|
||||
|
||||
@@ -1023,22 +1023,27 @@ WriteRCOptions(std::string const& ,
|
||||
}
|
||||
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const&
|
||||
)
|
||||
void
|
||||
cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
|
||||
{
|
||||
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(const char* libflags = this->Target
|
||||
->GetProperty("STATIC_LIBRARY_FLAGS"))
|
||||
const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
|
||||
std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
|
||||
flagsConfigVar += cmSystemTools::UpperCase(config);
|
||||
const char* libflagsConfig =
|
||||
this->Target->GetProperty(flagsConfigVar.c_str());
|
||||
if(libflags || libflagsConfig)
|
||||
{
|
||||
this->WriteString("<Lib>\n", 2);
|
||||
cmVisualStudioGeneratorOptions
|
||||
libOptions(this->LocalGenerator, 10,
|
||||
cmVisualStudioGeneratorOptions::Linker,
|
||||
cmVS10LibFlagTable, 0, this);
|
||||
libOptions.Parse(libflags);
|
||||
libOptions.Parse(libflags?libflags:"");
|
||||
libOptions.Parse(libflagsConfig?libflagsConfig:"");
|
||||
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||
this->WriteString("</Lib>\n", 2);
|
||||
|
||||
Reference in New Issue
Block a user