summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-08-21 13:28:53 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-08-21 13:28:53 (GMT)
commit4ae9362b5be154781543b9255e06366a528db359 (patch)
tree4c8b4a19d2ce5a9c13c432748c13b7440eb1537a /Source
parent162e7b5675673cb5521a2b1e98c0dc66d3bad4fd (diff)
parente89ea3d190492e41b37425ff021311c2b471f1b9 (diff)
downloadCMake-4ae9362b5be154781543b9255e06366a528db359.zip
CMake-4ae9362b5be154781543b9255e06366a528db359.tar.gz
CMake-4ae9362b5be154781543b9255e06366a528db359.tar.bz2
Merge topic 'get-filename-component-base-dir'
e89ea3d1 get_filename_component: Teach new BASE_DIR parameter.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 13a9afb..0f56c8e 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -93,11 +93,23 @@ bool cmGetFilenameComponentCommand
else if (args[2] == "ABSOLUTE" ||
args[2] == "REALPATH")
{
+ // If the path given is relative, evaluate it relative to the
+ // current source directory unless the user passes a different
+ // base directory.
+ std::string baseDir = this->Makefile->GetCurrentSourceDirectory();
+ for(unsigned int i=3; i < args.size(); ++i)
+ {
+ if(args[i] == "BASE_DIR")
+ {
+ ++i;
+ if(i < args.size())
+ {
+ baseDir = args[i];
+ }
+ }
+ }
// Collapse the path to its simplest form.
- // If the path given is relative evaluate it relative to the
- // current source directory.
- result = cmSystemTools::CollapseFullPath(
- filename, this->Makefile->GetCurrentSourceDirectory());
+ result = cmSystemTools::CollapseFullPath(filename, baseDir);
if(args[2] == "REALPATH")
{
// Resolve symlinks if possible