mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 23:00:50 +08:00
cmLocalGenerator::MayBeRelativeToWorkDir: take care of all cases
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
#include "cmGeneratorTarget.h"
|
#include "cmGeneratorTarget.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmOutputConverter.h"
|
#include "cmOutputConverter.h"
|
||||||
#include "cmState.h"
|
|
||||||
#include "cmStateDirectory.h"
|
#include "cmStateDirectory.h"
|
||||||
#include "cmStateSnapshot.h"
|
#include "cmStateSnapshot.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
@@ -17,9 +16,8 @@
|
|||||||
class cmGlobalGenerator;
|
class cmGlobalGenerator;
|
||||||
|
|
||||||
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
|
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
|
||||||
cmMakefile* mf, WorkDir wd)
|
cmMakefile* mf)
|
||||||
: cmLocalGenerator(gg, mf)
|
: cmLocalGenerator(gg, mf)
|
||||||
, WorkingDirectory(wd)
|
|
||||||
{
|
{
|
||||||
this->ConfigNames =
|
this->ConfigNames =
|
||||||
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
||||||
@@ -29,21 +27,9 @@ cmLocalCommonGenerator::~cmLocalCommonGenerator() = default;
|
|||||||
|
|
||||||
std::string const& cmLocalCommonGenerator::GetWorkingDirectory() const
|
std::string const& cmLocalCommonGenerator::GetWorkingDirectory() const
|
||||||
{
|
{
|
||||||
if (this->WorkingDirectory == WorkDir::TopBin) {
|
|
||||||
return this->GetState()->GetBinaryDirectory();
|
|
||||||
}
|
|
||||||
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmLocalCommonGenerator::MaybeRelativeToWorkDir(
|
|
||||||
std::string const& path) const
|
|
||||||
{
|
|
||||||
if (this->WorkingDirectory == WorkDir::TopBin) {
|
|
||||||
return this->MaybeRelativeToTopBinDir(path);
|
|
||||||
}
|
|
||||||
return this->MaybeRelativeToCurBinDir(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
|
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
|
||||||
cmGeneratorTarget const* target, std::string const& config)
|
cmGeneratorTarget const* target, std::string const& config)
|
||||||
{
|
{
|
||||||
|
@@ -20,15 +20,8 @@ class cmSourceFile;
|
|||||||
*/
|
*/
|
||||||
class cmLocalCommonGenerator : public cmLocalGenerator
|
class cmLocalCommonGenerator : public cmLocalGenerator
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
enum class WorkDir
|
|
||||||
{
|
|
||||||
TopBin,
|
|
||||||
CurBin,
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf, WorkDir wd);
|
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
|
||||||
~cmLocalCommonGenerator() override;
|
~cmLocalCommonGenerator() override;
|
||||||
|
|
||||||
std::vector<std::string> const& GetConfigNames() const
|
std::vector<std::string> const& GetConfigNames() const
|
||||||
@@ -36,9 +29,7 @@ public:
|
|||||||
return this->ConfigNames;
|
return this->ConfigNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& GetWorkingDirectory() const;
|
virtual std::string const& GetWorkingDirectory() const;
|
||||||
|
|
||||||
std::string MaybeRelativeToWorkDir(std::string const& path) const;
|
|
||||||
|
|
||||||
std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
|
std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
|
||||||
std::string const& config) override;
|
std::string const& config) override;
|
||||||
@@ -48,8 +39,6 @@ public:
|
|||||||
cmGeneratorTarget const* gt = nullptr) override;
|
cmGeneratorTarget const* gt = nullptr) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WorkDir WorkingDirectory;
|
|
||||||
|
|
||||||
std::vector<std::string> ConfigNames;
|
std::vector<std::string> ConfigNames;
|
||||||
|
|
||||||
friend class cmCommonTargetGenerator;
|
friend class cmCommonTargetGenerator;
|
||||||
|
@@ -89,7 +89,7 @@ class cmLocalGenerator : public cmOutputConverter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
|
cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
|
||||||
virtual ~cmLocalGenerator();
|
~cmLocalGenerator() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the makefile for this directory.
|
* Generate the makefile for this directory.
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
|
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
|
||||||
cmMakefile* mf)
|
cmMakefile* mf)
|
||||||
: cmLocalCommonGenerator(gg, mf, WorkDir::TopBin)
|
: cmLocalCommonGenerator(gg, mf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +188,18 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
|
|||||||
return static_cast<cmGlobalNinjaGenerator*>(this->GetGlobalGenerator());
|
return static_cast<cmGlobalNinjaGenerator*>(this->GetGlobalGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const& cmLocalNinjaGenerator::GetWorkingDirectory() const
|
||||||
|
{
|
||||||
|
return this->GetState()->GetBinaryDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmLocalNinjaGenerator::MaybeRelativeToWorkDir(
|
||||||
|
std::string const& path) const
|
||||||
|
{
|
||||||
|
return this->GetGlobalNinjaGenerator()->NinjaOutputPath(
|
||||||
|
this->MaybeRelativeToTopBinDir(path));
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual protected methods.
|
// Virtual protected methods.
|
||||||
|
|
||||||
std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
|
std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
|
||||||
|
@@ -52,6 +52,10 @@ public:
|
|||||||
const cmake* GetCMakeInstance() const;
|
const cmake* GetCMakeInstance() const;
|
||||||
cmake* GetCMakeInstance();
|
cmake* GetCMakeInstance();
|
||||||
|
|
||||||
|
std::string const& GetWorkingDirectory() const override;
|
||||||
|
|
||||||
|
std::string MaybeRelativeToWorkDir(std::string const& path) const override;
|
||||||
|
|
||||||
/// @returns the relative path between the HomeOutputDirectory and this
|
/// @returns the relative path between the HomeOutputDirectory and this
|
||||||
/// local generators StartOutputDirectory.
|
/// local generators StartOutputDirectory.
|
||||||
std::string GetHomeRelativeOutputPath() const
|
std::string GetHomeRelativeOutputPath() const
|
||||||
|
@@ -111,7 +111,7 @@ private:
|
|||||||
|
|
||||||
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
|
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
|
||||||
cmGlobalGenerator* gg, cmMakefile* mf)
|
cmGlobalGenerator* gg, cmMakefile* mf)
|
||||||
: cmLocalCommonGenerator(gg, mf, WorkDir::CurBin)
|
: cmLocalCommonGenerator(gg, mf)
|
||||||
{
|
{
|
||||||
this->MakefileVariableSize = 0;
|
this->MakefileVariableSize = 0;
|
||||||
this->ColorMakefile = false;
|
this->ColorMakefile = false;
|
||||||
|
@@ -16,6 +16,7 @@ class cmOutputConverter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmOutputConverter(cmStateSnapshot const& snapshot);
|
cmOutputConverter(cmStateSnapshot const& snapshot);
|
||||||
|
virtual ~cmOutputConverter() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the given remote path to a relative path with respect to
|
* Convert the given remote path to a relative path with respect to
|
||||||
@@ -27,6 +28,15 @@ public:
|
|||||||
std::string MaybeRelativeToTopBinDir(std::string const& path) const;
|
std::string MaybeRelativeToTopBinDir(std::string const& path) const;
|
||||||
std::string MaybeRelativeToCurBinDir(std::string const& path) const;
|
std::string MaybeRelativeToCurBinDir(std::string const& path) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The effective working directory can be different for each generator.
|
||||||
|
* By default, equivalent to the current binary directory.
|
||||||
|
*/
|
||||||
|
virtual std::string MaybeRelativeToWorkDir(std::string const& path) const
|
||||||
|
{
|
||||||
|
return this->MaybeRelativeToCurBinDir(path);
|
||||||
|
}
|
||||||
|
|
||||||
std::string const& GetRelativePathTopSource() const;
|
std::string const& GetRelativePathTopSource() const;
|
||||||
std::string const& GetRelativePathTopBinary() const;
|
std::string const& GetRelativePathTopBinary() const;
|
||||||
void SetRelativePathTop(std::string const& topSource,
|
void SetRelativePathTop(std::string const& topSource,
|
||||||
|
Reference in New Issue
Block a user