cmCommonTargetGenerator: Store working directory for relative paths

The Makefile generators run tools with the current working directory set
to the subdirectory of the build tree for the each target.  The Ninja
generator runs tools with the current working directory set to the top
of the build tree.  Tell cmCommonTargetGenerator where the working
directory will be so it can compute proper relative paths.
This commit is contained in:
Brad King 2015-07-29 12:55:58 -04:00
parent 7371d8f3b4
commit 70c21301b2
4 changed files with 12 additions and 6 deletions

View File

@ -20,8 +20,12 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) cmCommonTargetGenerator::cmCommonTargetGenerator(
: GeneratorTarget(gt) cmOutputConverter::RelativeRoot wd,
cmGeneratorTarget* gt
)
: WorkingDirectory(wd)
, GeneratorTarget(gt)
, Target(gt->Target) , Target(gt->Target)
, Makefile(gt->Makefile) , Makefile(gt->Makefile)
, LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator)) , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
@ -152,7 +156,7 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
if (!mod_dir.empty()) if (!mod_dir.empty())
{ {
mod_dir = this->Convert(mod_dir, mod_dir = this->Convert(mod_dir,
cmLocalGenerator::START_OUTPUT, this->WorkingDirectory,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
} }
else else

View File

@ -29,7 +29,8 @@ class cmTarget;
class cmCommonTargetGenerator class cmCommonTargetGenerator
{ {
public: public:
cmCommonTargetGenerator(cmGeneratorTarget* gt); cmCommonTargetGenerator(cmOutputConverter::RelativeRoot wd,
cmGeneratorTarget* gt);
virtual ~cmCommonTargetGenerator(); virtual ~cmCommonTargetGenerator();
std::string const& GetConfigName() const; std::string const& GetConfigName() const;
@ -46,6 +47,7 @@ protected:
// Helper to add flag for windows .def file. // Helper to add flag for windows .def file.
void AddModuleDefinitionFlag(std::string& flags); void AddModuleDefinitionFlag(std::string& flags);
cmOutputConverter::RelativeRoot WorkingDirectory;
cmGeneratorTarget* GeneratorTarget; cmGeneratorTarget* GeneratorTarget;
cmTarget* Target; cmTarget* Target;
cmMakefile* Makefile; cmMakefile* Makefile;

View File

@ -33,7 +33,7 @@
#include <ctype.h> #include <ctype.h>
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(target) : cmCommonTargetGenerator(cmOutputConverter::START_OUTPUT, target)
, OSXBundleGenerator(0) , OSXBundleGenerator(0)
, MacOSXContentGenerator(0) , MacOSXContentGenerator(0)
{ {

View File

@ -58,7 +58,7 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
} }
cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(target), : cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target),
MacOSXContentGenerator(0), MacOSXContentGenerator(0),
OSXBundleGenerator(0), OSXBundleGenerator(0),
MacContentFolders(), MacContentFolders(),