Add STATIC_LIBRARY_FLAGS_<CONFIG> property (#10768)
This is a per-configuration version of STATIC_LIBRARY_FLAGS.
This commit is contained in:
parent
d3303dbc81
commit
fe971d97ca
|
@ -1381,11 +1381,43 @@ void cmLocalVisualStudio6Generator
|
||||||
cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
|
cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
|
||||||
}
|
}
|
||||||
std::string staticLibOptions;
|
std::string staticLibOptions;
|
||||||
|
std::string staticLibOptionsDebug;
|
||||||
|
std::string staticLibOptionsRelease;
|
||||||
|
std::string staticLibOptionsMinSizeRel;
|
||||||
|
std::string staticLibOptionsRelWithDebInfo;
|
||||||
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
||||||
{
|
{
|
||||||
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
||||||
{
|
{
|
||||||
staticLibOptions = libflags;
|
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);
|
mfcFlag);
|
||||||
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
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",
|
cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
|
||||||
staticLibOptions.c_str());
|
staticLibOptions.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -915,7 +915,20 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||||
}
|
}
|
||||||
fout << "\t\t\t<Tool\n"
|
fout << "\t\t\t<Tool\n"
|
||||||
<< "\t\t\t\tName=\"" << 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";
|
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,10 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||||
std::string extraFlags;
|
std::string extraFlags;
|
||||||
this->LocalGenerator->AppendFlags
|
this->LocalGenerator->AppendFlags
|
||||||
(extraFlags,this->Target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
(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);
|
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 static libraries.",
|
||||||
"Extra flags to use when linking a static library.");
|
"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
|
cm->DefineProperty
|
||||||
("SUFFIX", cmProperty::TARGET,
|
("SUFFIX", cmProperty::TARGET,
|
||||||
"What comes after the library name.",
|
"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)
|
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(const char* libflags = this->Target
|
const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
|
||||||
->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);
|
this->WriteString("<Lib>\n", 2);
|
||||||
cmVisualStudioGeneratorOptions
|
cmVisualStudioGeneratorOptions
|
||||||
libOptions(this->LocalGenerator, 10,
|
libOptions(this->LocalGenerator, 10,
|
||||||
cmVisualStudioGeneratorOptions::Linker,
|
cmVisualStudioGeneratorOptions::Linker,
|
||||||
cmVS10LibFlagTable, 0, this);
|
cmVS10LibFlagTable, 0, this);
|
||||||
libOptions.Parse(libflags);
|
libOptions.Parse(libflags?libflags:"");
|
||||||
|
libOptions.Parse(libflagsConfig?libflagsConfig:"");
|
||||||
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||||
this->WriteString("</Lib>\n", 2);
|
this->WriteString("</Lib>\n", 2);
|
||||||
|
|
|
@ -67,7 +67,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LIB32=link.exe -lib
|
LIB32=link.exe -lib
|
||||||
# ADD BASE LIB32 /nologo
|
# ADD BASE LIB32 /nologo
|
||||||
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS
|
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS_RELEASE
|
||||||
|
|
||||||
CMAKE_CUSTOM_RULE_CODE_RELEASE
|
CMAKE_CUSTOM_RULE_CODE_RELEASE
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LIB32=link.exe -lib
|
LIB32=link.exe -lib
|
||||||
# ADD BASE LIB32 /nologo
|
# ADD BASE LIB32 /nologo
|
||||||
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS
|
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS_DEBUG
|
||||||
|
|
||||||
CMAKE_CUSTOM_RULE_CODE_DEBUG
|
CMAKE_CUSTOM_RULE_CODE_DEBUG
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LIB32=link.exe -lib
|
LIB32=link.exe -lib
|
||||||
# ADD BASE LIB32 /nologo
|
# ADD BASE LIB32 /nologo
|
||||||
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS
|
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS_MINSIZEREL
|
||||||
|
|
||||||
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
|
CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LIB32=link.exe -lib
|
LIB32=link.exe -lib
|
||||||
# ADD BASE LIB32 /nologo
|
# ADD BASE LIB32 /nologo
|
||||||
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS
|
# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS_RELWITHDEBINFO
|
||||||
|
|
||||||
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
|
CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
|
||||||
|
|
||||||
|
|
|
@ -202,9 +202,6 @@ IF(BUILD_TESTING)
|
||||||
ADD_LINK_FLAGS_TEST(dll_config lib_config)
|
ADD_LINK_FLAGS_TEST(dll_config lib_config)
|
||||||
ADD_LINK_FLAGS_TEST(exe_config dll_config)
|
ADD_LINK_FLAGS_TEST(exe_config dll_config)
|
||||||
|
|
||||||
# STATIC_LIBRARY_FLAGS_<CONFIG> not yet implemented
|
|
||||||
SET_TESTS_PROPERTIES(LinkFlags-lib_config PROPERTIES WILL_FAIL 1)
|
|
||||||
|
|
||||||
# If we are running right now with a UnixMakefiles based generator,
|
# If we are running right now with a UnixMakefiles based generator,
|
||||||
# build the "Simple" test with the ExtraGenerators, if available
|
# build the "Simple" test with the ExtraGenerators, if available
|
||||||
# This doesn't test whether the generated project files work (unfortunately),
|
# This doesn't test whether the generated project files work (unfortunately),
|
||||||
|
|
Loading…
Reference in New Issue