summaryrefslogtreecommitdiffstats
path: root/Source/cmGetFilenameComponentCommand.cxx
diff options
context:
space:
mode:
authorJames Johnston <johnstonj.public@codenest.com>2015-08-18 03:55:38 (GMT)
committerJames Johnston <johnstonj.public@codenest.com>2015-08-18 03:55:38 (GMT)
commite89ea3d190492e41b37425ff021311c2b471f1b9 (patch)
tree35c88e18b8ac49fc2f115140c73ba04b8df3f0a1 /Source/cmGetFilenameComponentCommand.cxx
parenta38ea312c02eec6e4ee61015f70920999bf79ff9 (diff)
downloadCMake-e89ea3d190492e41b37425ff021311c2b471f1b9.zip
CMake-e89ea3d190492e41b37425ff021311c2b471f1b9.tar.gz
CMake-e89ea3d190492e41b37425ff021311c2b471f1b9.tar.bz2
get_filename_component: Teach new BASE_DIR parameter.
In the get_filename_component command, add a new BASE_DIR parameter to use with the ABSOLUTE and REALPATH options. This will be used when finding an absolute path from a relative path.
Diffstat (limited to 'Source/cmGetFilenameComponentCommand.cxx')
-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