From e50a36df488be05dfbc85005c88ec8d4c5314a76 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Thu, 24 Jan 2019 22:38:52 +0530 Subject: cmGetFilenameComponentCommand: Add more components LAST_EXT: gets last extension from filename with multiple periods NAME_WLE: gets the name without the last extension --- Source/cmGetFilenameComponentCommand.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index ffb895e..163b4c8 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -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 -- cgit v0.12 From 7a25ef326bc53293f2dd288a7c092b4080658821 Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Thu, 24 Jan 2019 22:41:22 +0530 Subject: Help: Add documentation for new get_filename_component components --- Help/command/get_filename_component.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst index 3e3c9c3..f55499a 100644 --- a/Help/command/get_filename_component.rst +++ b/Help/command/get_filename_component.rst @@ -15,6 +15,8 @@ Sets ```` to a component of ````, where ```` 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. -- cgit v0.12 From edda30d0f5c7230b7854d8d714159ad68a2344ef Mon Sep 17 00:00:00 2001 From: Tushar Maheshwari Date: Thu, 24 Jan 2019 22:42:09 +0530 Subject: Tests: Add tests for LAST_EXT and NAME_WLE --- Tests/RunCMake/get_filename_component/KnownComponents.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index ac77ac3..54b858f 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -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}) -- cgit v0.12 From 2a9220c34d26d33b5733ba41a25c44e02c8cdb3a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Jan 2019 08:20:24 -0500 Subject: Help: Add notes for topic 'get_filename_component_last_ext' --- Help/release/dev/get_filename_component_last_ext.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/get_filename_component_last_ext.rst diff --git a/Help/release/dev/get_filename_component_last_ext.rst b/Help/release/dev/get_filename_component_last_ext.rst new file mode 100644 index 0000000..2487dbc --- /dev/null +++ b/Help/release/dev/get_filename_component_last_ext.rst @@ -0,0 +1,6 @@ +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. -- cgit v0.12