CMake: workaround unsupported cmake_path(IS_PREFIX ..) in v3.20
Add a macro that implements something similar to cmake_path's IS_PREFIX which isn't supported in older versions of CMake. This caused the build-bot to fail.
This commit is contained in:
parent
65e4d169ba
commit
d5ce854fb1
@ -57,6 +57,25 @@ macro(path_ensure_trailing_slash
|
||||
unset(_path_sep)
|
||||
endmacro()
|
||||
|
||||
# Our own version of `cmake_path(IS_PREFIX ..)`.
|
||||
# This can be removed when 3.20 or greater is the minimum supported version.
|
||||
macro(path_is_prefix
|
||||
path_prefix path result_var
|
||||
)
|
||||
# Remove when CMAKE version is bumped to "3.20" or greater.
|
||||
# `cmake_path(IS_PREFIX ${path_prefix} ${path} NORMALIZE result_var)`
|
||||
# Get the normalized paths (needed to remove `..`).
|
||||
get_filename_component(_abs_prefix "${${path_prefix}}" ABSOLUTE)
|
||||
get_filename_component(_abs_suffix "${${path}}" ABSOLUTE)
|
||||
string(LENGTH "${_abs_prefix}" _len)
|
||||
string(SUBSTRING "${_abs_suffix}" 0 "${_len}" _substr)
|
||||
string(COMPARE EQUAL "${_abs_prefix}" "${_substr}" "${result_var}")
|
||||
unset(_abs_prefix)
|
||||
unset(_abs_suffix)
|
||||
unset(_len)
|
||||
unset(_substr)
|
||||
endmacro()
|
||||
|
||||
# foo_bar.spam --> foo_barMySuffix.spam
|
||||
macro(file_suffix
|
||||
file_name_new file_name file_suffix
|
||||
|
@ -151,7 +151,7 @@ if(WITH_PYTHON)
|
||||
# Installing into `site-packages`, warn when installing into `./../lib/`
|
||||
# which script authors almost certainly don't want.
|
||||
if(EXISTS ${LIBDIR})
|
||||
cmake_path(IS_PREFIX LIBDIR "${PYTHON_SITE_PACKAGES}" NORMALIZE _is_prefix)
|
||||
path_is_prefix(LIBDIR PYTHON_SITE_PACKAGES _is_prefix)
|
||||
if(_is_prefix)
|
||||
message(WARNING "
|
||||
Building Blender with the following configuration:
|
||||
|
@ -36,7 +36,7 @@ set(TEST_PYTHON_EXE_EXTRA_ARGS)
|
||||
|
||||
# Check if this a Blender managed Python installation, if so, don't add `*.pyc` files.
|
||||
if(LIBDIR)
|
||||
cmake_path(IS_PREFIX LIBDIR "${TEST_PYTHON_EXE}" NORMALIZE _is_prefix)
|
||||
path_is_prefix(LIBDIR TEST_PYTHON_EXE _is_prefix)
|
||||
if(_is_prefix)
|
||||
# Keep the Python in Blender's SVN LIBDIR pristine, to avoid conflicts on updating.
|
||||
set(TEST_PYTHON_EXE_EXTRA_ARGS "-B")
|
||||
|
Loading…
Reference in New Issue
Block a user