Skip to content

Commit

Permalink
cmake: fix relative path calculate error
Browse files Browse the repository at this point in the history
```C
file(RELATIVE_PATH relpath ${ZEPHYR_BASE}/include ${path})
```

The prerequisite path assumed here must be the prefix of ZEPHYR,
but if use symbolic links it will calculate error: like this:
#74647 (comment)

Fixes: #74647

Signed-off-by: Lingao Meng <[email protected]>
  • Loading branch information
LingaoM committed Jun 27, 2024
1 parent 4123c53 commit 5035af4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,10 @@ function(zephyr_linker_sources location)
endif()

# Find the relative path to the linker file from the include folder.
file(RELATIVE_PATH relpath ${ZEPHYR_BASE}/include ${path})
get_filename_component(ZEPHYR_BASE_REALPATH "${ZEPHYR_BASE}/include" REALPATH)
get_filename_component(PATH_REALPATH "${path}" REALPATH)

file(RELATIVE_PATH relpath "${ZEPHYR_BASE_REALPATH}" "${PATH_REALPATH}")

# Create strings to be written into the file
set (include_str "/* Sort key: \"${SORT_KEY}\" */#include \"${relpath}\"")
Expand Down

0 comments on commit 5035af4

Please sign in to comment.