cmake: fix installed application binaries to match Application.mk

Match the Application.mk install rule: keep the application attribute
symbols (nx_stacksize etc.) through strip as NX_KEEP does, and mark
the installed binaries executable, since ld -r output is not and
filesystem images built from bin/ refuse to exec.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
This commit is contained in:
raiden00pl 2026-08-04 18:38:51 +02:00 committed by Xiang Xiao
parent 3e142bbced
commit b5dccf4fe3

View file

@ -199,7 +199,15 @@ function(nuttx_add_application)
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin_debug/${ELF_NAME}
${CMAKE_BINARY_DIR}/bin/${ELF_NAME}
COMMAND ${CMAKE_STRIP} ${CMAKE_BINARY_DIR}/bin/${ELF_NAME}
# keep the application attribute symbols through strip so the binary
# loader can still read them, see NX_KEEP in Application.mk
COMMAND
${CMAKE_STRIP} -K nx_stacksize -K nx_priority -K nx_uid -K nx_gid -K
nx_mode ${CMAKE_BINARY_DIR}/bin/${ELF_NAME}
# match the Application.mk install rule: ld -r output is not marked
# executable, but filesystem images built from bin/ must carry the
# execute permission
COMMAND chmod +x ${CMAKE_BINARY_DIR}/bin/${ELF_NAME}
COMMENT "Building ELF:${ELF_NAME}"
COMMAND_EXPAND_LISTS)
else()