# SPDX-FileCopyrightText: 2021 Dmitry Kazakov # # SPDX-License-Identifier: BSD-3-Clause # # krita_to_native_path( ) # # Converts path separators of the list into the native format # and stores the result in # # Usage: # # krita_to_native_path("${KRITA_PYTHONPATH}" _krita_pythonpath) function (krita_to_native_path path_list output_var) if(WIN32) if(${CMAKE_VERSION} VERSION_LESS "3.20.0") foreach (_path ${path_list}) string(REPLACE "//" "/" _path "${_path}") string(REPLACE "/" "\\" _path "${_path}") list(APPEND _output_var "${_path}") endforeach() set (${output_var} ${_output_var} PARENT_SCOPE) else() cmake_path(CONVERT "${path_list}" TO_NATIVE_PATH_LIST _output_var NORMALIZE) set (${output_var} ${_output_var} PARENT_SCOPE) endif() else() set (${output_var} ${path_list} PARENT_SCOPE) endif() endfunction() # krita_to_native_environment_path_list( ) # # Converts the list of paths in into the native format # and then joins them into a string suitable to be assigned to # PATH (or PATH-like) variable. On Windows the string is joined # using ';' separator. On other platforms with ':' separator. # # To avoid conversion back to a list object, the function adds # separators in a form of generators: $ or $ # # Usage: # # krita_to_native_environment_path_list("${KRITA_PYTHONPATH}" _krita_pythonpath) function (krita_to_native_environment_path_list path_list output_var) krita_to_native_path("${path_list}" _output_var) if(WIN32) list(JOIN _output_var $ _output_var) else() list(JOIN _output_var ":" _output_var) endif() set (${output_var} ${_output_var} PARENT_SCOPE) endfunction()