summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDocumentVariables.cxx43
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx34
-rw-r--r--Source/cmLocalGenerator.cxx40
-rw-r--r--Source/cmLocalGenerator.h5
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx101
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx12
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx8
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx13
8 files changed, 158 insertions, 98 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index 58b7147..91e278e 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1428,6 +1428,49 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Same as CMAKE_C_FLAGS_* but used by the linker "
"when creating executables.",false,
"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
("CMAKE_LIBRARY_PATH_FLAG", cmProperty::VARIABLE,
"The flag to be used to add a library search path to a compiler.",
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 63de1a5..7cb2d1f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1769,27 +1769,31 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
configName);
}
- const char* linkFlagsProp = "LINK_FLAGS";
if(target.GetType() == cmTarget::OBJECT_LIBRARY ||
target.GetType() == cmTarget::STATIC_LIBRARY)
{
- linkFlagsProp = "STATIC_LIBRARY_FLAGS";
- }
- const char* targetLinkFlags = target.GetProperty(linkFlagsProp);
- if(targetLinkFlags)
- {
- extraLinkOptions += " ";
- extraLinkOptions += targetLinkFlags;
+ this->CurrentLocalGenerator
+ ->GetStaticLibraryFlags(extraLinkOptions,
+ cmSystemTools::UpperCase(configName),
+ &target);
}
- if(configName && *configName)
+ else
{
- std::string linkFlagsVar = linkFlagsProp;
- linkFlagsVar += "_";
- linkFlagsVar += cmSystemTools::UpperCase(configName);
- if(const char* linkFlags = target.GetProperty(linkFlagsVar.c_str()))
+ const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
+ if(targetLinkFlags)
{
- extraLinkOptions += " ";
- extraLinkOptions += linkFlags;
+ this->CurrentLocalGenerator->
+ 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);
+ }
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b187d6b..b515727 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -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,
std::string& flags,
std::string& linkFlags,
@@ -1557,26 +1576,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
switch(target->GetType())
{
case cmTarget::STATIC_LIBRARY:
- {
- 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 += " ";
- }
- }
- }
+ this->GetStaticLibraryFlags(linkFlags, buildType, target->Target);
break;
case cmTarget::MODULE_LIBRARY:
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index ed0f6e3..10f0b1a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -348,6 +348,11 @@ public:
std::string const& dir_max,
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,
* flags, and linkflags. */
void GetTargetFlags(std::string& linkLibs,
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index df6e1f1..667d86f 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1171,18 +1171,42 @@ void cmLocalVisualStudio6Generator
std::string extraLinkOptionsRelWithDebInfo;
if(target.GetType() == cmTarget::EXECUTABLE)
{
- extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
+ extraLinkOptions = this->Makefile->
+ 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)
{
- extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
+ extraLinkOptions = this->Makefile->
+ 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)
{
- extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
+ extraLinkOptions = this->Makefile->
+ 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.
@@ -1435,38 +1459,39 @@ void cmLocalVisualStudio6Generator
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;
- }
+ const char *libflagsGlobal =
+ this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS");
+ this->AppendFlags(staticLibOptions, libflagsGlobal);
+ this->AppendFlags(staticLibOptionsDebug, libflagsGlobal);
+ this->AppendFlags(staticLibOptionsRelease, libflagsGlobal);
+ this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal);
+ this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal);
+
+ this->AppendFlags(staticLibOptionsDebug, this->Makefile->
+ GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG"));
+ this->AppendFlags(staticLibOptionsRelease, this->Makefile->
+ GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE"));
+ this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile->
+ GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL"));
+ this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile->
+ GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO"));
+
+ const char *libflags = target.GetProperty("STATIC_LIBRARY_FLAGS");
+ this->AppendFlags(staticLibOptions, libflags);
+ this->AppendFlags(staticLibOptionsDebug, libflags);
+ this->AppendFlags(staticLibOptionsRelease, libflags);
+ this->AppendFlags(staticLibOptionsMinSizeRel, libflags);
+ this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags);
+
+ this->AppendFlags(staticLibOptionsDebug,
+ target.GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"));
+ this->AppendFlags(staticLibOptionsRelease,
+ target.GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"));
+ this->AppendFlags(staticLibOptionsMinSizeRel,
+ target.GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"));
+ this->AppendFlags(staticLibOptionsRelWithDebInfo,
+ target.GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"));
+
std::string objects;
this->OutputObjects(target, "LIB", objects);
if(!objects.empty())
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 9ecd53d..672edf4 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1039,17 +1039,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
}
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;
- }
+ this->GetStaticLibraryFlags(libflags, configTypeUpper, &target);
if(!libflags.empty())
{
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 347f26d..ea9663f 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -144,12 +144,8 @@ 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->LocalGenerator->GetStaticLibraryFlags(extraFlags,
+ cmSystemTools::UpperCase(this->ConfigName), this->Target);
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index d59de11..da5696a 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1417,20 +1417,17 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
{
return;
}
- 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)
+ std::string libflags;
+ this->LocalGenerator->GetStaticLibraryFlags(libflags,
+ cmSystemTools::UpperCase(config), this->Target);
+ if(!libflags.empty())
{
this->WriteString("<Lib>\n", 2);
cmVisualStudioGeneratorOptions
libOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Linker,
cmVSGetLibFlagTable(this->LocalGenerator), 0, this);
- libOptions.Parse(libflags?libflags:"");
- libOptions.Parse(libflagsConfig?libflagsConfig:"");
+ libOptions.Parse(libflags.c_str());
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
this->WriteString("</Lib>\n", 2);