summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx10
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx15
-rw-r--r--Source/cmOutputConverter.cxx57
-rw-r--r--Source/cmOutputConverter.h13
-rw-r--r--Source/cmcmd.cxx6
-rw-r--r--Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake12
7 files changed, 73 insertions, 43 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 4245037..bbc9c54 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2495,8 +2495,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld);
auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
auto lgd = this->CreateLocalGenerator(mfd.get());
- lgd->SetRelativePathTopSource(dir_top_src);
- lgd->SetRelativePathTopBinary(dir_top_bld);
+ lgd->SetRelativePathTop(dir_top_src, dir_top_bld);
this->Makefiles.push_back(std::move(mfd));
this->LocalGenerators.push_back(std::move(lgd));
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b752c41..1e6624e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -4695,10 +4695,12 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(
std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
{
- // We force conversion because Xcode breakpoints do not work unless
- // they are in a file named relative to the source tree.
- return cmSystemTools::ForceToRelativePath(
- this->CurrentRootGenerator->GetCurrentSourceDirectory(), p);
+ std::string const& rootSrc =
+ this->CurrentRootGenerator->GetCurrentSourceDirectory();
+ if (cmSystemTools::IsSubDirectory(p, rootSrc)) {
+ return cmSystemTools::ForceToRelativePath(rootSrc, p);
+ }
+ return p;
}
std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 0f8cdca..7c4af7d 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1508,13 +1508,12 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
}
// Setup relative path top directories.
- if (cmValue relativePathTopSource =
- mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) {
- this->SetRelativePathTopSource(*relativePathTopSource);
- }
- if (cmValue relativePathTopBinary =
- mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) {
- this->SetRelativePathTopBinary(*relativePathTopBinary);
+ cmValue relativePathTopSource =
+ mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE");
+ cmValue relativePathTopBinary =
+ mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY");
+ if (relativePathTopSource && relativePathTopBinary) {
+ this->SetRelativePathTop(*relativePathTopSource, *relativePathTopBinary);
}
} else {
cmSystemTools::Error("Directory Information file not found");
@@ -1849,7 +1848,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
cmSystemTools::Touch(DepTimestamp.GenericString(), true);
// clear the dependencies files generated by the compiler
- std::vector<std::string> dependencies = cmExpandedList(depsFiles);
+ std::vector<std::string> dependencies = cmExpandedList(depsFiles, true);
cmDependsCompiler depsManager;
depsManager.SetVerbose(verbose);
depsManager.ClearDependencies(dependencies);
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index b143170..e62e0cd 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -34,6 +34,7 @@ cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot)
assert(this->StateSnapshot.IsValid());
this->ComputeRelativePathTopSource();
this->ComputeRelativePathTopBinary();
+ this->ComputeRelativePathTopRelation();
}
void cmOutputConverter::ComputeRelativePathTopSource()
@@ -69,6 +70,22 @@ void cmOutputConverter::ComputeRelativePathTopBinary()
this->RelativePathTopBinary = snapshot.GetDirectory().GetCurrentBinary();
}
+void cmOutputConverter::ComputeRelativePathTopRelation()
+{
+ if (cmSystemTools::ComparePath(this->RelativePathTopSource,
+ this->RelativePathTopBinary)) {
+ this->RelativePathTopRelation = TopRelation::InSource;
+ } else if (cmSystemTools::IsSubDirectory(this->RelativePathTopBinary,
+ this->RelativePathTopSource)) {
+ this->RelativePathTopRelation = TopRelation::BinInSrc;
+ } else if (cmSystemTools::IsSubDirectory(this->RelativePathTopSource,
+ this->RelativePathTopBinary)) {
+ this->RelativePathTopRelation = TopRelation::SrcInBin;
+ } else {
+ this->RelativePathTopRelation = TopRelation::Separate;
+ }
+}
+
std::string const& cmOutputConverter::GetRelativePathTopSource() const
{
return this->RelativePathTopSource;
@@ -79,27 +96,45 @@ std::string const& cmOutputConverter::GetRelativePathTopBinary() const
return this->RelativePathTopBinary;
}
-void cmOutputConverter::SetRelativePathTopSource(std::string const& top)
-{
- this->RelativePathTopSource = top;
-}
-
-void cmOutputConverter::SetRelativePathTopBinary(std::string const& top)
+void cmOutputConverter::SetRelativePathTop(std::string const& topSource,
+ std::string const& topBinary)
{
- this->RelativePathTopBinary = top;
+ this->RelativePathTopSource = topSource;
+ this->RelativePathTopBinary = topBinary;
+ this->ComputeRelativePathTopRelation();
}
std::string cmOutputConverter::MaybeRelativeTo(
std::string const& local_path, std::string const& remote_path) const
{
- bool bothInBinary =
- PathEqOrSubDir(local_path, this->RelativePathTopBinary) &&
+ bool localInBinary = PathEqOrSubDir(local_path, this->RelativePathTopBinary);
+ bool remoteInBinary =
PathEqOrSubDir(remote_path, this->RelativePathTopBinary);
- bool bothInSource =
- PathEqOrSubDir(local_path, this->RelativePathTopSource) &&
+ bool localInSource = PathEqOrSubDir(local_path, this->RelativePathTopSource);
+ bool remoteInSource =
PathEqOrSubDir(remote_path, this->RelativePathTopSource);
+ switch (this->RelativePathTopRelation) {
+ case TopRelation::Separate:
+ // Checks are independent.
+ break;
+ case TopRelation::BinInSrc:
+ localInSource = localInSource && !localInBinary;
+ remoteInSource = remoteInSource && !remoteInBinary;
+ break;
+ case TopRelation::SrcInBin:
+ localInBinary = localInBinary && !localInSource;
+ remoteInBinary = remoteInBinary && !remoteInSource;
+ break;
+ case TopRelation::InSource:
+ // Checks are identical.
+ break;
+ };
+
+ bool const bothInBinary = localInBinary && remoteInBinary;
+ bool const bothInSource = localInSource && remoteInSource;
+
if (bothInBinary || bothInSource) {
return cmSystemTools::ForceToRelativePath(local_path, remote_path);
}
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index 335442d..d19bccc 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -29,8 +29,8 @@ public:
std::string const& GetRelativePathTopSource() const;
std::string const& GetRelativePathTopBinary() const;
- void SetRelativePathTopSource(std::string const& top);
- void SetRelativePathTopBinary(std::string const& top);
+ void SetRelativePathTop(std::string const& topSource,
+ std::string const& topBinary);
enum OutputFormat
{
@@ -147,8 +147,17 @@ private:
// safely by the build tools.
std::string RelativePathTopSource;
std::string RelativePathTopBinary;
+ enum class TopRelation
+ {
+ Separate,
+ BinInSrc,
+ SrcInBin,
+ InSource,
+ };
+ TopRelation RelativePathTopRelation = TopRelation::Separate;
void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary();
+ void ComputeRelativePathTopRelation();
std::string MaybeRelativeTo(std::string const& local_path,
std::string const& remote_path) const;
};
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index ba61a83..f1c1bdc 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1286,8 +1286,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
// FIXME: With advanced add_subdirectory usage, these are
// not necessarily the same as the generator originally used.
// We should pass all these directories through an info file.
- lgd->SetRelativePathTopSource(homeDir);
- lgd->SetRelativePathTopBinary(homeOutDir);
+ lgd->SetRelativePathTop(homeDir, homeOutDir);
// Actually scan dependencies.
return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2;
@@ -1569,8 +1568,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
// FIXME: With advanced add_subdirectory usage, these are
// not necessarily the same as the generator originally used.
// We should pass all these directories through an info file.
- lgd->SetRelativePathTopSource(homeDir);
- lgd->SetRelativePathTopBinary(homeOutDir);
+ lgd->SetRelativePathTop(homeDir, homeOutDir);
return cmTransformDepfile(format, *lgd, args[8], args[9]) ? 0 : 2;
}
diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
index 304e9de..e5bfac4 100644
--- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
+++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
@@ -76,18 +76,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src)
run_symlink_test_case("${case}" -S "../${name}/${src}" -B "../${name}/${bin}")
# Verify paths passed to compiler.
- if(case MATCHES "^(different|asymmetric)-bin_in_src$")
- # FIXME: Some generators compute incorrect relative paths.
- message(STATUS "${case}-exe - SKIPPED")
- message(STATUS "${case}-exe-build - SKIPPED")
- return()
- endif()
- if(case MATCHES "^(different|asymmetric)-src_in_bin$" AND RunCMake_GENERATOR STREQUAL "Xcode")
- # FIXME: The Xcode generator computes an incorrect relative path.
- message(STATUS "${case}-exe - SKIPPED")
- message(STATUS "${case}-exe-build - SKIPPED")
- return()
- endif()
unset(RunCMake_TEST_VARIANT_DESCRIPTION)
run_symlink_test_case("${case}-exe" -S "${src}" -B "${bin}")
if (RunCMake_GENERATOR MATCHES "Xcode")