This is an automated email from the ASF dual-hosted git repository.
anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f479de022ef cmake: Remove an old link before file(CREATE_LINK).
f479de022ef is described below
commit f479de022ef3f281e01dbc248b1a199693a907e1
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 19 16:53:19 2026 +0200
cmake: Remove an old link before file(CREATE_LINK).
nuttx_create_symlink() sets policy CMP0205 to NEW. With this policy,
file(CREATE_LINK) in CMake 4.3.0 and 4.3.1 removes an existing
destination that is a directory recursively, also when the destination
is a symbolic link to a directory. The removal follows the link: it
deletes the files in the source tree, and then it fails on the link
with "existing path cannot be removed: Not a directory".
A reconfigure creates the board links again. Thus on these CMake
versions each reconfigure deletes all files in boards/.../<board>/src
(the link arch/<arch>/src/board/board) and in boards/<arch>/<chip>/drivers
(the link drivers/platform), and the configuration fails. The libcxx,
libcxxabi, uClibc++ and libmcs include links have the same problem.
Remove an existing link with file(REMOVE) first. file(REMOVE) removes
the link, not its target. CMake 4.3.2 has the same fix in
file(CREATE_LINK) (CMake issue #27747). A destination that is a copy
(Windows, or COPY_ON_ERROR) is not a link, so its behavior does not
change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
cmake/nuttx_create_symlink.cmake | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/cmake/nuttx_create_symlink.cmake b/cmake/nuttx_create_symlink.cmake
index 4cbaa5c0daa..5750783ab4f 100644
--- a/cmake/nuttx_create_symlink.cmake
+++ b/cmake/nuttx_create_symlink.cmake
@@ -21,6 +21,12 @@
#
##############################################################################
function(nuttx_create_symlink old new)
+ # Remove an old link itself. With CMP0205 NEW, CMake 4.3.0 and 4.3.1 remove
+ # the content of the directory that the old link points to.
+ if(IS_SYMLINK ${new})
+ file(REMOVE ${new})
+ endif()
+
if(IS_DIRECTORY ${old} AND CMAKE_HOST_SYSTEM_NAME MATCHES
"MSYS|CYGWIN|Windows")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${old} ${new})