mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 11:06:04 +08:00
cmake remove circular linking and reorganize
- px4_add_module now requires MAIN - px4_add_library doesn't automatically link
This commit is contained in:
@@ -42,7 +42,7 @@ endif()
|
||||
add_executable(${FW_NAME} ${PX4_SOURCE_DIR}/src/platforms/empty.c)
|
||||
add_dependencies(${FW_NAME} git_nuttx nuttx_build)
|
||||
|
||||
get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES)
|
||||
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
|
||||
|
||||
# build NuttX
|
||||
add_subdirectory(NuttX ${PX4_BINARY_DIR}/NuttX)
|
||||
@@ -76,24 +76,41 @@ file(RELATIVE_PATH PX4_BINARY_DIR_REL ${CMAKE_CURRENT_BINARY_DIR} ${PX4_BINARY_D
|
||||
# because even relative linker script paths are different for linux, mac and windows
|
||||
CYGPATH(PX4_BINARY_DIR PX4_BINARY_DIR_CYG)
|
||||
|
||||
target_link_libraries(${FW_NAME}
|
||||
target_link_libraries(nuttx_arch
|
||||
INTERFACE
|
||||
drivers_board
|
||||
drivers_arch
|
||||
drivers_boards_common
|
||||
drivers_boards_common_arch
|
||||
)
|
||||
|
||||
target_link_libraries(nuttx_c INTERFACE nuttx_drivers)
|
||||
target_link_libraries(nuttx_cxx INTERFACE nuttx_c)
|
||||
|
||||
target_link_libraries(${FW_NAME} PRIVATE
|
||||
|
||||
-nodefaultlibs
|
||||
-nostdlib
|
||||
|
||||
-fno-exceptions
|
||||
-fno-rtti
|
||||
|
||||
-Wl,--script=${PX4_BINARY_DIR_CYG}/NuttX/nuttx/configs/${BOARD}/scripts/${LD_SCRIPT}
|
||||
-Wl,-Map=${CONFIG}.map
|
||||
-Wl,--warn-common,--gc-sections
|
||||
-Wl,--warn-common
|
||||
-Wl,--gc-sections
|
||||
|
||||
-Wl,--start-group
|
||||
${module_libraries}
|
||||
${nuttx_libs}
|
||||
${nuttx_libs}
|
||||
-Wl,--end-group
|
||||
|
||||
m
|
||||
gcc
|
||||
)
|
||||
|
||||
target_link_libraries(${FW_NAME} PRIVATE ${module_libraries})
|
||||
target_link_libraries(${FW_NAME} PRIVATE modules__uORB)
|
||||
|
||||
if (config_romfs_root)
|
||||
add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS)
|
||||
target_link_libraries(${FW_NAME} romfs)
|
||||
target_link_libraries(${FW_NAME} PRIVATE romfs)
|
||||
endif()
|
||||
|
||||
# create px4 file (combined firmware and metadata)
|
||||
@@ -212,4 +229,3 @@ add_custom_target(profile
|
||||
DEPENDS ${FW_NAME} ${PX4_SOURCE_DIR}/platforms/nuttx/Debug/poor-mans-profiler.sh
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ function(px4_nuttx_make_uavcan_bootloadable)
|
||||
add_custom_command(OUTPUT ${uavcan_bl_imange_name}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/make_can_boot_descriptor.py
|
||||
-v --use-git-hash ${BIN} ${uavcan_bl_imange_name}
|
||||
DEPENDS ${BIN})
|
||||
DEPENDS ${BIN}
|
||||
)
|
||||
add_custom_target(build_uavcan_bl_${BOARD} ALL DEPENDS ${uavcan_bl_imange_name})
|
||||
endfunction()
|
||||
|
||||
@@ -188,11 +189,11 @@ function(px4_os_add_flags)
|
||||
${PX4_BINARY_DIR}/NuttX/apps/include
|
||||
)
|
||||
|
||||
#set(added_exe_linker_flags)
|
||||
#set(added_link_dirs ${nuttx_export_dir}/libs)
|
||||
set(added_definitions -D__PX4_NUTTX)
|
||||
add_definitions(
|
||||
-D__PX4_NUTTX
|
||||
-D__DF_NUTTX
|
||||
)
|
||||
|
||||
list(APPEND added_definitions -D__DF_NUTTX)
|
||||
|
||||
if("${config_nuttx_hw_stack_check_${BOARD}}" STREQUAL "y")
|
||||
set(instrument_flags
|
||||
@@ -240,7 +241,9 @@ function(px4_os_prebuild_targets)
|
||||
REQUIRED OUT BOARD
|
||||
ARGN ${ARGN})
|
||||
|
||||
add_custom_target(${OUT} DEPENDS nuttx_context uorb_headers)
|
||||
add_library(${OUT} INTERFACE)
|
||||
target_link_libraries(${OUT} INTERFACE nuttx_cxx nuttx_c nuttx_fs nuttx_mm nuttx_sched m gcc)
|
||||
add_dependencies(${OUT} DEPENDS nuttx_context uorb_headers)
|
||||
|
||||
# parse nuttx config options for cmake
|
||||
file(STRINGS ${PX4_SOURCE_DIR}/platforms/nuttx/nuttx-configs/${BOARD}/nsh/defconfig ConfigContents)
|
||||
@@ -323,4 +326,3 @@ function(px4_nuttx_configure)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# vim: set noet fenc=utf-8 ff=unix nowrap:
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
# skip for px4_layer support on an IO board
|
||||
if (NOT ${BOARD} MATCHES "px4io")
|
||||
|
||||
px4_add_module(
|
||||
MODULE platform_px4_layer
|
||||
SRCS
|
||||
px4_nuttx_tasks.c
|
||||
px4_nuttx_impl.cpp
|
||||
DEPENDS
|
||||
prebuild_targets
|
||||
)
|
||||
add_library(px4_layer
|
||||
px4_nuttx_tasks.c
|
||||
px4_nuttx_impl.cpp
|
||||
)
|
||||
target_link_libraries(px4_layer PRIVATE nuttx_sched drivers_boards_common_arch)
|
||||
else()
|
||||
add_library(px4_layer ${PX4_SOURCE_DIR}/src/platforms/empty.c)
|
||||
endif()
|
||||
add_dependencies(px4_layer prebuild_targets)
|
||||
|
||||
Reference in New Issue
Block a user