diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-03 16:57:51 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-03 16:57:51 (GMT) |
commit | 3c8e899102dc58efa5301240f5bf5bf2225c2b65 (patch) | |
tree | ea7b3aa1cf42176e6719ffe9506ec76e4dcd1c9d /Source | |
parent | 32b63ef915eadc1d5e48c63e09ca1a65e0f0ca52 (diff) | |
download | CMake-3c8e899102dc58efa5301240f5bf5bf2225c2b65.zip CMake-3c8e899102dc58efa5301240f5bf5bf2225c2b65.tar.gz CMake-3c8e899102dc58efa5301240f5bf5bf2225c2b65.tar.bz2 |
ENH: add support for per config target LINK_FLAGS
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 25 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 10 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmSetTargetPropertiesCommand.h | 3 |
6 files changed, 63 insertions, 7 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index af82c45..748bfe5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1045,6 +1045,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { linkFlags += targetLinkFlags; linkFlags += " "; + std::string configLinkFlags = targetLinkFlags; + configLinkFlags += buildType; + targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); + if(targetLinkFlags) + { + linkFlags += targetLinkFlags; + linkFlags += " "; + } } cmOStringStream linklibsStr; this->OutputLinkLibraries(linklibsStr, target, false); @@ -1103,7 +1111,15 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(targetLinkFlags) { linkFlags += targetLinkFlags; - linkFlags += " "; + linkFlags += " "; + std::string configLinkFlags = targetLinkFlags; + configLinkFlags += buildType; + targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); + if(targetLinkFlags) + { + linkFlags += targetLinkFlags; + linkFlags += " "; + } } } break; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 6c36bea..ec5d7ea 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1062,7 +1062,6 @@ void cmLocalVisualStudio6Generator libMultiLineOptionsForDebug += targetLinkFlags; libMultiLineOptionsForDebug += " \n"; } - // are there any custom rules on the target itself // only if the target is a lib or exe @@ -1185,18 +1184,38 @@ void cmLocalVisualStudio6Generator std::string flagVar = baseFlagVar + "_RELEASE"; flagsRelease = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" "; - + if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELEASE")) + { + flagsRelease += targetLinkFlags; + flagsRelease += " "; + } flagVar = baseFlagVar + "_MINSIZEREL"; flagsMinSize = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" "; + if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_MINSIZEREL")) + { + flagsMinSize += targetLinkFlags; + flagsMinSize += " "; + } flagVar = baseFlagVar + "_DEBUG"; flagsDebug = this->Makefile->GetRequiredDefinition(flagVar.c_str()); flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" "; - + if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_DEBUG")) + { + flagsDebug += targetLinkFlags; + flagsDebug += " "; + } + flagVar = baseFlagVar + "_RELWITHDEBINFO"; flagsDebugRel = this->Makefile->GetRequiredDefinition(flagVar.c_str()); 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 diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 38b9700..55b80ef 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -626,7 +626,15 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, extraLinkOptions += " "; 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; this-> FillFlagMapFromCommandFlags(flagMap, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 7388862..37c664c 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -232,7 +232,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add target-specific linker 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 // may need to be cleaned. std::vector<std::string> exeCleanFiles; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 6cf5be9..bf5d55c 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -109,6 +109,11 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) std::string extraFlags; 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->ConfigurationName.c_str()); 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; 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->ConfigurationName.c_str()); // TODO: .def files should be supported here also. diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index fdf41b1..21a7b50 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -79,7 +79,8 @@ public: "variable for executables)." "\n" "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 " "compiling sources in a shared library. " "If not set here then it is set to target_EXPORTS by default " |