Add _qt_internal_path_is_prefix
compatibility
Direct equivalent to `cmake_path(IS_PREFIX)` except for `NORMALIZE` support. Change-Id: Ic17990b93d458073ddc1b860a7f5d5b81bd63ea8 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
6865c21e41
commit
0630f055b8
@ -790,3 +790,44 @@ function(_qt_internal_relative_path path_var)
|
||||
endif()
|
||||
set(${arg_OUTPUT_VARIABLE} "${${arg_OUTPUT_VARIABLE}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Compatibility of `cmake_path(IS_PREFIX)`
|
||||
#
|
||||
# NORMALIZE keyword is not supported
|
||||
#
|
||||
# Synopsis
|
||||
#
|
||||
# _qt_internal_path_is_prefix(<path-var> <input> <out-var>)
|
||||
#
|
||||
# Arguments
|
||||
#
|
||||
# `path-var`
|
||||
# Equivalent to `cmake_path(IS_PREFIX <path-var>)`.
|
||||
#
|
||||
# `input`
|
||||
# Equivalent to `cmake_path(IS_PREFIX <input>)`.
|
||||
#
|
||||
# `out-var`
|
||||
# Equivalent to `cmake_path(IS_PREFIX <out-var>)`.
|
||||
function(_qt_internal_path_is_prefix path_var input out_var)
|
||||
|
||||
# Make sure the path ends with `/`
|
||||
if(NOT ${path_var} MATCHES "/$")
|
||||
set(${path_var} "${${path_var}}/")
|
||||
endif()
|
||||
# For the case input == path_var, we need to also include a trailing `/` to match the
|
||||
# previous change. We discard the actual path for input so we can add it unconditionally
|
||||
set(input "${input}/")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.20)
|
||||
string(FIND "${input}" "${${path_var}}" find_pos)
|
||||
if(find_pos EQUAL 0)
|
||||
# input starts_with path_var
|
||||
set(${out_var} ON)
|
||||
else()
|
||||
set(${out_var} OFF)
|
||||
endif()
|
||||
else()
|
||||
cmake_path(IS_PREFIX ${path_var} ${input} ${out_var})
|
||||
endif()
|
||||
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user