cmake: update zephyr_file to use cmake_path()

Since the introduction of zephyr_file() then the minimum required CMake
version has become 3.20.
Update zephyr_file() to use cmake_path insteasd of set().
This allows us to normalize the path and thereby also remove duplicates
in the list as paths are normalized.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2024-05-28 09:56:17 +02:00 committed by Fabio Baltieri
commit 8b3d4c6f0d

View file

@ -2624,11 +2624,11 @@ Please provide one of following: APPLICATION_ROOT, CONF_FILES")
# `set(<var> CACHE)`, so let's update current scope variable to absolute
# path from `APPLICATION_SOURCE_DIR`.
if(NOT IS_ABSOLUTE ${path})
set(abs_path ${APPLICATION_SOURCE_DIR}/${path})
list(FIND ${ZFILE_APPLICATION_ROOT} ${path} index)
cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY ${APPLICATION_SOURCE_DIR} NORMALIZE)
if(NOT ${index} LESS 0)
list(REMOVE_AT ${ZFILE_APPLICATION_ROOT} ${index})
list(INSERT ${ZFILE_APPLICATION_ROOT} ${index} ${abs_path})
list(INSERT ${ZFILE_APPLICATION_ROOT} ${index} ${path})
endif()
endif()
endforeach()
@ -2645,6 +2645,7 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
endif()
endforeach()
list(REMOVE_DUPLICATES ZFILE_APPLICATION_ROOT)
# This updates the provided argument in parent scope (callers scope)
set(${ZFILE_APPLICATION_ROOT} ${${ZFILE_APPLICATION_ROOT}} PARENT_SCOPE)
endif()