Commit 1593e16d authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'get_filename_component_last_ext'

2a9220c3 Help: Add notes for topic 'get_filename_component_last_ext'
edda30d0 Tests: Add tests for LAST_EXT and NAME_WLE
7a25ef32 Help: Add documentation for new get_filename_component components
e50a36df

 cmGetFilenameComponentCommand: Add more components
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2853
parents dc752c9d 2a9220c3
......@@ -15,6 +15,8 @@ Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of:
NAME = File name without directory
EXT = File name longest extension (.b.c from d/a.b.c)
NAME_WE = File name without directory or longest extension
LAST_EXT = File name last extention (.c from d/a.b.c)
NAME_WLE = File name without directory or last extension
PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)
Paths are returned with forward slashes and have no trailing slashes.
......
get_filename_component_last_ext
-------------------------------
* The :command:`get_filename_component` command gained new
``LAST_EXT`` and ``NAME_WLE`` variants to work with the
extension after the last ``.`` in the name.
......@@ -88,6 +88,10 @@ bool cmGetFilenameComponentCommand::InitialPass(
result = cmSystemTools::GetFilenameExtension(filename);
} else if (args[2] == "NAME_WE") {
result = cmSystemTools::GetFilenameWithoutExtension(filename);
} else if (args[2] == "LAST_EXT") {
result = cmSystemTools::GetFilenameLastExtension(filename);
} else if (args[2] == "NAME_WLE") {
result = cmSystemTools::GetFilenameWithoutLastExtension(filename);
} 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
......
......@@ -11,8 +11,10 @@ set(expect_DIRECTORY "/path/to")
set(expect_NAME "filename.ext.in")
set(expect_EXT ".ext.in")
set(expect_NAME_WE "filename")
set(expect_LAST_EXT ".in")
set(expect_NAME_WLE "filename.ext")
set(expect_PATH "/path/to")
foreach(c DIRECTORY NAME EXT NAME_WE PATH)
foreach(c DIRECTORY NAME EXT NAME_WE LAST_EXT NAME_WLE PATH)
get_filename_component(actual_${c} "${filename}" ${c})
check("${c}" "${actual_${c}}" "${expect_${c}}")
list(APPEND non_cache_vars actual_${c})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment