From e0c4e292bfb0994a1dd5d398acb9b22631526f41 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 4 Jan 2024 17:13:50 +0900 Subject: [PATCH] cmake: do not run objcopy for macOS The mach-o support of objcopy is fragile at best and often results in a broken output. It's better not to rely on it. This matches what the non-cmake version does. --- CMakeLists.txt | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f03424ad5..0364cc8bcf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -688,16 +688,28 @@ else() list(APPEND nuttx_libs_paths $) endforeach() - add_custom_command( - OUTPUT nuttx.rel - COMMAND - ${CMAKE_C_COMPILER} ARGS -r $<$:-m32> - $ $<$>:-Wl,--start-group> - ${nuttx_libs_paths} ${nuttx_extra_libs} - $<$>:-Wl,--end-group> -o nuttx.rel - COMMAND ${CMAKE_OBJCOPY} --redefine-syms=nuttx-names.dat nuttx.rel - DEPENDS ${nuttx_libs} ${nuttx_extra_libs} sim_head - COMMAND_EXPAND_LISTS) + if(APPLE) + add_custom_command( + OUTPUT nuttx.rel + COMMAND + ${CMAKE_C_COMPILER} ARGS -r $<$:-m32> + $ $<$>:-Wl,--start-group> + ${nuttx_libs_paths} ${nuttx_extra_libs} + $<$>:-Wl,--end-group> -o nuttx.rel + DEPENDS ${nuttx_libs} ${nuttx_extra_libs} sim_head + COMMAND_EXPAND_LISTS) + else() + add_custom_command( + OUTPUT nuttx.rel + COMMAND + ${CMAKE_C_COMPILER} ARGS -r $<$:-m32> + $ $<$>:-Wl,--start-group> + ${nuttx_libs_paths} ${nuttx_extra_libs} + $<$>:-Wl,--end-group> -o nuttx.rel + COMMAND ${CMAKE_OBJCOPY} --redefine-syms=nuttx-names.dat nuttx.rel + DEPENDS ${nuttx_libs} ${nuttx_extra_libs} sim_head + COMMAND_EXPAND_LISTS) + endif() add_custom_target(nuttx-rel DEPENDS nuttx.rel $<$>:nuttx.ld>)