summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaNormalTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx412
1 files changed, 208 insertions, 204 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 73ba815..e344df4 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -18,6 +18,7 @@
#include "cmMakefile.h"
#include "cmOSXBundleGenerator.h"
#include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
#include <assert.h>
#include <algorithm>
@@ -35,7 +36,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
, TargetNameReal()
, TargetNameImport()
, TargetNamePDB()
- , TargetLinkLanguage(0)
+ , TargetLinkLanguage("")
{
this->TargetLinkLanguage = target->Target
->GetLinkerLanguage(this->GetConfigName());
@@ -72,10 +73,10 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
void cmNinjaNormalTargetGenerator::Generate()
{
- if (!this->TargetLinkLanguage) {
+ if (this->TargetLinkLanguage.empty()) {
cmSystemTools::Error("CMake can not determine linker language for "
"target: ",
- this->GetTarget()->GetName());
+ this->GetTarget()->GetName().c_str());
return;
}
@@ -109,9 +110,10 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
<< "\n\n";
#endif
- std::set<cmStdString> languages;
- this->GetTarget()->GetLanguages(languages);
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ std::set<std::string> languages;
+ this->GetTarget()->GetLanguages(languages,
+ this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end();
++l)
this->WriteLanguageRules(*l);
@@ -140,7 +142,7 @@ std::string
cmNinjaNormalTargetGenerator
::LanguageLinkerRule() const
{
- return std::string(this->TargetLinkLanguage)
+ return this->TargetLinkLanguage
+ "_"
+ cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
+ "_LINKER";
@@ -163,7 +165,7 @@ cmNinjaNormalTargetGenerator
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GetTarget();
- vars.Language = this->TargetLinkLanguage;
+ vars.Language = this->TargetLinkLanguage.c_str();
std::string responseFlag;
if (!useResponseFile) {
@@ -175,7 +177,7 @@ cmNinjaNormalTargetGenerator
// build response file name
std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
- const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str());
+ const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar);
if(flag) {
responseFlag = flag;
} else {
@@ -185,12 +187,7 @@ cmNinjaNormalTargetGenerator
responseFlag += rspfile;
// build response file content
- std::string linkOptionVar = cmakeVarLang;
- linkOptionVar += "_COMPILER_LINKER_OPTION_FLAG_";
- linkOptionVar += cmTarget::GetTargetTypeName(targetType);
- const std::string linkOption =
- GetMakefile()->GetSafeDefinition(linkOptionVar.c_str());
- rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES";
+ rspcontent = "$in_newline $LINK_PATH $LINK_LIBRARIES";
vars.Objects = responseFlag.c_str();
vars.LinkLibraries = "";
}
@@ -230,13 +227,11 @@ cmNinjaNormalTargetGenerator
vars.LinkFlags = "$LINK_FLAGS";
std::string langFlags;
- if (targetType != cmTarget::EXECUTABLE) {
- this->GetLocalGenerator()->AddLanguageFlags(langFlags,
- this->TargetLinkLanguage,
- this->GetConfigName());
- langFlags += " $ARCH_FLAGS";
+ if (targetType != cmTarget::EXECUTABLE)
+ {
+ langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
vars.LanguageCompileFlags = langFlags.c_str();
- }
+ }
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeLinkCmd();
@@ -312,97 +307,87 @@ cmNinjaNormalTargetGenerator
::ComputeLinkCmd()
{
std::vector<std::string> linkCmds;
- cmTarget::TargetType targetType = this->GetTarget()->GetType();
- switch (targetType) {
+ cmMakefile* mf = this->GetMakefile();
+ {
+ std::string linkCmdVar = this->GetGeneratorTarget()
+ ->GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName());
+ const char *linkCmd = mf->GetDefinition(linkCmdVar);
+ if (linkCmd)
+ {
+ cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+ return linkCmds;
+ }
+ }
+ switch (this->GetTarget()->GetType()) {
case cmTarget::STATIC_LIBRARY: {
- // Check if you have a non archive way to create the static library.
- {
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- linkCmdVar += "_CREATE_STATIC_LIBRARY";
- if (const char *linkCmd =
- this->GetMakefile()->GetDefinition(linkCmdVar.c_str()))
- {
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
- return linkCmds;
- }
- }
-
// We have archive link commands set. First, delete the existing archive.
+ {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
+ mf->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL);
linkCmds.push_back(cmakeCommand + " -E remove $out");
-
+ }
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
{
std::string linkCmdVar = "CMAKE_";
linkCmdVar += this->TargetLinkLanguage;
linkCmdVar += "_ARCHIVE_CREATE";
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+ const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
}
{
std::string linkCmdVar = "CMAKE_";
linkCmdVar += this->TargetLinkLanguage;
linkCmdVar += "_ARCHIVE_FINISH";
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+ const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
}
return linkCmds;
}
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
- case cmTarget::EXECUTABLE: {
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- switch (targetType) {
- case cmTarget::SHARED_LIBRARY:
- linkCmdVar += "_CREATE_SHARED_LIBRARY";
- break;
- case cmTarget::MODULE_LIBRARY:
- linkCmdVar += "_CREATE_SHARED_MODULE";
- break;
- case cmTarget::EXECUTABLE:
- linkCmdVar += "_LINK_EXECUTABLE";
- break;
- default:
- assert(0 && "Unexpected target type");
- }
-
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
- return linkCmds;
- }
+ case cmTarget::EXECUTABLE:
+ break;
default:
assert(0 && "Unexpected target type");
}
return std::vector<std::string>();
}
-void cmNinjaNormalTargetGenerator::WriteLinkStatement()
+
+static int calculateCommandLineLengthLimit(int linkRuleLength)
{
- cmTarget::TargetType targetType = this->GetTarget()->GetType();
+#ifdef _WIN32
+ return 8000 - linkRuleLength;
+#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__)
+ // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
+ return ((int)sysconf(_SC_ARG_MAX)) - linkRuleLength - 1000;
+#else
+ (void)linkRuleLength;
+ return -1;
+#endif
+}
+
+void cmNinjaNormalTargetGenerator::WriteLinkStatement()
+{
+ cmTarget& target = *this->GetTarget();
+ const std::string cfgName = this->GetConfigName();
std::string targetOutput = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
+ target.GetFullPath(cfgName).c_str());
std::string targetOutputReal = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName(),
- /*implib=*/false,
- /*realpath=*/true).c_str());
+ target.GetFullPath(cfgName,
+ /*implib=*/false,
+ /*realpath=*/true).c_str());
std::string targetOutputImplib = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName(),
- /*implib=*/true).c_str());
+ target.GetFullPath(cfgName,
+ /*implib=*/true).c_str());
- if (this->GetTarget()->IsAppBundleOnApple())
+ if (target.IsAppBundleOnApple())
{
// Create the app bundle
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
+ std::string outpath = target.GetDirectory(cfgName);
this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
// Calculate the output path
@@ -415,23 +400,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
targetOutputReal += this->TargetNameReal;
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
}
- else if (this->GetTarget()->IsFrameworkOnApple())
+ else if (target.IsFrameworkOnApple())
{
// Create the library framework.
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
- this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, outpath);
+ this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
+ target.GetDirectory(cfgName));
}
- else if(this->GetTarget()->IsCFBundleOnApple())
+ else if(target.IsCFBundleOnApple())
{
// Create the core foundation bundle.
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
- this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath);
+ this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
+ target.GetDirectory(cfgName));
}
// Write comments.
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
+ const cmTarget::TargetType targetType = target.GetType();
this->GetBuildFileStream()
<< "# Link build statements for "
<< cmTarget::GetTargetTypeName(targetType)
@@ -444,8 +428,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute the comment.
cmOStringStream comment;
- comment << "Link the " << this->GetVisibleTypeName() << " "
- << targetOutputReal;
+ comment <<
+ "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal;
// Compute outputs.
cmNinjaDeps outputs;
@@ -455,16 +439,26 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmNinjaDeps explicitDeps = this->GetObjects();
cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ cmMakefile* mf = this->GetMakefile();
+
std::string frameworkPath;
std::string linkPath;
- this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
- vars["FLAGS"],
- vars["LINK_FLAGS"],
- frameworkPath,
- linkPath,
- this->GetGeneratorTarget());
-
- this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
+ cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
+
+ std::string createRule =
+ genTarget.GetCreateRuleVariable(this->TargetLinkLanguage,
+ this->GetConfigName());
+ bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
+ cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
+ localGen.GetTargetFlags(vars["LINK_LIBRARIES"],
+ vars["FLAGS"],
+ vars["LINK_FLAGS"],
+ frameworkPath,
+ linkPath,
+ &genTarget,
+ useWatcomQuote);
+
+ this->addPoolNinjaVariable("JOB_POOL_LINK", &target, vars);
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
vars["LINK_FLAGS"] = cmGlobalNinjaGenerator
@@ -475,44 +469,48 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute architecture specific link flags. Yes, these go into a different
// variable for executables, probably due to a mistake made when duplicating
// code between the Makefile executable and library generators.
- std::string flags = (targetType == cmTarget::EXECUTABLE
- ? vars["FLAGS"]
- : vars["ARCH_FLAGS"]);
- this->GetLocalGenerator()->AddArchitectureFlags(flags,
- this->GetGeneratorTarget(),
- this->TargetLinkLanguage,
- this->GetConfigName());
- if (targetType == cmTarget::EXECUTABLE) {
- vars["FLAGS"] = flags;
- } else {
- vars["ARCH_FLAGS"] = flags;
- }
- if (this->GetTarget()->HasSOName(this->GetConfigName())) {
- vars["SONAME_FLAG"] =
- this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
+ if (targetType == cmTarget::EXECUTABLE)
+ {
+ std::string t = vars["FLAGS"];
+ localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ vars["FLAGS"] = t;
+ }
+ else
+ {
+ std::string t = vars["ARCH_FLAGS"];
+ localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ vars["ARCH_FLAGS"] = t;
+ t = "";
+ localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName);
+ vars["LANGUAGE_COMPILE_FLAGS"] = t;
+ }
+
+ if (target.HasSOName(cfgName))
+ {
+ vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
vars["SONAME"] = this->TargetNameSO;
- if (targetType == cmTarget::SHARED_LIBRARY) {
- std::string install_name_dir = this->GetTarget()
- ->GetInstallNameDirForBuildTree(this->GetConfigName());
-
- if (!install_name_dir.empty()) {
- vars["INSTALLNAME_DIR"] =
- this->GetLocalGenerator()->Convert(install_name_dir.c_str(),
- cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL, false);
+ if (targetType == cmTarget::SHARED_LIBRARY)
+ {
+ std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName);
+ if (!install_dir.empty())
+ {
+ vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
+ cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL,
+ false);
+ }
}
}
- }
- if (!this->TargetNameImport.empty()) {
- const std::string impLibPath = this->GetLocalGenerator()
- ->ConvertToOutputFormat(targetOutputImplib.c_str(),
- cmLocalGenerator::SHELL);
+ if (!this->TargetNameImport.empty())
+ {
+ const std::string impLibPath = localGen.ConvertToOutputFormat(
+ targetOutputImplib,
+ cmLocalGenerator::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
- }
+ }
- cmMakefile* mf = this->GetMakefile();
if (!this->SetMsvcTargetPdbVariable(vars))
{
// It is common to place debug symbols at a specific place,
@@ -520,11 +518,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string prefix;
std::string base;
std::string suffix;
- this->GetTarget()->GetFullNameComponents(prefix, base, suffix);
+ target.GetFullNameComponents(prefix, base, suffix);
std::string dbg_suffix = ".dbg";
// TODO: Where to document?
if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX"))
+ {
dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX");
+ }
vars["TARGET_PDB"] = base + suffix + dbg_suffix;
}
@@ -536,12 +536,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
std::string& linkLibraries = vars["LINK_LIBRARIES"];
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
+ std::string& link_path = vars["LINK_PATH"];
+ std::replace(link_path.begin(), link_path.end(), '\\', '/');
}
const std::vector<cmCustomCommand> *cmdLists[3] = {
- &this->GetTarget()->GetPreBuildCommands(),
- &this->GetTarget()->GetPreLinkCommands(),
- &this->GetTarget()->GetPostBuildCommands()
+ &target.GetPreBuildCommands(),
+ &target.GetPreLinkCommands(),
+ &target.GetPostBuildCommands()
};
std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
@@ -551,99 +553,102 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
&postBuildCmdLines
};
- for (unsigned i = 0; i != 3; ++i) {
+ for (unsigned i = 0; i != 3; ++i)
+ {
for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- this->GetLocalGenerator()->AppendCustomCommandLines(&*ci,
- *cmdLineLists[i]);
+ ci != cmdLists[i]->end(); ++ci)
+ {
+ cmCustomCommandGenerator ccg(*ci, cfgName, mf);
+ localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
+ }
}
- }
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
// the link commands.
- if (!preLinkCmdLines.empty()) {
- const std::string homeOutDir = this->GetLocalGenerator()
- ->ConvertToOutputFormat(this->GetMakefile()->GetHomeOutputDirectory(),
- cmLocalGenerator::SHELL);
+ if (!preLinkCmdLines.empty())
+ {
+ const std::string homeOutDir = localGen.ConvertToOutputFormat(
+ mf->GetHomeOutputDirectory(),
+ cmLocalGenerator::SHELL);
preLinkCmdLines.push_back("cd " + homeOutDir);
- }
+ }
- vars["PRE_LINK"] =
- this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines);
- std::string postBuildCmdLine =
- this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines);
+ vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines);
+ std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines);
cmNinjaVars symlinkVars;
- if (targetOutput == targetOutputReal) {
+ if (targetOutput == targetOutputReal)
+ {
vars["POST_BUILD"] = postBuildCmdLine;
- } else {
+ }
+ else
+ {
vars["POST_BUILD"] = ":";
symlinkVars["POST_BUILD"] = postBuildCmdLine;
- }
+ }
- int linkRuleLength = this->GetGlobalGenerator()->
- GetRuleCmdLength(this->LanguageLinkerRule());
+ cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
int commandLineLengthLimit = 1;
const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
- if (!this->GetMakefile()->IsDefinitionSet(forceRspFile) &&
- cmSystemTools::GetEnv(forceRspFile) == 0) {
-#ifdef _WIN32
- commandLineLengthLimit = 8000 - linkRuleLength;
-#elif defined(__linux) || defined(__APPLE__)
- // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
- commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000;
-#else
- (void)linkRuleLength;
- commandLineLengthLimit = -1;
-#endif
- }
-
- //Get the global generator as we are going to be call WriteBuild numerous
- //times in the following section
- cmGlobalNinjaGenerator* globalGenerator = this->GetGlobalGenerator();
+ if (!mf->IsDefinitionSet(forceRspFile) &&
+ cmSystemTools::GetEnv(forceRspFile) == 0)
+ {
+ commandLineLengthLimit = calculateCommandLineLengthLimit(
+ globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));
+ }
+ const std::string rspfile =
+ std::string(cmake::GetCMakeFilesDirectoryPostSlash())
+ + target.GetName() + ".rsp";
- const std::string rspfile = std::string
- (cmake::GetCMakeFilesDirectoryPostSlash()) +
- this->GetTarget()->GetName() + ".rsp";
+ // Gather order-only dependencies.
+ cmNinjaDeps orderOnlyDeps;
+ this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(),
+ orderOnlyDeps);
// Write the build statement for this target.
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
- comment.str(),
- this->LanguageLinkerRule(),
- outputs,
- explicitDeps,
- implicitDeps,
- emptyDeps,
- vars,
- rspfile,
- commandLineLengthLimit);
-
- if (targetOutput != targetOutputReal &&
- !this->GetTarget()->IsFrameworkOnApple()) {
- if (targetType == cmTarget::EXECUTABLE) {
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
- "Create executable symlink " + targetOutput,
- "CMAKE_SYMLINK_EXECUTABLE",
- cmNinjaDeps(1, targetOutput),
- cmNinjaDeps(1, targetOutputReal),
- emptyDeps,
- emptyDeps,
- symlinkVars);
- } else {
+ globalGen.WriteBuild(this->GetBuildFileStream(),
+ comment.str(),
+ this->LanguageLinkerRule(),
+ outputs,
+ explicitDeps,
+ implicitDeps,
+ orderOnlyDeps,
+ vars,
+ rspfile,
+ commandLineLengthLimit);
+
+ if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple())
+ {
+ if (targetType == cmTarget::EXECUTABLE)
+ {
+ globalGen.WriteBuild(this->GetBuildFileStream(),
+ "Create executable symlink " + targetOutput,
+ "CMAKE_SYMLINK_EXECUTABLE",
+ cmNinjaDeps(1, targetOutput),
+ cmNinjaDeps(1, targetOutputReal),
+ emptyDeps,
+ emptyDeps,
+ symlinkVars);
+ }
+ else
+ {
cmNinjaDeps symlinks;
const std::string soName = this->GetTargetFilePath(this->TargetNameSO);
// If one link has to be created.
- if (targetOutputReal == soName || targetOutput == soName) {
+ if (targetOutputReal == soName || targetOutput == soName)
+ {
symlinkVars["SONAME"] = soName;
- } else {
+ }
+ else
+ {
symlinkVars["SONAME"] = "";
symlinks.push_back(soName);
- }
+ }
symlinks.push_back(targetOutput);
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
+ globalGen.WriteBuild(this->GetBuildFileStream(),
"Create library symlink " + targetOutput,
"CMAKE_SYMLINK_LIBRARY",
symlinks,
@@ -651,23 +656,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
emptyDeps,
emptyDeps,
symlinkVars);
+ }
}
- }
- if (!this->TargetNameImport.empty()) {
+ if (!this->TargetNameImport.empty())
+ {
// Since using multiple outputs would mess up the $out variable, use an
// alias for the import library.
- globalGenerator->WritePhonyBuild(this->GetBuildFileStream(),
- "Alias for import library.",
- cmNinjaDeps(1, targetOutputImplib),
- cmNinjaDeps(1, targetOutputReal));
- }
+ globalGen.WritePhonyBuild(this->GetBuildFileStream(),
+ "Alias for import library.",
+ cmNinjaDeps(1, targetOutputImplib),
+ cmNinjaDeps(1, targetOutputReal));
+ }
// Add aliases for the file name and the target name.
- globalGenerator->AddTargetAlias(this->TargetNameOut,
- this->GetTarget());
- globalGenerator->AddTargetAlias(this->GetTargetName(),
- this->GetTarget());
+ globalGen.AddTargetAlias(this->TargetNameOut, &target);
+ globalGen.AddTargetAlias(this->GetTargetName(), &target);
}
//----------------------------------------------------------------------------