summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2020-01-09 15:14:38 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2020-01-16 18:54:26 (GMT)
commitfd0ba705ce37f54eb88f17e257e5a57e823351bb (patch)
treedea7eabac44a62c27cdec775195bcda2859f9abb /Source
parentfd84f510f8f22244853115782af58cad5884934b (diff)
downloadCMake-fd0ba705ce37f54eb88f17e257e5a57e823351bb.zip
CMake-fd0ba705ce37f54eb88f17e257e5a57e823351bb.tar.gz
CMake-fd0ba705ce37f54eb88f17e257e5a57e823351bb.tar.bz2
add_custom_command: check if a relative path should be an in-source path
This still is broken for dependencies on generated paths where they get generated to the source directory rather than the build directory however, but there's no way to determine that is the case. Fixes: #20194
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCustomCommandGenerator.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx7
2 files changed, 7 insertions, 4 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index a595007..34f815f 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -8,7 +8,6 @@
#include <cmext/algorithm>
-#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmGeneratorExpression.h"
@@ -30,9 +29,6 @@ void AppendPaths(const std::vector<std::string>& inputs,
cmExpandedList(cge->Evaluate(lg, config));
for (std::string& it : result) {
cmSystemTools::ConvertToUnixSlashes(it);
- if (cmContains(it, '/') && !cmSystemTools::FileIsFullPath(it)) {
- it = cmStrCat(lg->GetMakefile()->GetCurrentBinaryDirectory(), '/', it);
- }
if (cmSystemTools::FileIsFullPath(it)) {
it = cmSystemTools::CollapseFullPath(
it, lg->GetMakefile()->GetHomeOutputDirectory());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f9d8e55..6b282ab 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2004,6 +2004,13 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Treat the name as relative to the source directory in which it
// was given.
dep = cmStrCat(this->GetCurrentSourceDirectory(), '/', inName);
+
+ // If the in-source path does not exist, assume it instead lives in the
+ // binary directory.
+ if (!cmSystemTools::FileExists(dep)) {
+ dep = cmStrCat(this->GetCurrentBinaryDirectory(), '/', inName);
+ }
+
return true;
}