summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-01-26 21:32:17 (GMT)
committerBrad King <brad.king@kitware.com>2011-01-26 23:02:02 (GMT)
commit88548a45fbd35205469ac9fd332349551e172496 (patch)
tree7fb78e2070cd8320d73b0f4f2c8e1b2cf962e5d3 /Source
parent7befc00783ca9739e7585ff4d2b645a762a38396 (diff)
downloadCMake-88548a45fbd35205469ac9fd332349551e172496.zip
CMake-88548a45fbd35205469ac9fd332349551e172496.tar.gz
CMake-88548a45fbd35205469ac9fd332349551e172496.tar.bz2
Handle relative WORKING_DIRECTORY in add_custom_(command|target)
This also fixes handling of trailing slashes in the directory name.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx7
-rw-r--r--Source/cmAddCustomCommandCommand.h2
-rw-r--r--Source/cmAddCustomTargetCommand.cxx8
-rw-r--r--Source/cmAddCustomTargetCommand.h2
4 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 7af6ec8..502829e 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -286,6 +286,13 @@ bool cmAddCustomCommandCommand
return false;
}
+ // Convert working directory to a full path.
+ if(!working.empty())
+ {
+ const char* build_dir = this->Makefile->GetCurrentOutputDirectory();
+ working = cmSystemTools::CollapseFullPath(working.c_str(), build_dir);
+ }
+
// Choose which mode of the command to use.
bool escapeOldStyle = !verbatim;
if(source.empty() && output.empty())
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 490e043..47b542c 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -110,6 +110,8 @@ public:
"will be treated as PRE_LINK.\n"
"If WORKING_DIRECTORY is specified the command will be executed "
"in the directory given. "
+ "If it is a relative path it will be interpreted relative to the "
+ "build tree directory corresponding to the current source directory. "
"If COMMENT is set, the value will be displayed as a "
"message before the commands are executed at build time. "
"If APPEND is specified the COMMAND and DEPENDS option values "
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index edb787b..27dea98 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -166,6 +166,14 @@ bool cmAddCustomTargetCommand
}
}
+ // Convert working directory to a full path.
+ if(!working_directory.empty())
+ {
+ const char* build_dir = this->Makefile->GetCurrentOutputDirectory();
+ working_directory =
+ cmSystemTools::CollapseFullPath(working_directory.c_str(), build_dir);
+ }
+
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
cmTarget* target =
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index 7a2b396..6d94fb2 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -79,6 +79,8 @@ public:
"empty target will be created. "
"If WORKING_DIRECTORY is set, then the command will be run in that "
"directory. "
+ "If it is a relative path it will be interpreted relative to the "
+ "build tree directory corresponding to the current source directory. "
"If COMMENT is set, the value will be displayed as a "
"message before the commands are executed at build time. "
"Dependencies listed with the DEPENDS argument may reference files "