File: GetFilenameComponent.cmake

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (17 lines) | stat: -rw-r--r-- 581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Reimplementation of native CMake command,
# for correct handling of leading dot,
# https://cmake.org/pipermail/cmake-developers/2011-June/013526.html
function(get_filename_component)
    _get_filename_component (${ARGN})
    list(GET ARGN 0 VAR)
    list(GET ARGN 2 CMD)
    if(${CMD} STREQUAL "EXT")
        string(REGEX MATCHALL "\\.[^.]*" PARTS ${${VAR}})
        list(LENGTH PARTS LEN)
        if(LEN GREATER 1)
            math(EXPR LEN "${LEN} - 1")
            list(GET PARTS ${LEN} ${VAR})
        endif()
    endif()
    set(${VAR} ${${VAR}} PARENT_SCOPE)
endfunction()