Merge topic 'static_library_flags'
33e6e0b
VS6: Add handling of CMAKE_*_LINKER_FLAGS_<CONFIG> variables152dfda
Add additonal tests for the linker flags20ed496
Add documentation for the missing CMAKE_*_LINKER_FLAGS_* variables54f7019
Add CMAKE_STATIC_LINKER_FLAGS to CMakeCommonLanguageInclude2a43c30
Add support for CMAKE_STATIC_LINKER_FLAGS14bbf83
Unify the way the flags of a static library are read
This commit is contained in:
commit
e3b6ab92db
|
@ -68,6 +68,19 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||||
${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
|
${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
|
||||||
"Flags used by the linker during Release with Debug Info builds.")
|
"Flags used by the linker during Release with Debug Info builds.")
|
||||||
|
|
||||||
|
set (CMAKE_STATIC_LINKER_FLAGS_DEBUG ${CMAKE_STATIC_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
|
||||||
|
"Flags used by the linker during debug builds.")
|
||||||
|
|
||||||
|
set (CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL ${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL_INIT}
|
||||||
|
CACHE STRING
|
||||||
|
"Flags used by the linker during release minsize builds.")
|
||||||
|
|
||||||
|
set (CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
|
||||||
|
"Flags used by the linker during release builds.")
|
||||||
|
|
||||||
|
set (CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||||
|
${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
|
||||||
|
"Flags used by the linker during Release with Debug Info builds.")
|
||||||
endif()
|
endif()
|
||||||
# shared linker flags
|
# shared linker flags
|
||||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
|
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
|
||||||
|
@ -77,6 +90,10 @@ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
|
||||||
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
|
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
|
||||||
CACHE STRING "Flags used by the linker during the creation of modules.")
|
CACHE STRING "Flags used by the linker during the creation of modules.")
|
||||||
|
|
||||||
|
# static linker flags
|
||||||
|
set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_INIT}"
|
||||||
|
CACHE STRING "Flags used by the linker during the creation of static libraries.")
|
||||||
|
|
||||||
set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL
|
set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL
|
||||||
"What is the target build tool cmake is generating for.")
|
"What is the target build tool cmake is generating for.")
|
||||||
|
|
||||||
|
@ -103,5 +120,10 @@ CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
||||||
|
|
||||||
|
CMAKE_STATIC_LINKER_FLAGS
|
||||||
|
CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
||||||
|
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
||||||
|
CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
||||||
|
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1428,6 +1428,49 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
|
||||||
"Same as CMAKE_C_FLAGS_* but used by the linker "
|
"Same as CMAKE_C_FLAGS_* but used by the linker "
|
||||||
"when creating executables.",false,
|
"when creating executables.",false,
|
||||||
"Variables that Control the Build");
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_MODULE_LINKER_FLAGS", cmProperty::VARIABLE,
|
||||||
|
"Linker flags to be used to create modules.",
|
||||||
|
"These flags will be used by the linker when creating a module."
|
||||||
|
,false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_MODULE_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE,
|
||||||
|
"Flags to be used when linking a module.",
|
||||||
|
"Same as CMAKE_C_FLAGS_* but used by the linker "
|
||||||
|
"when creating modules.",false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_SHARED_LINKER_FLAGS", cmProperty::VARIABLE,
|
||||||
|
"Linker flags to be used to create shared libraries.",
|
||||||
|
"These flags will be used by the linker when creating a shared library."
|
||||||
|
,false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_SHARED_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE,
|
||||||
|
"Flags to be used when linking a shared library.",
|
||||||
|
"Same as CMAKE_C_FLAGS_* but used by the linker "
|
||||||
|
"when creating shared libraries.",false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_STATIC_LINKER_FLAGS", cmProperty::VARIABLE,
|
||||||
|
"Linker flags to be used to create static libraries.",
|
||||||
|
"These flags will be used by the linker when creating a static library."
|
||||||
|
,false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("CMAKE_STATIC_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE,
|
||||||
|
"Flags to be used when linking a static library.",
|
||||||
|
"Same as CMAKE_C_FLAGS_* but used by the linker "
|
||||||
|
"when creating static libraries.",false,
|
||||||
|
"Variables that Control the Build");
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("CMAKE_LIBRARY_PATH_FLAG", cmProperty::VARIABLE,
|
("CMAKE_LIBRARY_PATH_FLAG", cmProperty::VARIABLE,
|
||||||
"The flag to be used to add a library search path to a compiler.",
|
"The flag to be used to add a library search path to a compiler.",
|
||||||
|
|
|
@ -1769,27 +1769,31 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
configName);
|
configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* linkFlagsProp = "LINK_FLAGS";
|
|
||||||
if(target.GetType() == cmTarget::OBJECT_LIBRARY ||
|
if(target.GetType() == cmTarget::OBJECT_LIBRARY ||
|
||||||
target.GetType() == cmTarget::STATIC_LIBRARY)
|
target.GetType() == cmTarget::STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
linkFlagsProp = "STATIC_LIBRARY_FLAGS";
|
this->CurrentLocalGenerator
|
||||||
|
->GetStaticLibraryFlags(extraLinkOptions,
|
||||||
|
cmSystemTools::UpperCase(configName),
|
||||||
|
&target);
|
||||||
}
|
}
|
||||||
const char* targetLinkFlags = target.GetProperty(linkFlagsProp);
|
else
|
||||||
if(targetLinkFlags)
|
|
||||||
{
|
{
|
||||||
extraLinkOptions += " ";
|
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
|
||||||
extraLinkOptions += targetLinkFlags;
|
if(targetLinkFlags)
|
||||||
}
|
|
||||||
if(configName && *configName)
|
|
||||||
{
|
|
||||||
std::string linkFlagsVar = linkFlagsProp;
|
|
||||||
linkFlagsVar += "_";
|
|
||||||
linkFlagsVar += cmSystemTools::UpperCase(configName);
|
|
||||||
if(const char* linkFlags = target.GetProperty(linkFlagsVar.c_str()))
|
|
||||||
{
|
{
|
||||||
extraLinkOptions += " ";
|
this->CurrentLocalGenerator->
|
||||||
extraLinkOptions += linkFlags;
|
AppendFlags(extraLinkOptions, targetLinkFlags);
|
||||||
|
}
|
||||||
|
if(configName && *configName)
|
||||||
|
{
|
||||||
|
std::string linkFlagsVar = "LINK_FLAGS_";
|
||||||
|
linkFlagsVar += cmSystemTools::UpperCase(configName);
|
||||||
|
if(const char* linkFlags = target.GetProperty(linkFlagsVar.c_str()))
|
||||||
|
{
|
||||||
|
this->CurrentLocalGenerator->
|
||||||
|
AppendFlags(extraLinkOptions, linkFlags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1541,6 +1541,25 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
|
||||||
|
std::string const& config,
|
||||||
|
cmTarget* target)
|
||||||
|
{
|
||||||
|
this->AppendFlags(flags,
|
||||||
|
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
|
||||||
|
if(!config.empty())
|
||||||
|
{
|
||||||
|
std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
|
||||||
|
this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str()));
|
||||||
|
}
|
||||||
|
this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
||||||
|
if(!config.empty())
|
||||||
|
{
|
||||||
|
std::string name = "STATIC_LIBRARY_FLAGS_" + config;
|
||||||
|
this->AppendFlags(flags, target->GetProperty(name.c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
std::string& flags,
|
std::string& flags,
|
||||||
std::string& linkFlags,
|
std::string& linkFlags,
|
||||||
|
@ -1557,26 +1576,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
switch(target->GetType())
|
switch(target->GetType())
|
||||||
{
|
{
|
||||||
case cmTarget::STATIC_LIBRARY:
|
case cmTarget::STATIC_LIBRARY:
|
||||||
{
|
this->GetStaticLibraryFlags(linkFlags, buildType, target->Target);
|
||||||
const char* targetLinkFlags =
|
|
||||||
target->GetProperty("STATIC_LIBRARY_FLAGS");
|
|
||||||
if(targetLinkFlags)
|
|
||||||
{
|
|
||||||
linkFlags += targetLinkFlags;
|
|
||||||
linkFlags += " ";
|
|
||||||
}
|
|
||||||
if(!buildType.empty())
|
|
||||||
{
|
|
||||||
std::string build = "STATIC_LIBRARY_FLAGS_";
|
|
||||||
build += buildType;
|
|
||||||
targetLinkFlags = target->GetProperty(build.c_str());
|
|
||||||
if(targetLinkFlags)
|
|
||||||
{
|
|
||||||
linkFlags += targetLinkFlags;
|
|
||||||
linkFlags += " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case cmTarget::MODULE_LIBRARY:
|
case cmTarget::MODULE_LIBRARY:
|
||||||
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
|
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
|
||||||
|
|
|
@ -348,6 +348,11 @@ public:
|
||||||
std::string const& dir_max,
|
std::string const& dir_max,
|
||||||
bool* hasSourceExtension = 0);
|
bool* hasSourceExtension = 0);
|
||||||
|
|
||||||
|
/** Fill out the static linker flags for the given target. */
|
||||||
|
void GetStaticLibraryFlags(std::string& flags,
|
||||||
|
std::string const& config,
|
||||||
|
cmTarget* target);
|
||||||
|
|
||||||
/** Fill out these strings for the given target. Libraries to link,
|
/** Fill out these strings for the given target. Libraries to link,
|
||||||
* flags, and linkflags. */
|
* flags, and linkflags. */
|
||||||
void GetTargetFlags(std::string& linkLibs,
|
void GetTargetFlags(std::string& linkLibs,
|
||||||
|
|
|
@ -1171,18 +1171,42 @@ void cmLocalVisualStudio6Generator
|
||||||
std::string extraLinkOptionsRelWithDebInfo;
|
std::string extraLinkOptionsRelWithDebInfo;
|
||||||
if(target.GetType() == cmTarget::EXECUTABLE)
|
if(target.GetType() == cmTarget::EXECUTABLE)
|
||||||
{
|
{
|
||||||
extraLinkOptions =
|
extraLinkOptions = this->Makefile->
|
||||||
this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
|
GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
|
||||||
|
extraLinkOptionsDebug = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_DEBUG");
|
||||||
|
extraLinkOptionsRelease = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELEASE");
|
||||||
|
extraLinkOptionsMinSizeRel = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_MINSIZEREL");
|
||||||
|
extraLinkOptionsRelWithDebInfo = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO");
|
||||||
}
|
}
|
||||||
if(target.GetType() == cmTarget::SHARED_LIBRARY)
|
if(target.GetType() == cmTarget::SHARED_LIBRARY)
|
||||||
{
|
{
|
||||||
extraLinkOptions =
|
extraLinkOptions = this->Makefile->
|
||||||
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
|
GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
|
||||||
|
extraLinkOptionsDebug = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_DEBUG");
|
||||||
|
extraLinkOptionsRelease = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELEASE");
|
||||||
|
extraLinkOptionsMinSizeRel = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL");
|
||||||
|
extraLinkOptionsRelWithDebInfo = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO");
|
||||||
}
|
}
|
||||||
if(target.GetType() == cmTarget::MODULE_LIBRARY)
|
if(target.GetType() == cmTarget::MODULE_LIBRARY)
|
||||||
{
|
{
|
||||||
extraLinkOptions =
|
extraLinkOptions = this->Makefile->
|
||||||
this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
|
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
|
||||||
|
extraLinkOptionsDebug = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_DEBUG");
|
||||||
|
extraLinkOptionsRelease = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELEASE");
|
||||||
|
extraLinkOptionsMinSizeRel = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL");
|
||||||
|
extraLinkOptionsRelWithDebInfo = this->Makefile->
|
||||||
|
GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get extra linker options for this target.
|
// Get extra linker options for this target.
|
||||||
|
@ -1435,38 +1459,39 @@ void cmLocalVisualStudio6Generator
|
||||||
std::string staticLibOptionsRelWithDebInfo;
|
std::string staticLibOptionsRelWithDebInfo;
|
||||||
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
if(target.GetType() == cmTarget::STATIC_LIBRARY )
|
||||||
{
|
{
|
||||||
if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
const char *libflagsGlobal =
|
||||||
{
|
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS");
|
||||||
staticLibOptions = libflags;
|
this->AppendFlags(staticLibOptions, libflagsGlobal);
|
||||||
staticLibOptionsDebug = libflags;
|
this->AppendFlags(staticLibOptionsDebug, libflagsGlobal);
|
||||||
staticLibOptionsRelease = libflags;
|
this->AppendFlags(staticLibOptionsRelease, libflagsGlobal);
|
||||||
staticLibOptionsMinSizeRel = libflags;
|
this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal);
|
||||||
staticLibOptionsRelWithDebInfo = libflags;
|
this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal);
|
||||||
}
|
|
||||||
if(const char* libflagsDebug =
|
this->AppendFlags(staticLibOptionsDebug, this->Makefile->
|
||||||
target.GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"))
|
GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG"));
|
||||||
{
|
this->AppendFlags(staticLibOptionsRelease, this->Makefile->
|
||||||
staticLibOptionsDebug += " ";
|
GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE"));
|
||||||
staticLibOptionsDebug = libflagsDebug;
|
this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile->
|
||||||
}
|
GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL"));
|
||||||
if(const char* libflagsRelease =
|
this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile->
|
||||||
target.GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"))
|
GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO"));
|
||||||
{
|
|
||||||
staticLibOptionsRelease += " ";
|
const char *libflags = target.GetProperty("STATIC_LIBRARY_FLAGS");
|
||||||
staticLibOptionsRelease = libflagsRelease;
|
this->AppendFlags(staticLibOptions, libflags);
|
||||||
}
|
this->AppendFlags(staticLibOptionsDebug, libflags);
|
||||||
if(const char* libflagsMinSizeRel =
|
this->AppendFlags(staticLibOptionsRelease, libflags);
|
||||||
target.GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"))
|
this->AppendFlags(staticLibOptionsMinSizeRel, libflags);
|
||||||
{
|
this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags);
|
||||||
staticLibOptionsMinSizeRel += " ";
|
|
||||||
staticLibOptionsMinSizeRel = libflagsMinSizeRel;
|
this->AppendFlags(staticLibOptionsDebug,
|
||||||
}
|
target.GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"));
|
||||||
if(const char* libflagsRelWithDebInfo =
|
this->AppendFlags(staticLibOptionsRelease,
|
||||||
target.GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"))
|
target.GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"));
|
||||||
{
|
this->AppendFlags(staticLibOptionsMinSizeRel,
|
||||||
staticLibOptionsRelWithDebInfo += " ";
|
target.GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"));
|
||||||
staticLibOptionsRelWithDebInfo = libflagsRelWithDebInfo;
|
this->AppendFlags(staticLibOptionsRelWithDebInfo,
|
||||||
}
|
target.GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"));
|
||||||
|
|
||||||
std::string objects;
|
std::string objects;
|
||||||
this->OutputObjects(target, "LIB", objects);
|
this->OutputObjects(target, "LIB", objects);
|
||||||
if(!objects.empty())
|
if(!objects.empty())
|
||||||
|
|
|
@ -1039,17 +1039,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string libflags;
|
std::string libflags;
|
||||||
if(const char* flags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
|
this->GetStaticLibraryFlags(libflags, configTypeUpper, &target);
|
||||||
{
|
|
||||||
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())
|
if(!libflags.empty())
|
||||||
{
|
{
|
||||||
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
|
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
|
||||||
|
|
|
@ -144,12 +144,8 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string extraFlags;
|
std::string extraFlags;
|
||||||
this->LocalGenerator->AppendFlags
|
this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
|
||||||
(extraFlags,this->Target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
cmSystemTools::UpperCase(this->ConfigName), this->Target);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1417,20 +1417,17 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
|
std::string libflags;
|
||||||
std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
|
this->LocalGenerator->GetStaticLibraryFlags(libflags,
|
||||||
flagsConfigVar += cmSystemTools::UpperCase(config);
|
cmSystemTools::UpperCase(config), this->Target);
|
||||||
const char* libflagsConfig =
|
if(!libflags.empty())
|
||||||
this->Target->GetProperty(flagsConfigVar.c_str());
|
|
||||||
if(libflags || libflagsConfig)
|
|
||||||
{
|
{
|
||||||
this->WriteString("<Lib>\n", 2);
|
this->WriteString("<Lib>\n", 2);
|
||||||
cmVisualStudioGeneratorOptions
|
cmVisualStudioGeneratorOptions
|
||||||
libOptions(this->LocalGenerator,
|
libOptions(this->LocalGenerator,
|
||||||
cmVisualStudioGeneratorOptions::Linker,
|
cmVisualStudioGeneratorOptions::Linker,
|
||||||
cmVSGetLibFlagTable(this->LocalGenerator), 0, this);
|
cmVSGetLibFlagTable(this->LocalGenerator), 0, this);
|
||||||
libOptions.Parse(libflags?libflags:"");
|
libOptions.Parse(libflags.c_str());
|
||||||
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);
|
||||||
|
|
|
@ -394,10 +394,20 @@ if(BUILD_TESTING)
|
||||||
endmacro()
|
endmacro()
|
||||||
ADD_LINK_FLAGS_TEST(lib prepare)
|
ADD_LINK_FLAGS_TEST(lib prepare)
|
||||||
ADD_LINK_FLAGS_TEST(dll lib)
|
ADD_LINK_FLAGS_TEST(dll lib)
|
||||||
ADD_LINK_FLAGS_TEST(exe dll)
|
ADD_LINK_FLAGS_TEST(mod dll)
|
||||||
|
ADD_LINK_FLAGS_TEST(exe mod)
|
||||||
ADD_LINK_FLAGS_TEST(lib_config exe)
|
ADD_LINK_FLAGS_TEST(lib_config exe)
|
||||||
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(mod_config dll_config)
|
||||||
|
ADD_LINK_FLAGS_TEST(exe_config mod_config)
|
||||||
|
ADD_LINK_FLAGS_TEST(lib_flags exe_config)
|
||||||
|
ADD_LINK_FLAGS_TEST(dll_flags lib_flags)
|
||||||
|
ADD_LINK_FLAGS_TEST(mod_flags dll_flags)
|
||||||
|
ADD_LINK_FLAGS_TEST(exe_flags mod_flags)
|
||||||
|
ADD_LINK_FLAGS_TEST(lib_flags_config exe_flags)
|
||||||
|
ADD_LINK_FLAGS_TEST(dll_flags_config lib_flags_config)
|
||||||
|
ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
|
||||||
|
ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
|
||||||
|
|
||||||
# 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
|
||||||
|
|
|
@ -13,6 +13,9 @@ set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS ${pre}BADFLAG${o
|
||||||
add_library(LinkFlags_dll SHARED LinkFlagsLib.c)
|
add_library(LinkFlags_dll SHARED LinkFlagsLib.c)
|
||||||
set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
|
set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
|
||||||
|
add_library(LinkFlags_mod MODULE LinkFlagsLib.c)
|
||||||
|
set_property(TARGET LinkFlags_mod PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
|
||||||
add_executable(LinkFlags_exe LinkFlagsExe.c)
|
add_executable(LinkFlags_exe LinkFlagsExe.c)
|
||||||
set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
|
set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
|
||||||
|
@ -22,7 +25,13 @@ set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CO
|
||||||
add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c)
|
add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c)
|
||||||
set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
|
set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
|
||||||
|
|
||||||
|
add_library(LinkFlags_mod_config MODULE LinkFlagsLib.c)
|
||||||
|
set_property(TARGET LinkFlags_mod_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
|
||||||
|
|
||||||
add_executable(LinkFlags_exe_config LinkFlagsExe.c)
|
add_executable(LinkFlags_exe_config LinkFlagsExe.c)
|
||||||
set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
|
set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj})
|
||||||
|
|
||||||
add_executable(LinkFlags LinkFlags.c)
|
add_executable(LinkFlags LinkFlags.c)
|
||||||
|
|
||||||
|
add_subdirectory(LinkerFlags)
|
||||||
|
add_subdirectory(LinkerFlagsConfig)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
set(CMAKE_STATIC_LINKER_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_lib_flags STATIC ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_dll_flags SHARED ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_LINKER_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_mod_flags MODULE ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS ${pre}BADFLAG${obj})
|
||||||
|
add_executable(LinkFlags_exe_flags ../LinkFlagsExe.c)
|
|
@ -0,0 +1,11 @@
|
||||||
|
set(CMAKE_STATIC_LINKER_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_lib_flags_config STATIC ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_dll_flags_config SHARED ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_LINKER_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG${obj})
|
||||||
|
add_library(LinkFlags_mod_flags_config MODULE ../LinkFlagsLib.c)
|
||||||
|
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG${obj})
|
||||||
|
add_executable(LinkFlags_exe_flags_config ../LinkFlagsExe.c)
|
Loading…
Reference in New Issue