cmake use standard mechanisms for settings flags

This commit is contained in:
Daniel Agar 2018-11-23 12:39:44 -05:00 committed by David Sidrane
parent 11be2b8873
commit 3e0a3559a9
68 changed files with 292 additions and 665 deletions

View File

@ -213,7 +213,7 @@ endif()
message(STATUS "PX4 config file: ${PX4_CONFIG_FILE}")
include(px4_add_board)
include(${PX4_CONFIG_FILE})
message(STATUS "PX4 config: ${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}")
message(STATUS "PX4 config: ${PX4_CONFIG}")
message(STATUS "PX4 platform: ${PX4_PLATFORM}")
# external modules
@ -272,6 +272,11 @@ endif()
# Setup install paths
if (${PX4_PLATFORM} STREQUAL "posix")
# This makes it possible to dynamically load code which depends on symbols
# inside the px4 executable.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_ENABLE_EXPORTS ON)
include(coverage)
include(sanitizers)
@ -287,19 +292,6 @@ if (${PX4_PLATFORM} STREQUAL "posix")
include(CTest)
endif()
#=============================================================================
# require px4 module interface
set(px4_required_interface
px4_os_prebuild_targets
px4_os_add_flags
px4_add_board
)
foreach(cmd ${px4_required_interface})
if (NOT COMMAND ${cmd})
message(FATAL_ERROR "${CONFIG} must implement ${cmd}")
endif()
endforeach()
#=============================================================================
# ccache
#
@ -349,19 +341,9 @@ endif()
#=============================================================================
# build flags
#
px4_os_add_flags(
BOARD ${PX4_BOARD}
C_FLAGS c_flags
CXX_FLAGS cxx_flags
OPTIMIZATION_FLAGS optimization_flags
EXE_LINKER_FLAGS exe_linker_flags
INCLUDE_DIRS include_dirs
LINK_DIRS link_dirs
DEFINITIONS definitions)
px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${CMAKE_EXE_LINKER_FLAGS};${exe_linker_flags}" GLUE " ")
px4_join(OUT CMAKE_C_FLAGS LIST "${CMAKE_C_FLAGS};${c_flags};${optimization_flags}" GLUE " ")
px4_join(OUT CMAKE_CXX_FLAGS LIST "${CMAKE_CXX_FLAGS};${cxx_flags};${optimization_flags}" GLUE " ")
include(px4_add_common_flags)
px4_add_common_flags()
px4_os_add_flags()
#=============================================================================
# message, and airframe generation
@ -546,14 +528,14 @@ add_custom_target(all_metadata
#
# Important to having packaging at end of cmake file.
#
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${CONFIG})
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${PX4_CONFIG})
set(CPACK_PACKAGE_VERSION ${PX4_GIT_TAG})
set(CPACK_PACKAGE_CONTACT ${package-contact})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # TODO: review packaging for linux boards
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The PX4 Pro autopilot.")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CONFIG}-${PX4_GIT_TAG}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_CONFIG}-${PX4_GIT_TAG}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_GIT_TAG}")
set(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
set(CPACK_PACKAGING_INSTALL_PREFIX "")

View File

@ -4,7 +4,7 @@ px4_add_board(
MODEL ocpoc
LABEL ubuntu
PLATFORM posix
PROCESSOR cortex-a9
ARCHITECTURE cortex-a9
TOOLCHAIN arm-linux-gnueabihf
TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR airmind
MODEL mindpx-v2
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@ -25,16 +25,24 @@ set(DISABLE_PARAMS_MODULE_SCOPING TRUE)
set(CONFIG_SHMEM "1")
add_definitions(-DORB_COMMUNICATOR)
# This definition allows to differentiate if this just the usual POSIX build
# or if it is for the Snapdragon.
add_definitions(-D__PX4_POSIX_EAGLE)
# atlflight toolchain doesn't properly set the compiler, so these aren't set automatically
add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=gnu99>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=gnu++11>)
add_definitions(
-D__PX4_POSIX_EAGLE
-D__PX4_LINUX
# For DriverFramework
-D__DF_LINUX
)
px4_add_board(
PLATFORM posix
VENDOR atlflight
MODEL eagle
LABEL default
TESTING
#TESTING
TOOLCHAIN arm-linux-gnueabihf
DRIVERS
@ -100,18 +108,18 @@ px4_add_board(
reboot
sd_bench
shutdown
tests # tests and test runner
#tests # tests and test runner
top
topic_listener
tune_control
ver
EXAMPLES
bottle_drop # OBC challenge
fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
#bottle_drop # OBC challenge
#fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
#hwtest # Hardware test
px4_mavlink_debug # Tutorial code from https://px4.io/dev/debug_values
px4_simple_app # Tutorial code from https://px4.io/dev/px4_simple_app
rover_steering_control # Rover example app
segway
#px4_mavlink_debug # Tutorial code from https://px4.io/dev/debug_values
#px4_simple_app # Tutorial code from https://px4.io/dev/px4_simple_app
#rover_steering_control # Rover example app
#segway
)

View File

@ -47,8 +47,6 @@
#define BOARD_NUMBER_BRICKS 0
#define CONFIG_ARCH_BOARD_SITL 1
/*
* I2C busses
*/

View File

@ -25,9 +25,17 @@ set(DISABLE_PARAMS_MODULE_SCOPING TRUE)
set(CONFIG_SHMEM "1")
add_definitions(-DORB_COMMUNICATOR)
# This definition allows to differentiate if this just the usual POSIX build
# or if it is for the Snapdragon.
add_definitions(-D__PX4_POSIX_EXCELSIOR)
# atlflight toolchain doesn't properly set the compiler, so these aren't set automatically
add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=gnu99>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=gnu++11>)
add_definitions(
-D__PX4_POSIX_EXCELSIOR
-D__PX4_LINUX
# For DriverFramework
-D__DF_LINUX
)
px4_add_board(
PLATFORM posix

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR atmel
MODEL same70xplained
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
TESTING
#UAVCAN_INTERFACES 1

View File

@ -41,7 +41,7 @@ px4_add_board(
VENDOR auav
MODEL esc35-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
DRIVERS
bootloaders

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR auav
MODEL x21
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR av
MODEL x-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@ -4,7 +4,7 @@ px4_add_board(
MODEL blue
LABEL cross
PLATFORM posix
PROCESSOR cortex-a8
ARCHITECTURE cortex-a8
TOOLCHAIN arm-linux-gnueabihf
TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR bitcraze
MODEL crazyflie
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
DRIVERS

View File

@ -4,7 +4,7 @@ px4_add_board(
MODEL navio2
LABEL cross
PLATFORM posix
PROCESSOR cortex-a53
ARCHITECTURE cortex-a53
TOOLCHAIN arm-linux-gnueabihf
TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR gumstix
MODEL aerocore2
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
UAVCAN_INTERFACES 1

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR intel
MODEL aerofc-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
SERIAL_PORTS

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL aerofc-v1
LABEL rtsp
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
SERIAL_PORTS

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR nxp
MODEL hlite-v3
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@ -3,7 +3,7 @@
# see misc/tools/kconfig-language.txt.
#
if ARCH_BOARD_NXPHLITE_V3
if ARCH_BOARD_NXP_HLITE_V3
config NXPHLITE_SDHC_AUTOMOUNT
bool "SDHC automounter"
default n

View File

@ -35,8 +35,8 @@
*
************************************************************************************/
#ifndef __CONFIG_NXPHLITE_V3_INCLUDE_BOARD_H
#define __CONFIG_NXPHLITE_V3_INCLUDE_BOARD_H
#ifndef __CONFIG_NXP_HLITE_V3_INCLUDE_BOARD_H
#define __CONFIG_NXP_HLITE_V3_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
@ -556,4 +556,4 @@ void kinetis_boardinitialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIG_NXPHLITE_V23_INCLUDE_BOARD_H */
#endif /* __CONFIG_NXP_HLITE_V3_INCLUDE_BOARD_H */

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR omnibus
MODEL f4sd
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
SERIAL_PORTS

View File

@ -3,7 +3,7 @@ px4_add_board(
VENDOR parrot
MODEL bebop
PLATFORM posix
PROCESSOR cortex-a53
ARCHITECTURE cortex-a53
TOOLCHAIN arm-linux-gnueabihf
DRIVERS

View File

@ -39,7 +39,7 @@ px4_add_board(
VENDOR px4
MODEL cannode-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m3
ARCHITECTURE cortex-m3
DRIVERS
bootloaders

View File

@ -41,7 +41,7 @@ px4_add_board(
VENDOR px4
MODEL esc-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
DRIVERS
bootloaders

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR px4
MODEL fmu-v2
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
BOOTLOADER ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/extras/px4fmuv3_bl.bin
IO px4_io-v2_default

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v2
LABEL lpe
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
BOOTLOADER ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/extras/px4fmuv3_bl.bin
IO px4_io-v2_default

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v2
LABEL test
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_test
IO px4_io-v2_default
TESTING

View File

@ -7,7 +7,7 @@ px4_add_board(
MODEL fmu-v3
LABEL default
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -7,7 +7,7 @@ px4_add_board(
MODEL fmu-v3
LABEL rtps
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -7,7 +7,7 @@ px4_add_board(
MODEL fmu-v3
LABEL stackcheck
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v4
LABEL default
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v4
LABEL rtps
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v4
LABEL stackcheck
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
TESTING
#UAVCAN_INTERFACES 1

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v4pro
LABEL default
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v4pro
LABEL default
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -318,8 +318,6 @@
* the connector interface and Spektrum requires VDD 3v3 to be controllable
*/
#define BOARD_NAME "PX4_FMU_V4PRO"
/* By Providing BOARD_ADC_USB_CONNECTED (using the px4_arch abstraction)
* this board support the ADC system_power interface, and therefore
* provides the true logic GPIO BOARD_ADC_xxxx macros.

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR px4
MODEL fmu-v5
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v5
LABEL rtps
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -5,7 +5,7 @@ px4_add_board(
MODEL fmu-v5
LABEL stackcheck
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR px4
MODEL io-v2
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m3
ARCHITECTURE cortex-m3
DRIVERS
stm32
MODULES

View File

@ -4,7 +4,7 @@ px4_add_board(
MODEL raspberrypi
LABEL cross
PLATFORM posix
PROCESSOR cortex-a53
ARCHITECTURE cortex-a53
TOOLCHAIN Toolchain-arm-linux-gnueabihf
TESTING

View File

@ -47,8 +47,6 @@
#define BOARD_HAS_NO_RESET
#define BOARD_HAS_NO_BOOTLOADER
#define CONFIG_ARCH_BOARD_SITL 1
#define PX4_I2C_BUS_EXPANSION 1
#define PX4_I2C_BUS_ONBOARD 2
#define PX4_NUMBER_I2C_BUSES 1

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR stm
MODEL 32f4discovery
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
ROMFSROOT px4fmu_common
#TESTING

View File

@ -4,7 +4,7 @@ px4_add_board(
VENDOR stm
MODEL nucleo-F767ZI
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m7
ARCHITECTURE cortex-m7
ROMFSROOT px4fmu_common
TESTING
#UAVCAN_INTERFACES 2

View File

@ -32,7 +32,7 @@ px4_add_board(
VENDOR thiemar
MODEL s2740vc-v1
TOOLCHAIN arm-none-eabi
PROCESSOR cortex-m4
ARCHITECTURE cortex-m4
DRIVERS
bootloaders

View File

@ -46,7 +46,7 @@ include(px4_base)
# MODEL <string>
# [ LABEL <string> ]
# [ TOOLCHAIN <string> ]
# [ PROCESSOR <string> ]
# [ ARCHITECTURE <string> ]
# [ ROMFSROOT <string> ]
# [ IO <string> ]
# [ BOOTLOADER <string> ]
@ -67,7 +67,7 @@ include(px4_base)
# MODEL : name of board model
# LABEL : optional label, set to default if not specified
# TOOLCHAIN : cmake toolchain
# PROCESSOR : name of the CPU CMake is building for (used by the toolchain)
# ARCHITECTURE : name of the CPU CMake is building for (used by the toolchain)
# ROMFSROOT : relative path to the ROMFS root directory (currently NuttX only)
# IO : name of IO board to be built and included in the ROMFS (requires a valid ROMFSROOT)
# BOOTLOADER : bootloader file to include for flashing via bl_update (currently NuttX only)
@ -88,7 +88,7 @@ include(px4_base)
# VENDOR px4
# MODEL fmu-v5
# TOOLCHAIN arm-none-eabi
# PROCESSOR cortex-m7
# ARCHITECTURE cortex-m7
# ROMFSROOT px4fmu_common
# IO px4_io-v2_default
# SERIAL_PORTS
@ -137,7 +137,7 @@ function(px4_add_board)
MODEL
LABEL
TOOLCHAIN
PROCESSOR
ARCHITECTURE
ROMFSROOT
IO
BOOTLOADER
@ -159,28 +159,32 @@ function(px4_add_board)
ARGN ${ARGN})
set(PX4_BOARD_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE STRING "PX4 board directory" FORCE)
include_directories(${PX4_BOARD_DIR}/src)
set(PX4_BOARD ${VENDOR}_${MODEL} CACHE STRING "PX4 board" FORCE)
# board name is uppercase with no underscores when used as a define
string(TOUPPER ${PX4_BOARD} PX4_BOARD_NAME)
string(REPLACE "-" "_" PX4_BOARD_NAME ${PX4_BOARD_NAME})
set(PX4_BOARD_NAME ${PX4_BOARD_NAME} CACHE STRING "PX4 board define" FORCE)
set(PX4_BOARD_VENDOR ${VENDOR} CACHE STRING "PX4 board vendor" FORCE)
set(PX4_BOARD_MODEL ${MODEL} CACHE STRING "PX4 board model" FORCE)
if(BOARD_OVERRIDE)
set(PX4_BOARD ${BOARD_OVERRIDE} CACHE STRING "PX4 board" FORCE)
else()
set(PX4_BOARD ${VENDOR}_${MODEL} CACHE STRING "PX4 board" FORCE)
endif()
if(LABEL)
set(PX4_BOARD_LABEL ${LABEL} CACHE STRING "PX4 board label" FORCE)
else()
set(PX4_BOARD_LABEL "default" CACHE STRING "PX4 board label" FORCE)
endif()
set(PX4_CONFIG "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}" CACHE STRING "PX4 config" FORCE)
# set OS, and append specific platform module path
set(PX4_PLATFORM ${PLATFORM} CACHE STRING "PX4 board OS" FORCE)
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake)
if(PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${PROCESSOR} CACHE INTERNAL "system processor" FORCE)
if(ARCHITECTURE)
set(CMAKE_SYSTEM_PROCESSOR ${ARCHITECTURE} CACHE INTERNAL "system processor" FORCE)
endif()
if(TOOLCHAIN)
@ -264,7 +268,6 @@ function(px4_add_board)
# add board config directory src to build modules
file(RELATIVE_PATH board_support_src_rel ${PX4_SOURCE_DIR}/src ${PX4_BOARD_DIR})
list(APPEND config_module_list ${board_support_src_rel}/src)
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
set(config_module_list ${config_module_list} PARENT_SCOPE)

View File

@ -40,49 +40,27 @@ include(px4_base)
# Set the default build flags.
#
# Usage:
# px4_add_common_flags(
# BOARD <in-string>
# C_FLAGS <inout-variable>
# CXX_FLAGS <inout-variable>
# OPTIMIZATION_FLAGS <inout-variable>
# EXE_LINKER_FLAGS <inout-variable>
# INCLUDE_DIRS <inout-variable>
# LINK_DIRS <inout-variable>
# DEFINITIONS <inout-variable>)
#
# Input:
# BOARD : board
#
# Input/Output: (appends to existing variable)
# C_FLAGS : c compile flags variable
# CXX_FLAGS : c++ compile flags variable
# OPTIMIZATION_FLAGS : optimization compile flags variable
# EXE_LINKER_FLAGS : executable linker flags variable
# INCLUDE_DIRS : include directories
# LINK_DIRS : link directories
# DEFINITIONS : definitions
#
# Example:
# px4_add_common_flags(
# BOARD px4_fmu-v2
# C_FLAGS CMAKE_C_FLAGS
# CXX_FLAGS CMAKE_CXX_FLAGS
# OPTIMIZATION_FLAGS optimization_flags
# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS
# INCLUDES <list>)
# px4_add_common_flags()
#
function(px4_add_common_flags)
set(inout_vars
C_FLAGS CXX_FLAGS OPTIMIZATION_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS)
add_compile_options(
-g # always build debug symbols
px4_parse_function_args(
NAME px4_add_common_flags
ONE_VALUE ${inout_vars} BOARD
REQUIRED ${inout_vars}
ARGN ${ARGN})
# optimization options
-fdata-sections
-ffunction-sections
-fomit-frame-pointer
-funsafe-math-optimizations
set(warnings
-fno-strict-aliasing
-fno-math-errno
# visibility
-fvisibility=hidden
-include visibility.h
# Warnings
-Wall
-Wextra
-Werror
@ -95,132 +73,95 @@ function(px4_add_common_flags)
-Wformat-security
-Winit-self
-Wlogical-op
-Wmissing-declarations
-Wpointer-arith
-Wshadow
-Wuninitialized
-Wunknown-pragmas
-Wunused-variable
# disabled warnings
-Wno-implicit-fallthrough # set appropriate level and update
-Wno-missing-field-initializers
-Wno-missing-include-dirs # TODO: fix and enable
-Wno-unused-parameter
)
if (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")
# compiler specific flags
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# force color for clang (needed for clang + ccache)
add_compile_options(-fcolor-diagnostics)
# QuRT 6.4.X compiler identifies as Clang but does not support this option
if (NOT ${PX4_PLATFORM} STREQUAL "qurt")
list(APPEND warnings
if (NOT "${PX4_PLATFORM}" STREQUAL "qurt")
add_compile_options(
-Qunused-arguments
-Wno-unused-const-variable
-Wno-varargs
-Wno-address-of-packed-member
-Wno-unknown-warning-option
-Wunused-but-set-variable
-Wno-unused-const-variable
-Wno-varargs
)
endif()
else()
list(APPEND warnings
-Wunused-but-set-variable
-Wformat=1
)
endif()
set(_optimization_flags
-fno-strict-aliasing
-fomit-frame-pointer
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-fno-math-errno
-funsafe-math-optimizations
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
# force color for gcc > 4.9
add_compile_options(-fdiagnostics-color=always)
endif()
-ffunction-sections
-fdata-sections
)
set(c_warnings
-Wbad-function-cast
-Wstrict-prototypes
-Wmissing-prototypes
-Wnested-externs
)
set(c_compile_flags
-g
-std=gnu99
-fno-common
)
set(cxx_warnings
-Wno-overloaded-virtual # TODO: fix and remove
-Wreorder
)
set(cxx_compile_flags
-g
-fno-exceptions
-fno-rtti
-std=gnu++11
-fno-threadsafe-statics
-DCONFIG_WCHAR_BUILTIN
-D__CUSTOM_FILE_IO__
)
# regular Clang or AppleClang
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# force color for clang (needed for clang + ccache)
list(APPEND _optimization_flags
-fcolor-diagnostics
)
else()
list(APPEND _optimization_flags
-fno-strength-reduce
add_compile_options(
-fno-builtin-printf
-fno-strength-reduce
-Wformat=1
-Wunused-but-set-variable
-Wno-format-truncation # TODO: fix
)
# -fcheck-new is a no-op for Clang in general
# and has no effect, but can generate a compile
# error for some OS
list(APPEND cxx_compile_flags
-fcheck-new
)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fcheck-new>)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message(FATAL_ERROR "Intel compiler not yet supported")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(FATAL_ERROR "MS compiler not yet supported")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
# force color for gcc > 4.9
list(APPEND _optimization_flags
-fdiagnostics-color=always
)
endif()
# C only flags
set(c_flags)
list(APPEND c_flags
-fno-common
list(APPEND cxx_warnings
-Wno-format-truncation # TODO: fix
)
endif()
-Wbad-function-cast
-Wnested-externs
-Wstrict-prototypes
)
foreach(flag ${c_flags})
add_compile_options($<$<COMPILE_LANGUAGE:C>:${flag}>)
endforeach()
set(visibility_flags
-fvisibility=hidden
-include visibility.h
)
set(added_c_flags
${c_compile_flags}
${warnings}
${c_warnings}
${visibility_flags}
)
# CXX only flags
set(cxx_flags)
list(APPEND cxx_flags
-fno-exceptions
-fno-rtti
-fno-threadsafe-statics
set(added_cxx_flags
${cxx_compile_flags}
${warnings}
${cxx_warnings}
${visibility_flags}
)
-Wreorder
# disabled warnings
-Wno-overloaded-virtual # TODO: fix and remove
)
foreach(flag ${cxx_flags})
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${flag}>)
endforeach()
set(added_optimization_flags
${_optimization_flags}
)
include_directories(
${PX4_BINARY_DIR}
@ -237,19 +178,10 @@ function(px4_add_common_flags)
${PX4_SOURCE_DIR}/src/platforms
)
string(TOUPPER ${PX4_BOARD} board_upper)
string(REPLACE "-" "_" board_config ${board_upper})
add_definitions(
-DCONFIG_ARCH_BOARD_${board_config}
-DCONFIG_ARCH_BOARD_${PX4_BOARD_NAME}
-D__CUSTOM_FILE_IO__
-D__STDC_FORMAT_MACROS
)
# output
foreach(var ${inout_vars})
string(TOLOWER ${var} lower_var)
set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)
#message(STATUS "set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)")
endforeach()
endfunction()

View File

@ -212,13 +212,6 @@ function(px4_add_module)
endforeach()
endif()
# join list variables to get ready to send to compiler
foreach(prop LINK_FLAGS)
if(${prop})
px4_join(OUT ${prop} LIST ${${prop}} GLUE " ")
endif()
endforeach()
foreach (prop LINK_FLAGS STACK_MAIN MAIN PRIORITY)
if (${prop})
set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}})

View File

@ -38,7 +38,6 @@
# utility functions
#
# * px4_parse_function_args
# * px4_join
#
include(CMakeParseArguments)
@ -114,40 +113,6 @@ function(px4_parse_function_args)
endfunction()
#=============================================================================
#
# px4_join
#
# This function joins a list with a given separator. If list is not
# passed, or is sent "", this will return the empty string.
#
# Usage:
# px4_join(OUT ${OUT} [ LIST ${LIST} ] GLUE ${GLUE})
#
# Input:
# LIST : list to join
# GLUE : separator to use
#
# Output:
# OUT : joined list
#
# Example:
# px4_join(OUT test_join LIST a b c GLUE ";")
# test_join would then be:
# "a;b;c"
#
function(px4_join)
px4_parse_function_args(
NAME px4_join
ONE_VALUE OUT GLUE
MULTI_VALUE LIST
REQUIRED GLUE OUT
ARGN ${ARGN})
string (REPLACE ";" "${GLUE}" _TMP_STR "${LIST}")
set(${OUT} ${_TMP_STR} PARENT_SCOPE)
endfunction()
#=============================================================================
#
# px4_find_python_module

View File

@ -90,7 +90,7 @@ target_link_libraries(${FW_NAME} PRIVATE
-fno-rtti
-Wl,--script=${PX4_BINARY_DIR_CYG}/NuttX/nuttx/configs/${PX4_BOARD}/scripts/ld.script
-Wl,-Map=${CONFIG}.map
-Wl,-Map=${PX4_CONFIG}.map
-Wl,--warn-common
-Wl,--gc-sections
@ -195,7 +195,7 @@ if (TARGET parameters_xml AND TARGET airframes_xml)
endforeach()
endif()
px4_join(OUT serial_ports LIST "${serial_ports}" GLUE ",")
string(REPLACE ";" "," serial_ports "${serial_ports}")
add_custom_target(upload
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${fw_file}

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-m3 -mthumb -march=armv7-m")
set(cpu_flags "-mcpu=cortex-m3 -mthumb")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard")
set(cpu_flags "-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard")
set(cpu_flags "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -49,62 +49,8 @@ include(px4_base)
#
# Set the nuttx build flags.
#
# Usage:
# px4_os_add_flags(
# C_FLAGS <inout-variable>
# CXX_FLAGS <inout-variable>
# OPTIMIZATION_FLAGS <inout-variable>
# EXE_LINKER_FLAGS <inout-variable>
# INCLUDE_DIRS <inout-variable>
# LINK_DIRS <inout-variable>
# DEFINITIONS <inout-variable>)
#
# Input:
# BOARD : flags depend on board/nuttx config
#
# Input/Output: (appends to existing variable)
# C_FLAGS : c compile flags variable
# CXX_FLAGS : c++ compile flags variable
# OPTIMIZATION_FLAGS : optimization compile flags variable
# EXE_LINKER_FLAGS : executable linker flags variable
# INCLUDE_DIRS : include directories
# LINK_DIRS : link directories
# DEFINITIONS : definitions
#
# Note that EXE_LINKER_FLAGS is not suitable for adding libraries because
# these flags are added before any of the object files and static libraries.
# Add libraries in src/firmware/nuttx/CMakeLists.txt.
#
# Example:
# px4_os_add_flags(
# C_FLAGS CMAKE_C_FLAGS
# CXX_FLAGS CMAKE_CXX_FLAGS
# OPTIMIZATION_FLAGS optimization_flags
# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS
# INCLUDES <list>)
#
function(px4_os_add_flags)
set(inout_vars
C_FLAGS CXX_FLAGS OPTIMIZATION_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS)
px4_parse_function_args(
NAME px4_os_add_flags
ONE_VALUE ${inout_vars} BOARD
REQUIRED ${inout_vars}
ARGN ${ARGN})
include(px4_add_common_flags)
px4_add_common_flags(
BOARD ${PX4_BOARD}
C_FLAGS ${C_FLAGS}
CXX_FLAGS ${CXX_FLAGS}
OPTIMIZATION_FLAGS ${OPTIMIZATION_FLAGS}
EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS}
INCLUDE_DIRS ${INCLUDE_DIRS}
LINK_DIRS ${LINK_DIRS}
DEFINITIONS ${DEFINITIONS})
include_directories(BEFORE SYSTEM
${PX4_BINARY_DIR}/NuttX/nuttx/include
${PX4_BINARY_DIR}/NuttX/nuttx/include/cxx
@ -125,20 +71,12 @@ function(px4_os_add_flags)
if("${CONFIG_ARMV7M_STACKCHECK}" STREQUAL "y")
message(STATUS "NuttX Stack Checking (CONFIG_ARMV7M_STACKCHECK) enabled")
set(instrument_flags
add_compile_options(
-finstrument-functions
-ffixed-r10
)
list(APPEND c_flags ${instrument_flags})
list(APPEND cxx_flags ${instrument_flags})
endif()
# output
foreach(var ${inout_vars})
string(TOLOWER ${var} lower_var)
set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)
#message(STATUS "nuttx: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)")
endforeach()
endfunction()
#=============================================================================

View File

@ -21,13 +21,12 @@ px4_posix_generate_alias(
PREFIX ${PX4_SHELL_COMMAND_PREFIX}
)
if (("${PX4_BOARD}" STREQUAL "atlflight_eagle") OR ("${PX4_BOARD}" STREQUAL "atlflight_excelsior"))
if (("${PX4_BOARD}" MATCHES "atlflight_eagle") OR ("${PX4_BOARD}" MATCHES "atlflight_excelsior"))
include(fastrpc)
include(linux_app)
FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")
LINUX_APP(
APP_NAME px4
IDL_NAME px4muorb

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-a53 -mfpu=neon -mfloat-abi=hard")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-a9 -mfpu=neon-vfpv3 -mfloat-abi=hard -mthumb-interwork")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -1,6 +1,6 @@
set(cpu_flags "-mcpu=cortex-a8 -mfpu=neon-vfpv3 -mfloat-abi=hard -mthumb-interwork")
set(CMAKE_C_FLAGS "${cpu_flags}")
set(CMAKE_CXX_FLAGS "${cpu_flags}")
set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cpu_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cpu_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${cpu_flags} -D__ASSEMBLY__")

View File

@ -47,11 +47,6 @@
include(px4_base)
# This makes it possible to dynamically load code which depends on symbols
# inside the px4 executable.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_ENABLE_EXPORTS ON)
#=============================================================================
#
# px4_posix_generate_builtin_commands
@ -215,65 +210,10 @@ endfunction()
# Set the posix build flags.
#
# Usage:
# px4_os_add_flags(
# C_FLAGS <inout-variable>
# CXX_FLAGS <inout-variable>
# OPTIMIZATION_FLAGS <inout-variable>
# EXE_LINKER_FLAGS <inout-variable>
# INCLUDE_DIRS <inout-variable>
# LINK_DIRS <inout-variable>
# DEFINITIONS <inout-variable>)
#
# Input:
# BOARD : flags depend on board/posix config
#
# Input/Output: (appends to existing variable)
# C_FLAGS : c compile flags variable
# CXX_FLAGS : c++ compile flags variable
# OPTIMIZATION_FLAGS : optimization compile flags variable
# EXE_LINKER_FLAGS : executable linker flags variable
# INCLUDE_DIRS : include directories
# LINK_DIRS : link directories
# DEFINITIONS : definitions
#
# Note that EXE_LINKER_FLAGS is not suitable for adding libraries because
# these flags are added before any of the object files and static libraries.
# Add libraries in src/firmware/posix/CMakeLists.txt.
#
# Example:
# px4_os_add_flags(
# C_FLAGS CMAKE_C_FLAGS
# CXX_FLAGS CMAKE_CXX_FLAGS
# OPTIMIZATION_FLAGS optimization_flags
# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS
# INCLUDES <list>)
# px4_os_add_flags()
#
function(px4_os_add_flags)
set(inout_vars
C_FLAGS CXX_FLAGS OPTIMIZATION_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS)
px4_parse_function_args(
NAME px4_os_add_flags
ONE_VALUE ${inout_vars} BOARD
REQUIRED ${inout_vars} BOARD
ARGN ${ARGN})
include(px4_add_common_flags)
px4_add_common_flags(
BOARD ${PX4_BOARD}
C_FLAGS ${C_FLAGS}
CXX_FLAGS ${CXX_FLAGS}
OPTIMIZATION_FLAGS ${OPTIMIZATION_FLAGS}
EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS}
INCLUDE_DIRS ${INCLUDE_DIRS}
LINK_DIRS ${LINK_DIRS}
DEFINITIONS ${DEFINITIONS})
set(added_c_flags)
set(added_cxx_flags)
set(added_exe_linker_flags)
add_definitions(
-D__PX4_POSIX
-Dnoreturn_function=__attribute__\(\(noreturn\)\)
@ -281,177 +221,107 @@ function(px4_os_add_flags)
include_directories(platforms/posix/include)
if(UNIX AND APPLE)
add_definitions(
-D__PX4_DARWIN
-D__DF_DARWIN
)
if ("${PX4_BOARD}" MATCHES "sitl")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message(FATAL_ERROR "PX4 Firmware requires XCode 8 or newer on Mac OS. Version installed on this system: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
# message(STATUS "PX4 Darwin Version: ${DARWIN_VERSION}")
if (DARWIN_VERSION LESS 16)
if(UNIX AND APPLE)
add_definitions(
-DCLOCK_MONOTONIC=1
-DCLOCK_REALTIME=0
-D__PX4_APPLE_LEGACY
-D__PX4_DARWIN
-D__DF_DARWIN
)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message(FATAL_ERROR "PX4 Firmware requires XCode 8 or newer on Mac OS. Version installed on this system: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
# message(STATUS "PX4 Darwin Version: ${DARWIN_VERSION}")
if (DARWIN_VERSION LESS 16)
add_definitions(
-DCLOCK_MONOTONIC=1
-DCLOCK_REALTIME=0
-D__PX4_APPLE_LEGACY
)
endif()
elseif(CYGWIN)
add_definitions(
-D__PX4_CYGWIN
-D_GNU_SOURCE
-D__USE_LINUX_IOCTL_DEFS
-U__CUSTOM_FILE_IO__
)
else()
add_definitions(
-D__PX4_LINUX
-D__DF_LINUX
)
endif()
elseif(CYGWIN)
add_definitions(
-D__PX4_CYGWIN
-D_GNU_SOURCE
-D__USE_LINUX_IOCTL_DEFS
-U __CUSTOM_FILE_IO__
)
else()
elseif (("${PX4_BOARD}" MATCHES "navio2") OR ("${PX4_BOARD}" MATCHES "raspberrypi"))
#TODO: move to board support
add_definitions(
-D__PX4_LINUX
# For DriverFramework
-D__DF_LINUX
)
endif()
# This block sets added_c_flags (appends to others).
if ("${PX4_BOARD}" STREQUAL "eagle")
if ("$ENV{HEXAGON_ARM_SYSROOT}" STREQUAL "")
message(FATAL_ERROR "HEXAGON_ARM_SYSROOT not set")
else()
set(HEXAGON_ARM_SYSROOT $ENV{HEXAGON_ARM_SYSROOT})
endif()
# Add the toolchain specific flags
list(APPEND added_c_flags --sysroot=${HEXAGON_ARM_SYSROOT})
list(APPEND added_cxx_flags --sysroot=${HEXAGON_ARM_SYSROOT})
# TODO: Wmissing-field-initializers ignored on older toolchain, can be removed eventually
list(APPEND added_cxx_flags -Wno-missing-field-initializers)
list(APPEND added_exe_linker_flags
-Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/usr/lib
-Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/lib
--sysroot=${HEXAGON_ARM_SYSROOT}
)
# This block sets added_c_flags (appends to others).
elseif ("${PX4_BOARD}" STREQUAL "excelsior")
if ("$ENV{HEXAGON_ARM_SYSROOT}" STREQUAL "")
message(FATAL_ERROR "HEXAGON_ARM_SYSROOT not set")
else()
set(HEXAGON_ARM_SYSROOT $ENV{HEXAGON_ARM_SYSROOT})
endif()
set(excelsior_flags --sysroot=${HEXAGON_ARM_SYSROOT}/lib32-apq8096 -mfloat-abi=softfp -mfpu=neon -mthumb-interwork)
# Add the toolchain specific flags
list(APPEND added_c_flags ${excelsior_flags})
list(APPEND added_cxx_flags ${excelsior_flags})
list(APPEND added_exe_linker_flags
-Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/lib32-apq8096/usr/lib
-Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/lib32-apq8096/lib
${excelsior_flags}
)
elseif ("${PX4_BOARD}" STREQUAL "rpi")
add_definitions(
-D__PX4_POSIX_RPI
-D__DF_LINUX # For DriverFramework
-D__DF_RPI # For DriverFramework
-D__DF_RPI
)
set(RPI_COMPILE_FLAGS -mcpu=cortex-a53 -mfpu=neon -mfloat-abi=hard)
list(APPEND added_c_flags ${RPI_COMPILE_FLAGS})
list(APPEND added_cxx_flags ${RPI_COMPILE_FLAGS})
elseif ("${PX4_BOARD}" MATCHES "bebop")
# TODO: Wmissing-field-initializers ignored on older toolchain, can be removed eventually
list(APPEND added_cxx_flags -Wno-missing-field-initializers)
find_program(CXX_COMPILER_PATH ${CMAKE_CXX_COMPILER})
GET_FILENAME_COMPONENT(CXX_COMPILER_PATH ${CXX_COMPILER_PATH} DIRECTORY)
GET_FILENAME_COMPONENT(CXX_COMPILER_PATH "${CXX_COMPILER_PATH}/../" ABSOLUTE)
IF ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CLANG_COMPILE_FLAGS
--target=arm-pc-linux-gnueabihf
-ccc-gcc-name arm-linux-gnueabihf-gcc
--sysroot=${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc
-I${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/include/
)
list(APPEND added_c_flags ${CLANG_COMPILE_FLAGS})
list(APPEND added_cxx_flags ${CLANG_COMPILE_FLAGS})
list(APPEND added_exe_linker_flags ${POSIX_CMAKE_EXE_LINKER_FLAGS} ${CLANG_COMPILE_FLAGS}
-B${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/lib
-L${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/lib
)
ENDIF()
elseif ("${PX4_BOARD}" STREQUAL "bebop")
#TODO: move to board support
add_definitions(
-D__PX4_POSIX_BEBOP
-D__DF_LINUX # Define needed DriverFramework
-D__DF_BEBOP # Define needed DriverFramework
)
-D__PX4_LINUX
-D__PX4_POSIX_BEBOP # TODO: remove
# TODO: Wmissing-field-initializers ignored on older toolchain, can be removed eventually
list(APPEND added_cxx_flags -Wno-missing-field-initializers)
# For DriverFramework
-D__DF_LINUX
-D__DF_BEBOP
)
elseif ("${PX4_BOARD}" MATCHES "aerotenna_ocpoc")
add_definitions(
-D__PX4_POSIX_OCPOC
-D__DF_LINUX # For DriverFramework
-D__DF_OCPOC # For DriverFramework
-D__PX4_POSIX
)
elseif ("${PX4_BOARD}" STREQUAL "beaglebone_blue")
#TODO: move to board support
add_definitions(
-D__PX4_POSIX_BBBLUE
-D__PX4_POSIX
-D__DF_LINUX # For DriverFramework
-D__DF_BBBLUE # For DriverFramework
-DRC_AUTOPILOT_EXT # Enable extensions in Robotics Cape Library
#-DDEBUG_BUILD
-D__PX4_LINUX
-D__PX4_POSIX_OCPOC # TODO: remove
#optional __DF_BBBLUE_USE_RC_BMP280_IMP
-D__DF_BBBLUE_USE_RC_BMP280_IMP
-D__PX4_BBBLUE_DEFAULT_MAVLINK_WIFI="wlan"
# For DriverFramework
-D__DF_LINUX
-D__DF_OCPOC
)
set(BBBLUE_COMPILE_FLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=hard -mtune=cortex-a8)
list(APPEND added_c_flags ${BBBLUE_COMPILE_FLAGS})
list(APPEND added_cxx_flags ${BBBLUE_COMPILE_FLAGS})
elseif ("${PX4_BOARD}" MATCHES "beaglebone_blue")
#TODO: move to board support
add_definitions(
-D__PX4_LINUX
-D__PX4_POSIX_BBBLUE # TODO: remove
# For DriverFramework
-D__DF_LINUX
-D__DF_BBBLUE
-D__DF_BBBLUE_USE_RC_BMP280_IMP # optional
-DRC_AUTOPILOT_EXT # Enable extensions in Robotics Cape Library, TODO: remove
)
set(LIBROBOTCONTROL_INSTALL_DIR $ENV{LIBROBOTCONTROL_INSTALL_DIR})
# TODO: Wmissing-field-initializers ignored on older toolchain, can be removed eventually
#
# On cross compile host system and native build system:
# a) select and define LIBROBOTCONTROL_INSTALL_DIR environment variable so that
# other unwanted headers will not be included
# b) install robotcontrol.h and rc/* into $LIBROBOTCONTROL_INSTALL_DIR/include
# c) install pre-built native (ARM) version of librobotcontrol.* into $LIBROBOTCONTROL_INSTALL_DIR/lib
list(APPEND added_cxx_flags -I${LIBROBOTCONTROL_INSTALL_DIR}/include -Wno-missing-field-initializers)
list(APPEND added_c_flags -I${LIBROBOTCONTROL_INSTALL_DIR}/include)
list(APPEND added_exe_linker_flags -L${LIBROBOTCONTROL_INSTALL_DIR}/lib)
endif()
add_compile_options(-I${LIBROBOTCONTROL_INSTALL_DIR}/include)
# output
foreach(var ${inout_vars})
string(TOLOWER ${var} lower_var)
set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)
endforeach()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LIBROBOTCONTROL_INSTALL_DIR}/lib")
endif()
endfunction()

View File

@ -90,9 +90,10 @@ foreach(viewer ${viewers})
endforeach()
endforeach()
px4_join(OUT posix_vmd_make_target_list LIST ${all_posix_vmd_make_targets} GLUE "\\n")
string(REPLACE ";" "," posix_vmd_make_target_list "${all_posix_vmd_make_targets}")
add_custom_target(list_vmd_make_targets
COMMAND sh -c "printf \"${posix_vmd_make_target_list}\\n\""
COMMENT "List of acceptable '${CONFIG}' <viewer_model_debugger> targets:"
COMMENT "List of acceptable '${PX4_BOARD}' <viewer_model_debugger> targets:"
VERBATIM
)

View File

@ -9,8 +9,6 @@ add_subdirectory(src)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes")
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
px4_qurt_generate_builtin_commands(
@ -20,6 +18,8 @@ px4_qurt_generate_builtin_commands(
FASTRPC_STUB_GEN(px4muorb.idl)
add_definitions(-D__QAIC_SKEL_EXPORT=__EXPORT)
# Enable build without HexagonSDK to check link dependencies
if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
@ -36,6 +36,7 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
)
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

View File

@ -31,7 +31,6 @@
#
############################################################################
#=============================================================================
#
# Defined functions in this file
@ -106,61 +105,10 @@ endfunction()
# Set the qurt build flags.
#
# Usage:
# px4_os_add_flags(
# C_FLAGS <inout-variable>
# CXX_FLAGS <inout-variable>
# OPTIMIZATION_FLAGS <inout-variable>
# EXE_LINKER_FLAGS <inout-variable>
# INCLUDE_DIRS <inout-variable>
# LINK_DIRS <inout-variable>
# DEFINITIONS <inout-variable>)
#
# Input:
# BOARD : flags depend on board/qurt config
#
# Input/Output: (appends to existing variable)
# C_FLAGS : c compile flags variable
# CXX_FLAGS : c++ compile flags variable
# OPTIMIZATION_FLAGS : optimization compile flags variable
# EXE_LINKER_FLAGS : executable linker flags variable
# INCLUDE_DIRS : include directories
# LINK_DIRS : link directories
# DEFINITIONS : definitions
#
# Note that EXE_LINKER_FLAGS is not suitable for adding libraries because
# these flags are added before any of the object files and static libraries.
# Add libraries in src/firmware/qurt/CMakeLists.txt.
#
# Example:
# px4_os_add_flags(
# C_FLAGS CMAKE_C_FLAGS
# CXX_FLAGS CMAKE_CXX_FLAGS
# OPTIMIZATION_FLAGS optimization_flags
# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS
# INCLUDES <list>)
# px4_os_add_flags()
#
function(px4_os_add_flags)
set(inout_vars
C_FLAGS CXX_FLAGS OPTIMIZATION_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS)
px4_parse_function_args(
NAME px4_os_add_flags
ONE_VALUE ${inout_vars} BOARD
REQUIRED ${inout_vars} BOARD
ARGN ${ARGN})
include(px4_add_common_flags)
px4_add_common_flags(
BOARD ${PX4_BOARD}
C_FLAGS ${C_FLAGS}
CXX_FLAGS ${CXX_FLAGS}
OPTIMIZATION_FLAGS ${OPTIMIZATION_FLAGS}
EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS}
INCLUDE_DIRS ${INCLUDE_DIRS}
LINK_DIRS ${LINK_DIRS}
DEFINITIONS ${DEFINITIONS})
set(DSPAL_ROOT src/lib/DriverFramework/dspal)
include_directories(
${DSPAL_ROOT}/include
@ -174,38 +122,24 @@ function(px4_os_add_flags)
)
add_definitions(
-D__DF_QURT # For DriverFramework
-D__PX4_POSIX
-D__PX4_QURT
-D__QAIC_SKEL_EXPORT=__EXPORT
-D__DF_QURT # For DriverFramework
)
# Add the toolchain specific flags
set(added_c_flags
-Wno-unknown-warning-option
)
set(added_cxx_flags
-Wno-unknown-warning-option
-Wno-unreachable-code
)
set(added_optimization_flags
add_compile_options(
-fPIC
-fmath-errno
)
-Wno-unknown-warning-option
)
# Clear -rdynamic flag which fails for hexagon
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
set(DF_TARGET "qurt" PARENT_SCOPE)
# output
foreach(var ${inout_vars})
string(TOLOWER ${var} lower_var)
set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)
endforeach()
set(DF_TARGET "qurt" CACHE STRING "DriverFramework target" FORCE)
endfunction()

View File

@ -15,10 +15,10 @@
#include <lib/rc/sumd.h>
#include <lib/rc/crsf.h>
#if !defined(CONFIG_ARCH_BOARD_SITL)
#define TEST_DATA_PATH "/fs/microsd"
#else
#if defined(CONFIG_ARCH_BOARD_PX4_SITL)
#define TEST_DATA_PATH "./test_data/"
#else
#define TEST_DATA_PATH "/fs/microsd"
#endif
extern "C" __EXPORT int rc_tests_main(int argc, char *argv[]);

View File

@ -76,8 +76,6 @@ endif()
add_library(version version.c)
string(TOUPPER "${PX4_BOARD}" PX4_BOARD_NAME)
target_compile_definitions(version
PUBLIC
PX4_BOARD_NAME="${PX4_BOARD_NAME}"

View File

@ -665,7 +665,7 @@ void Logger::add_default_topics()
add_topic("vtol_vehicle_status", 200);
add_topic("wind_estimate", 200);
#ifdef CONFIG_ARCH_BOARD_SITL
#ifdef CONFIG_ARCH_BOARD_PX4_SITL
add_topic("actuator_armed");
add_topic("actuator_controls_virtual_fw");
add_topic("actuator_controls_virtual_mc");
@ -681,7 +681,7 @@ void Logger::add_default_topics()
add_topic("vehicle_global_position_groundtruth", 100);
add_topic("vehicle_local_position_groundtruth", 100);
add_topic("vehicle_roi");
#endif
#endif /* CONFIG_ARCH_BOARD_PX4_SITL */
}
void Logger::add_high_rate_topics()

View File

@ -1337,7 +1337,7 @@ void Mavlink::send_autopilot_capabilites()
memcpy(&msg.uid2, &px4_guid, sizeof(msg.uid2));
#endif /* BOARD_HAS_NO_UUID */
#ifdef CONFIG_ARCH_BOARD_SITL
#ifdef CONFIG_ARCH_BOARD_PX4_SITL
// To avoid that multiple SITL instances have the same UUID, we add the mavlink
// system ID. We subtract 1, so that the first UUID remains unchanged given the
// default system ID is 1.
@ -1345,7 +1345,7 @@ void Mavlink::send_autopilot_capabilites()
// Note that the UUID show in `ver` will still be the same for all instances.
msg.uid += mavlink_system.sysid - 1;
msg.uid2[0] += mavlink_system.sysid - 1;
#endif
#endif /* CONFIG_ARCH_BOARD_PX4_SITL */
mavlink_msg_autopilot_version_send_struct(get_channel(), &msg);
}
}

View File

@ -145,6 +145,7 @@ if (GENERATE_RTPS_BRIDGE)
git_micro_cdr
microcdr
)
add_dependencies(microcdr prebuild_targets)
# microCDR
target_include_directories(uorb_msgs_microcdr

View File

@ -1022,7 +1022,7 @@ void VotedSensorsUpdate::print_status()
bool
VotedSensorsUpdate::apply_gyro_calibration(DevHandle &h, const struct gyro_calibration_s *gcal, const int device_id)
{
#if !defined(__PX4_QURT) && !defined(__PX4_POSIX_RPI) && !defined(__PX4_POSIX_BEBOP) && !defined(__PX4_POSIX_BBBLUE)
#if defined(__PX4_NUTTX)
/* On most systems, we can just use the IOCTL call to set the calibration params. */
return !h.ioctl(GYROIOCSSCALE, (long unsigned int)gcal);
@ -1036,7 +1036,7 @@ VotedSensorsUpdate::apply_gyro_calibration(DevHandle &h, const struct gyro_calib
bool
VotedSensorsUpdate::apply_accel_calibration(DevHandle &h, const struct accel_calibration_s *acal, const int device_id)
{
#if !defined(__PX4_QURT) && !defined(__PX4_POSIX_RPI) && !defined(__PX4_POSIX_BEBOP) && !defined(__PX4_POSIX_BBBLUE)
#if defined(__PX4_NUTTX)
/* On most systems, we can just use the IOCTL call to set the calibration params. */
return !h.ioctl(ACCELIOCSSCALE, (long unsigned int)acal);
@ -1050,7 +1050,7 @@ VotedSensorsUpdate::apply_accel_calibration(DevHandle &h, const struct accel_cal
bool
VotedSensorsUpdate::apply_mag_calibration(DevHandle &h, const struct mag_calibration_s *mcal, const int device_id)
{
#if !defined(__PX4_QURT) && !defined(__PX4_POSIX)
#if defined(__PX4_NUTTX)
if (!h.isValid()) {
return false;

View File

@ -79,7 +79,7 @@ static bool should_prearm = false;
#endif
#endif
#if defined(CONFIG_ARCH_BOARD_SITL)
#if defined(CONFIG_ARCH_BOARD_PX4_SITL)
#define MIXER_PATH(_file) "etc/mixers/"#_file
#define MIXER_ONBOARD_PATH "etc/mixers"
#else