mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 09:58:50 +08:00
32 lines
826 B
CMake
32 lines
826 B
CMake
# sets out_var to YES if filename has extension .h or .hpp, NO otherwise
|
|
function(is_header out_var filename)
|
|
set(res "NO")
|
|
get_filename_component(ext "${filename}" LAST_EXT)
|
|
if((ext STREQUAL ".h") OR (ext STREQUAL ".hpp"))
|
|
set(res "YES")
|
|
endif()
|
|
set("${out_var}" "${res}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(remove_prefix out prefix str)
|
|
string(LENGTH "${prefix}" len)
|
|
string(SUBSTRING "${str}" ${len} -1 res)
|
|
set("${out}" "${res}" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
function(is_prefix out prefix str)
|
|
string(LENGTH "${prefix}" plen)
|
|
string(LENGTH "${str}" slen)
|
|
if(plen GREATER slen)
|
|
set(res NO)
|
|
else()
|
|
string(SUBSTRING "${str}" 0 ${plen} pstr)
|
|
if(pstr STREQUAL prefix)
|
|
set(res YES)
|
|
else()
|
|
set(res NO)
|
|
endif()
|
|
endif()
|
|
set(${out} ${res} PARENT_SCOPE)
|
|
endfunction()
|