cmake remove circular linking and reorganize

- px4_add_module now requires MAIN
 - px4_add_library doesn't automatically link
This commit is contained in:
Daniel Agar
2018-04-29 21:48:54 -04:00
parent a8bc3d187f
commit ea3acb7121
576 changed files with 1406 additions and 2014 deletions
+26 -10
View File
@@ -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
)
+9 -7
View File
@@ -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:
+8 -8
View File
@@ -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)
+9 -15
View File
@@ -3,7 +3,7 @@ add_subdirectory(src)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES)
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
px4_posix_generate_builtin_commands(
OUT apps
@@ -46,23 +46,19 @@ else()
apps.cpp
)
if (APPLE)
target_link_libraries(px4
target_link_libraries(px4
PRIVATE
${module_libraries}
df_driver_framework
${df_driver_libs}
pthread m
)
else()
target_link_libraries(px4
-Wl,--start-group
${module_libraries}
df_driver_framework
${df_driver_libs}
pthread m rt
-Wl,--end-group
)
)
if (NOT APPLE)
target_link_libraries(px4 PRIVATE rt)
endif()
target_link_libraries(px4 PRIVATE modules__uORB)
endif()
if ("${BOARD}" STREQUAL "rpi")
@@ -99,5 +95,3 @@ endif()
install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
+10 -11
View File
@@ -164,21 +164,19 @@ function(px4_os_add_flags)
LINK_DIRS ${LINK_DIRS}
DEFINITIONS ${DEFINITIONS})
set(added_include_dirs
platforms/posix/include
)
# This block sets added_definitions and added_cxx_flags.
set(added_c_flags)
set(added_cxx_flags)
set(added_exe_linker_flags)
set(added_definitions
add_definitions(
-D__PX4_POSIX
-Dnoreturn_function=__attribute__\(\(noreturn\)\)
)
include_directories(platforms/posix/include)
if(UNIX AND APPLE)
list(APPEND added_definitions
add_definitions(
-D__PX4_DARWIN
-D__DF_DARWIN
)
@@ -191,7 +189,7 @@ function(px4_os_add_flags)
STRING(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
# message(STATUS "PX4 Darwin Version: ${DARWIN_VERSION}")
if (DARWIN_VERSION LESS 16)
list(APPEND added_definitions
add_definitions(
-DCLOCK_MONOTONIC=1
-DCLOCK_REALTIME=0
-D__PX4_APPLE_LEGACY
@@ -199,14 +197,14 @@ function(px4_os_add_flags)
endif()
elseif(CYGWIN)
list(APPEND added_definitions
add_definitions(
-D__PX4_CYGWIN
-D_GNU_SOURCE
-D__USE_LINUX_IOCTL_DEFS
-U __CUSTOM_FILE_IO__
)
else()
list(APPEND added_definitions
add_definitions(
-D__PX4_LINUX
-D__DF_LINUX
)
@@ -316,5 +314,6 @@ function(px4_os_prebuild_targets)
REQUIRED OUT BOARD
ARGN ${ARGN})
add_custom_target(${OUT} DEPENDS uorb_headers)
add_library(${OUT} INTERFACE)
add_dependencies(${OUT} DEPENDS uorb_headers)
endfunction()
+13 -14
View File
@@ -45,17 +45,16 @@ if("${CONFIG_SHMEM}" STREQUAL "1")
set(EXTRA_DEPENDS generate_px4muorb_stubs)
endif()
px4_add_module(
MODULE platforms__posix__px4_layer
COMPILE_FLAGS
SRCS
px4_posix_impl.cpp
px4_posix_tasks.cpp
px4_sem.cpp
lib_crc32.c
drv_hrt.c
${SHMEM_SRCS}
DEPENDS
platforms__common
${EXTRA_DEPENDS}
)
add_library(px4_layer
px4_posix_impl.cpp
px4_posix_tasks.cpp
px4_sem.cpp
lib_crc32.c
drv_hrt.c
${SHMEM_SRCS}
)
target_link_libraries(px4_layer PRIVATE work_queue)
if (EXTRA_DEPENDS)
add_dependencies(px4_layer ${EXTRA_DEPENDS})
endif()
@@ -46,7 +46,7 @@
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <systemlib/param/param.h>
#include <parameters/param.h>
#include "hrt_work.h"
#include <drivers/drv_hrt.h>
#include "px4_time.h"
+1 -1
View File
@@ -48,7 +48,7 @@
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "systemlib/param/param.h"
#include <parameters/param.h>
#include <shmem.h>
#include "px4muorb.h"
+10 -12
View File
@@ -10,33 +10,31 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes")
get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES)
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
px4_qurt_generate_builtin_commands(
OUT ${PX4_BINARY_DIR}/apps
MODULE_LIST ${module_libraries})
MODULE_LIST ${module_libraries}
)
FASTRPC_STUB_GEN(px4muorb.idl)
# Enable build without HexagonSDK to check link dependencies
if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
add_definitions(-D QURT_EXE_BUILD=1)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${FASTRPC_DSP_INCLUDES}
)
add_executable(px4
${PX4_BINARY_DIR}/src/firmware/qurt/px4muorb_skel.c
${PX4_BINARY_DIR}/apps.cpp
)
${PX4_BINARY_DIR}/platforms/qurt/px4muorb_skel.c
)
target_link_libraries(px4
-Wl,--start-group
${module_libraries}
${df_driver_libs}
-Wl,--end-group
)
target_link_libraries(px4 PRIVATE ${module_libraries} ${df_driver_libs})
else()
# Generate the DSP lib and stubs but not the apps side executable
# The Apps side executable is generated via the posix_eagle_xxxx target
@@ -58,6 +56,6 @@ else()
DEPENDS px4 px4muorb_skel
COMMENT "uploading px4"
USES_TERMINAL
)
)
endif()
+6 -8
View File
@@ -162,7 +162,7 @@ function(px4_os_add_flags)
DEFINITIONS ${DEFINITIONS})
set(DSPAL_ROOT src/lib/DriverFramework/dspal)
set(added_include_dirs
include_directories(
${DSPAL_ROOT}/include
${DSPAL_ROOT}/mpu_spi/inc
${DSPAL_ROOT}/sys
@@ -173,7 +173,7 @@ function(px4_os_add_flags)
platforms/qurt/include
)
set(added_definitions
add_definitions(
-D__DF_QURT # For DriverFramework
-D__PX4_POSIX
-D__PX4_QURT
@@ -195,8 +195,8 @@ function(px4_os_add_flags)
)
# Clear -rdynamic flag which fails for hexagon
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
set(DF_TARGET "qurt" PARENT_SCOPE)
@@ -238,8 +238,6 @@ function(px4_os_prebuild_targets)
REQUIRED OUT BOARD
ARGN ${ARGN})
add_custom_target(${OUT} DEPENDS git_driverframework uorb_headers)
add_library(${OUT} INTERFACE)
add_dependencies(${OUT} DEPENDS uorb_headers)
endfunction()
# vim: set noet fenc=utf-8 ff=unix nowrap:
+6 -9
View File
@@ -30,6 +30,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PX4_SOURCE_DIR}/cmake/cmake_hexagon")
include(hexagon_sdk)
@@ -52,12 +53,8 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
)
endif()
px4_add_module(
MODULE platforms_px4_layer
COMPILE_FLAGS
SRCS
${QURT_LAYER_SRCS}
${CONFIG_SRC}
DEPENDS
platforms__common
)
add_library(px4_layer
${QURT_LAYER_SRCS}
${CONFIG_SRC}
)
add_dependencies(px4_layer uorb_msgs) # dataman requires mission
@@ -48,7 +48,7 @@
#include <errno.h>
#include <unistd.h>
#include <semaphore.h>
#include <systemlib/param/param.h>
#include <parameters/param.h>
#include "hrt_work.h"
#include "px4_log.h"
+1 -1
View File
@@ -41,7 +41,7 @@
#include <sys/stat.h>
#include <atomic_ops.h>
#include "systemlib/param/param.h"
#include <parameters/param.h>
#include <shmem.h>
#include <drivers/drv_hrt.h>