diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt index 07c9a3d9089d..fdd823f64e35 100644 --- a/platforms/nuttx/CMakeLists.txt +++ b/platforms/nuttx/CMakeLists.txt @@ -258,7 +258,7 @@ if (CONFIG_BUILD_KERNEL) COMMAND mv ${PX4_BINARY_DIR}/bin/nsh ${PX4_BINARY_DIR}/init COMMAND install -D ${PX4_BINARY_DIR}/init -t ${PX4_BINARY_DIR}/boot COMMAND rm -f ${PX4_BINARY_DIR}/init - DEPENDS ${PX4_BINARY_DIR}/bin/nsh + DEPENDS nuttx_app_bins ) add_custom_target(boot_bins DEPENDS ${PX4_BINARY_DIR}/boot/init) diff --git a/platforms/nuttx/NuttX/CMakeLists.txt b/platforms/nuttx/NuttX/CMakeLists.txt index 042d175900e5..e48507409f0e 100644 --- a/platforms/nuttx/NuttX/CMakeLists.txt +++ b/platforms/nuttx/NuttX/CMakeLists.txt @@ -277,7 +277,6 @@ if (CONFIG_BUILD_KERNEL) ELFLDNAME="${LDSCRIPT}" USERLIBS="${userlibs}" > ${CMAKE_CURRENT_BINARY_DIR}/nuttx_apps_install.log COMMAND touch nuttx_install.stamp - BYPRODUCTS ${PX4_BINARY_DIR}/bin/nsh DEPENDS ${nuttx_userlibs} nuttx_startup ) add_custom_target(nuttx_app_bins DEPENDS nuttx_install.stamp) diff --git a/platforms/nuttx/cmake/bin_romfs.cmake b/platforms/nuttx/cmake/bin_romfs.cmake index 113344dfbc0a..6d39205868f2 100644 --- a/platforms/nuttx/cmake/bin_romfs.cmake +++ b/platforms/nuttx/cmake/bin_romfs.cmake @@ -82,25 +82,29 @@ function(make_bin_romfs) # Strip the elf files to reduce romfs image size + set(stripped_deps) + if (${STRIPPED} STREQUAL "y") # Preserve the files with debug symbols - add_custom_target(debug_${OUTPREFIX} + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_copy.stamp COMMAND cp -r ${BINDIR}/. ${BINDIR}_debug + COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_copy.stamp DEPENDS ${DEPS} ) + add_custom_target(${OUTPREFIX}_copy DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_copy.stamp) + # Then strip the binaries in place - add_custom_command(OUTPUT ${OUTPREFIX}_stripped_bins + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_stripped.stamp COMMAND for f in * \; do if [ -f "$$f" ]; then ${CMAKE_STRIP} $$f --strip-unneeded \; fi \; done - DEPENDS ${DEPS} debug_${OUTPREFIX} + COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_stripped.stamp + DEPENDS ${DEPS} ${OUTPREFIX}_copy WORKING_DIRECTORY ${BINDIR} ) - else() - add_custom_command(OUTPUT ${OUTPREFIX}_stripped_bins - COMMAND touch ${BINDIR} - ) + + list(APPEND stripped_deps ${CMAKE_CURRENT_BINARY_DIR}/${OUTPREFIX}_stripped.stamp) endif() # Make sure we have what we need @@ -128,7 +132,7 @@ function(make_bin_romfs) ${SED} 's/^unsigned char/const unsigned char/g' >${OUTPREFIX}_romfsimg.h COMMAND mv ${OUTPREFIX}_romfsimg.h ${OUTDIR}/${OUTPREFIX}_romfsimg.h COMMAND rm -f ${OUTPREFIX}_romfs.img - DEPENDS ${OUTDIR} ${DEPS} ${OUTPREFIX}_stripped_bins + DEPENDS ${DEPS} ${stripped_deps} ) add_custom_target(${OUTPREFIX}_romfsimg DEPENDS ${OUTDIR}/${OUTPREFIX}_romfsimg.h)