From 03f3b4e727d7d5f6c3ba4f0a64a2f440cff43a7d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Dec 2013 09:41:45 -0500 Subject: [PATCH] Replace rule placeholder consistently (#14667) The placeholder is supposed to be the base intermediate files directory for the current target. This is how it gets replaced during link line generation. However, during compile line generation we replace it with the directory containing the current object file which may be a subdirectory. Fix replacement of in the generated compile lines to be the base intermediate files directory. This was expoxed by commit 42ba1b08 (VS: Separate compiler and linker PDB files, 2013-04-05) when we added a "/Fd/" flag to the MSVC compile line in order to match the VS IDE default compiler program database location in the intermediate files directory. For source files in a subdirectory relative to the current target this caused the wrong location to be used for the compiler program database. This becomes particularly important when using precompiled headers. While at it, use the cmTarget::GetSupportDirectory method to compute the intermediate files directory for the current target instead of repeating the logic in a few places. --- Source/cmMakefileExecutableTargetGenerator.cxx | 12 +++++------- Source/cmMakefileLibraryTargetGenerator.cxx | 12 +++++------- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e4219a945..3a71bd6eb 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -338,13 +338,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.CMTarget = this->Target; vars.Language = linkLanguage; vars.Objects = buildObjs.c_str(); - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->Target->GetName(); - objdir += ".dir"; - objdir = this->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); + std::string objectDir = this->Target->GetSupportDirectory(); + objectDir = this->Convert(objectDir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objectDir.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index ea9663f2e..ffe68e5b2 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -577,13 +577,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.CMTarget = this->Target; vars.Language = linkLanguage; vars.Objects = buildObjs.c_str(); - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->Target->GetName(); - objdir += ".dir"; - objdir = this->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); + std::string objectDir = this->Target->GetSupportDirectory(); + objectDir = this->Convert(objectDir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objectDir.c_str(); vars.Target = targetOutPathReal.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0829cab6a..5e6c54822 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -638,7 +638,7 @@ cmMakefileTargetGenerator cmLocalGenerator::NONE, cmLocalGenerator::SHELL).c_str(); vars.Object = shellObj.c_str(); - std::string objectDir = cmSystemTools::GetFilenamePath(obj); + std::string objectDir = this->Target->GetSupportDirectory(); objectDir = this->Convert(objectDir.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 898aa0e9e..9c8b4810b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -543,7 +543,7 @@ cmNinjaTargetGenerator vars["DEP_FILE"] = objectFileName + ".d";; EnsureParentDirectoryExists(objectFileName); - std::string objectDir = cmSystemTools::GetFilenamePath(objectFileName); + std::string objectDir = this->Target->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( ConvertToNinjaPath(objectDir.c_str()).c_str(), cmLocalGenerator::SHELL);