Skip to content

Commit

Permalink
[nrf fromtree] cmake: update zephyr_file to use cmake_path()
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 8b3d4c6)
  • Loading branch information
tejlmand authored and anangl committed Jul 3, 2024
1 parent 10c0de0 commit 06cfbf0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2609,11 +2609,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()
Expand All @@ -2630,6 +2630,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()
Expand Down

0 comments on commit 06cfbf0

Please sign in to comment.