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:
@@ -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})
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user