summaryrefslogtreecommitdiffstats
path: root/Source/cmGetFilenameComponentCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-02-09 14:23:55 (GMT)
committerBrad King <brad.king@kitware.com>2009-02-09 14:23:55 (GMT)
commitae873d4a8987fc840d7b7515719d438918ea8f5b (patch)
treefa5cbf6ec67c6faa059de0ff61ccc5f2fc13a970 /Source/cmGetFilenameComponentCommand.cxx
parentca096a4596c8993cbadd5fc6e612ac349db6355c (diff)
downloadCMake-ae873d4a8987fc840d7b7515719d438918ea8f5b.zip
CMake-ae873d4a8987fc840d7b7515719d438918ea8f5b.tar.gz
CMake-ae873d4a8987fc840d7b7515719d438918ea8f5b.tar.bz2
ENH: Add get_filename_component(... REALPATH)
This patch from Philip Lowman creates a REALPATH mode in the get_filename_component command. It is like ABSOLUTE, but will also resolve symlinks (which ABSOLUTE once did but was broken long ago). See issue #8423.
Diffstat (limited to 'Source/cmGetFilenameComponentCommand.cxx')
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index d06efe8..8502e57 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -75,7 +75,8 @@ bool cmGetFilenameComponentCommand
{
result = cmSystemTools::GetFilenameWithoutExtension(filename);
}
- else if (args[2] == "ABSOLUTE")
+ else if (args[2] == "ABSOLUTE" ||
+ args[2] == "REALPATH")
{
// If the path given is relative evaluate it relative to the
// current source directory.
@@ -92,6 +93,11 @@ bool cmGetFilenameComponentCommand
// Collapse the path to its simplest form.
result = cmSystemTools::CollapseFullPath(filename.c_str());
+ if(args[2] == "REALPATH")
+ {
+ // Resolve symlinks if possible
+ result = cmSystemTools::GetRealPath(filename.c_str());
+ }
}
else
{