Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Fix some dependencies for kernel mode build #851

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ROMFS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ set(extras_dependencies)

# sysinit script for kernel mode
if(CONFIG_BUILD_KERNEL)
add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/rc.sysinit
add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/rc.sysinit rc.sysinit.stamp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PX4_BINARY_DIR}/NuttX/rc.sysinit ${romfs_gen_root_dir}/init.d/rc.sysinit
COMMAND ${CMAKE_COMMAND} -E touch rc.sysinit.stamp
DEPENDS
${PX4_BINARY_DIR}/NuttX/rc.sysinit
romfs_copy.stamp
COMMENT "ROMFS: copying rc.sysinit"
)
list(APPEND extras_dependencies
${romfs_gen_root_dir}/init.d/rc.sysinit
rc.sysinit.stamp
)
endif()

Expand Down
15 changes: 4 additions & 11 deletions platforms/nuttx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ if (CONFIG_BUILD_KERNEL)
# Build module.a into module.elf
set(BIN px4-${MAIN}.elf)
add_executable(${BIN} ${PX4_SOURCE_DIR}/platforms/nuttx/src/px4/common/process/main.cpp)
set_target_properties(${BIN} PROPERTIES OUTPUT_NAME ${BIN})
set_target_properties(${BIN} PROPERTIES OUTPUT_NAME ${MAIN})
set_target_properties(${BIN} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR}/bin)
add_dependencies(${BIN} nuttx_crt0 ${module})
target_compile_options(${BIN} PRIVATE -Dentry=${MAIN}_main)

Expand Down Expand Up @@ -328,19 +329,11 @@ if (CONFIG_BUILD_KERNEL)
# The individual module deps are FUBAR, so this cannot be done
#target_link_libraries(${BIN} PRIVATE ${module})
target_link_libraries(${BIN} INTERFACE perf nuttx_c)

# Some global deps are also FUBAR, so this must be done
target_link_libraries(px4_platform board_bus_info)

# Install the executable to /bin
add_custom_target(${BIN}_install
COMMAND mkdir -p ${PX4_BINARY_DIR}/bin
COMMAND install -D ${PX4_BINARY_DIR}/${BIN} -t ${PX4_BINARY_DIR}/bin
COMMAND mv ${PX4_BINARY_DIR}/bin/${BIN} ${PX4_BINARY_DIR}/bin/${MAIN}
COMMAND rm -f ${PX4_BINARY_DIR}/${BIN}
DEPENDS ${BIN}
)

list(APPEND px4_bins ${BIN}_install)
list(APPEND px4_bins ${BIN})
endforeach()

# Create the /bin ROMFS
Expand Down
4 changes: 3 additions & 1 deletion platforms/nuttx/NuttX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,19 @@ if (CONFIG_BUILD_KERNEL)

get_property(CRT0_OBJ TARGET nuttx_crt0 PROPERTY IMPORTED_OBJECTS)

add_custom_target(nuttx_app_bins
add_custom_command(OUTPUT nuttx_install.stamp
COMMAND mkdir -p ${PX4_BINARY_DIR}/bin
COMMAND make -C ${NUTTX_SRC_DIR}/apps install --no-print-directory --silent
ARCHCRT0OBJ="${CRT0_OBJ}"
BINDIR="${PX4_BINARY_DIR}/bin"
TOPDIR="${NUTTX_DIR}"
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)
endif()

###############################################################################
Expand Down
Loading