2015-09-07 21:37:45 -03:00
|
|
|
############################################################################
|
|
|
|
#
|
2019-04-25 03:16:45 -03:00
|
|
|
# Copyright (c) 2017 - 2019 PX4 Development Team. All rights reserved.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in
|
|
|
|
# the documentation and/or other materials provided with the
|
|
|
|
# distribution.
|
|
|
|
# 3. Neither the name PX4 nor the names of its contributors may be
|
|
|
|
# used to endorse or promote products derived from this software
|
|
|
|
# without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# CMAKE CODING STANDARD FOR PX4
|
|
|
|
#
|
|
|
|
# Structure
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
2015-09-08 01:30:35 -03:00
|
|
|
# * Common functions should be included in px_base.cmake.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# * OS/ board specific fucntions should be include in
|
2018-11-16 13:52:37 -04:00
|
|
|
# px_impl_${PX4_PLATFORM}.cmake or px4_impl_${PX4_PLATFORM}_${PX4_BOARD}.cmake.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Formatting
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# * Use hard indents to match the px4 source code.
|
|
|
|
#
|
|
|
|
# * All function and script arguments are upper case.
|
|
|
|
#
|
|
|
|
# * All local variables are lower case.
|
|
|
|
#
|
|
|
|
# * All cmake functions are lowercase.
|
|
|
|
#
|
2015-09-12 16:47:23 -03:00
|
|
|
# * For else, endif, endfunction, etc, never put the name of the statement
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# Functions/Macros
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
2015-09-08 00:58:31 -03:00
|
|
|
# * Use px4_parse_function_args to parse functions and check for required
|
2015-09-10 00:00:58 -03:00
|
|
|
# arguments. Unless there is only one argument in the function and it is clear.
|
2015-09-08 00:58:31 -03:00
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# * Never use macros. They allow overwriting global variables and this
|
|
|
|
# makes variable declarations hard to locate.
|
|
|
|
#
|
|
|
|
# * If a target from add_custom_* is set in a function, explicitly pass it
|
|
|
|
# as an output argument so that the target name is clear to the user.
|
|
|
|
#
|
2016-01-19 03:16:31 -04:00
|
|
|
# * Avoid use of global variables in functions. Functions in a nested
|
2015-09-07 21:37:45 -03:00
|
|
|
# scope may use global variables, but this makes it difficult to
|
2018-04-11 16:10:51 -03:00
|
|
|
# reuse functions.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Included CMake Files
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
2015-09-12 06:26:31 -03:00
|
|
|
# * All variables in config files must have the prefix "config_".
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# * Never set global variables in an included cmake file,
|
2015-09-11 00:53:25 -03:00
|
|
|
# you may only define functions. This excludes config and Toolchain files.
|
|
|
|
# This makes it clear to the user when variables are being set or targets
|
2015-09-07 21:37:45 -03:00
|
|
|
# are being created.
|
|
|
|
#
|
2015-09-10 00:18:53 -03:00
|
|
|
# * Setting a global variable in a CMakeLists.txt file is ok, because
|
|
|
|
# each CMakeLists.txt file has scope in the current directory and all
|
2017-06-01 09:47:33 -03:00
|
|
|
# subdirectories, so it is not truly global.
|
2015-09-10 00:18:53 -03:00
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# * All toolchain files should be included in the cmake
|
|
|
|
# directory and named Toolchain-"name".cmake.
|
|
|
|
#
|
|
|
|
# Misc
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# * If referencing a string variable, don't put it in quotes.
|
2018-11-16 13:52:37 -04:00
|
|
|
# Don't do "${PX4_PLATFORM}" STREQUAL "posix",
|
|
|
|
# instead type ${PX4_PLATFORM} STREQUAL "posix". This will throw an
|
|
|
|
# error when ${PX4_PLATFORM} is not defined instead of silently
|
2015-09-07 21:37:45 -03:00
|
|
|
# evaluating to false.
|
|
|
|
#
|
|
|
|
#=============================================================================
|
|
|
|
|
2017-11-21 21:22:48 -04:00
|
|
|
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
2015-09-10 23:15:11 -03:00
|
|
|
|
2016-08-18 16:37:23 -03:00
|
|
|
set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake)
|
2017-12-06 21:40:48 -04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# git
|
|
|
|
#
|
2018-11-16 13:52:37 -04:00
|
|
|
include(px4_git)
|
2017-12-06 21:40:48 -04:00
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --always --tags
|
2018-06-21 12:41:03 -03:00
|
|
|
OUTPUT_VARIABLE PX4_GIT_TAG
|
2017-12-06 21:40:48 -04:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
define_property(GLOBAL PROPERTY PX4_MODULE_LIBRARIES
|
|
|
|
BRIEF_DOCS "PX4 module libs"
|
2017-08-29 18:22:05 -03:00
|
|
|
FULL_DOCS "List of all PX4 module libraries"
|
|
|
|
)
|
2016-08-25 16:47:45 -03:00
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
define_property(GLOBAL PROPERTY PX4_MODULE_PATHS
|
|
|
|
BRIEF_DOCS "PX4 module paths"
|
|
|
|
FULL_DOCS "List of paths to all PX4 modules"
|
|
|
|
)
|
|
|
|
|
2015-09-10 23:15:11 -03:00
|
|
|
#=============================================================================
|
2017-06-01 09:47:33 -03:00
|
|
|
# configuration
|
2015-09-10 23:15:11 -03:00
|
|
|
#
|
|
|
|
|
2018-11-22 00:27:21 -04:00
|
|
|
set(CONFIG "px4_sitl_default" CACHE STRING "desired configuration")
|
2017-01-29 16:32:18 -04:00
|
|
|
|
2018-11-23 12:26:41 -04:00
|
|
|
include(px4_add_module)
|
2018-11-16 13:52:37 -04:00
|
|
|
set(config_module_list)
|
|
|
|
set(config_df_driver_list)
|
2017-01-29 16:32:18 -04:00
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
# find PX4 config
|
|
|
|
# look for in tree board config that matches CONFIG input
|
|
|
|
if(NOT PX4_CONFIG_FILE)
|
|
|
|
|
|
|
|
file(GLOB_RECURSE board_configs
|
|
|
|
RELATIVE "${PX4_SOURCE_DIR}/boards"
|
|
|
|
"boards/*.cmake"
|
|
|
|
)
|
|
|
|
|
2019-05-02 06:02:48 -03:00
|
|
|
set(PX4_CONFIGS ${board_configs} CACHE STRING "PX4 board configs" FORCE)
|
2018-11-16 13:52:37 -04:00
|
|
|
|
|
|
|
foreach(filename ${board_configs})
|
|
|
|
# parse input CONFIG into components to match with existing in tree configs
|
|
|
|
# the platform prefix (eg nuttx_) is historical, and removed if present
|
|
|
|
string(REPLACE ".cmake" "" filename_stripped ${filename})
|
|
|
|
string(REPLACE "/" ";" config ${filename_stripped})
|
|
|
|
list(LENGTH config config_len)
|
|
|
|
|
|
|
|
if(${config_len} EQUAL 3)
|
|
|
|
|
|
|
|
|
|
|
|
list(GET config 0 vendor)
|
|
|
|
list(GET config 1 model)
|
|
|
|
list(GET config 2 label)
|
|
|
|
|
|
|
|
set(board "${vendor}${model}")
|
|
|
|
|
|
|
|
# <VENDOR>_<MODEL>_<LABEL> (eg px4_fmu-v2_default)
|
|
|
|
# <VENDOR>_<MODEL>_default (eg px4_fmu-v2) # allow skipping label if "default"
|
|
|
|
if ((${CONFIG} MATCHES "${vendor}_${model}_${label}") OR # match full vendor, model, label
|
|
|
|
((${label} STREQUAL "default") AND (${CONFIG} STREQUAL "${vendor}_${model}")) # default label can be omitted
|
|
|
|
)
|
|
|
|
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
|
2018-11-22 00:27:21 -04:00
|
|
|
# <BOARD>_<LABEL> (eg px4_fmu-v2_default)
|
|
|
|
# <BOARD>_default (eg px4_fmu-v2) # allow skipping label if "default"
|
2018-11-16 13:52:37 -04:00
|
|
|
if ((${CONFIG} MATCHES "${board}_${label}") OR # match full board, label
|
|
|
|
((${label} STREQUAL "default") AND (${CONFIG} STREQUAL "${board}")) # default label can be omitted
|
|
|
|
)
|
|
|
|
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# LEGACY form
|
2018-11-22 00:27:21 -04:00
|
|
|
# <OS>_<BOARD>_<LABEL> (eg nuttx_px4_fmu-v2_default)
|
2018-11-16 13:52:37 -04:00
|
|
|
string(REGEX REPLACE "^nuttx_|^posix_|^qurt_" "" config_no_os ${CONFIG}) # ignore OS prefix
|
|
|
|
|
|
|
|
if ((${config_no_os} MATCHES "${board}_${label}"))
|
|
|
|
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# LEGACY form special case to ease board layout transition (2018-11-18)
|
|
|
|
# match board with model and label only: eg sitl_default -> px4_sitl_default
|
|
|
|
if ((${config_no_os} MATCHES "${model}_${label}"))
|
|
|
|
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT PX4_CONFIG_FILE)
|
|
|
|
message(FATAL_ERROR "PX4 config file not set, try one of ${PX4_CONFIGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "PX4 config file: ${PX4_CONFIG_FILE}")
|
|
|
|
include(px4_add_board)
|
|
|
|
include(${PX4_CONFIG_FILE})
|
2018-11-23 13:39:44 -04:00
|
|
|
message(STATUS "PX4 config: ${PX4_CONFIG}")
|
2018-11-16 13:52:37 -04:00
|
|
|
message(STATUS "PX4 platform: ${PX4_PLATFORM}")
|
|
|
|
|
2018-12-09 07:22:49 -04:00
|
|
|
if (ENABLE_LOCKSTEP_SCHEDULER)
|
|
|
|
add_definitions(-DENABLE_LOCKSTEP_SCHEDULER)
|
|
|
|
message(STATUS "PX4 lockstep: enabled")
|
|
|
|
else()
|
|
|
|
message(STATUS "PX4 lockstep: disabled")
|
|
|
|
endif()
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
# external modules
|
2016-09-07 09:05:22 -03:00
|
|
|
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
|
2015-09-10 23:15:11 -03:00
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
|
2017-02-24 10:06:38 -04:00
|
|
|
get_filename_component(EXTERNAL_MODULES_LOCATION "${EXTERNAL_MODULES_LOCATION}" ABSOLUTE)
|
|
|
|
endif()
|
|
|
|
|
2018-08-27 06:35:11 -03:00
|
|
|
set_property(GLOBAL PROPERTY PX4_MODULE_CONFIG_FILES)
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
include(platforms/${PX4_PLATFORM}/cmake/px4_impl_os.cmake)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake)
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2019-01-30 11:54:53 -04:00
|
|
|
if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/init.cmake")
|
|
|
|
include(init)
|
|
|
|
endif()
|
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
# CMake build type (Debug Release RelWithDebInfo MinSizeRel Coverage)
|
2017-06-01 09:47:33 -03:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
2018-11-16 13:52:37 -04:00
|
|
|
if (${PX4_PLATFORM} STREQUAL "nuttx")
|
2017-06-01 09:47:33 -03:00
|
|
|
set(PX4_BUILD_TYPE "MinSizeRel")
|
|
|
|
else()
|
|
|
|
set(PX4_BUILD_TYPE "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_BUILD_TYPE ${PX4_BUILD_TYPE} CACHE STRING "Build type" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2018-09-23 17:52:09 -03:00
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage;AddressSanitizer;UndefinedBehaviorSanitizer")
|
2017-06-01 09:47:33 -03:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
message(STATUS "PX4 version: ${PX4_GIT_TAG}")
|
|
|
|
message(STATUS "cmake build type: ${CMAKE_BUILD_TYPE}")
|
2017-11-21 21:22:48 -04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# project definition
|
|
|
|
#
|
|
|
|
project(px4 CXX C ASM)
|
|
|
|
|
|
|
|
set(package-contact "px4users@googlegroups.com")
|
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2019-06-26 23:25:39 -03:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2018-04-11 16:10:51 -03:00
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2016-12-12 18:53:12 -04:00
|
|
|
|
2018-09-27 20:08:08 -03:00
|
|
|
# For the catkin build process, unset build of dynamically-linked binaries
|
2018-12-12 14:30:07 -04:00
|
|
|
# and do not change CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
|
|
|
if (NOT CATKIN_DEVEL_PREFIX)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR})
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX4_BINARY_DIR})
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX4_BINARY_DIR})
|
|
|
|
else()
|
2018-09-27 20:08:08 -03:00
|
|
|
SET(BUILD_SHARED_LIBS OFF)
|
|
|
|
endif()
|
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
#=============================================================================
|
2016-12-12 18:53:12 -04:00
|
|
|
|
2016-07-24 14:07:14 -03:00
|
|
|
# Setup install paths
|
2018-11-16 13:52:37 -04:00
|
|
|
if (${PX4_PLATFORM} STREQUAL "posix")
|
2017-11-21 21:22:48 -04:00
|
|
|
|
2018-11-23 13:39:44 -04:00
|
|
|
# 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)
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
include(coverage)
|
|
|
|
include(sanitizers)
|
2018-04-11 16:10:51 -03:00
|
|
|
|
2017-11-21 21:22:48 -04:00
|
|
|
# Define GNU standard installation directories
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
if (NOT CMAKE_INSTALL_PREFIX)
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix" FORCE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-01-14 22:59:45 -04:00
|
|
|
#=============================================================================
|
|
|
|
# ccache
|
|
|
|
#
|
2017-12-29 16:13:41 -04:00
|
|
|
option(CCACHE "Use ccache if available" ON)
|
2017-01-14 22:59:45 -04:00
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
2017-12-29 16:13:41 -04:00
|
|
|
if (CCACHE AND CCACHE_PROGRAM AND NOT DEFINED ENV{CCACHE_DISABLE})
|
2018-06-30 15:35:58 -03:00
|
|
|
|
|
|
|
get_filename_component(ccache_real_path ${CCACHE_PROGRAM} REALPATH)
|
|
|
|
get_filename_component(cxx_real_path ${CMAKE_CXX_COMPILER} REALPATH)
|
|
|
|
get_filename_component(cxx_abs_path ${CMAKE_CXX_COMPILER} ABSOLUTE)
|
|
|
|
|
|
|
|
if ("${ccache_real_path}" STREQUAL "${cxx_real_path}")
|
|
|
|
message(STATUS "ccache enabled via symlink (${cxx_abs_path} -> ${cxx_real_path})")
|
|
|
|
else()
|
|
|
|
message(STATUS "ccache enabled (export CCACHE_DISABLE=1 to disable)")
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
|
|
|
endif()
|
|
|
|
|
2017-01-14 22:59:45 -04:00
|
|
|
endif()
|
|
|
|
|
2015-09-11 00:43:59 -03:00
|
|
|
#=============================================================================
|
2016-08-25 16:47:45 -03:00
|
|
|
# find programs and packages
|
2015-09-11 00:43:59 -03:00
|
|
|
#
|
2016-08-25 16:47:45 -03:00
|
|
|
|
|
|
|
# see if catkin was invoked to build this
|
|
|
|
if (CATKIN_DEVEL_PREFIX)
|
|
|
|
message(STATUS "catkin ENABLED")
|
|
|
|
find_package(catkin REQUIRED)
|
|
|
|
if (catkin_FOUND)
|
|
|
|
catkin_package()
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "catkin not found")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-11-20 12:52:22 -04:00
|
|
|
find_package(PythonInterp REQUIRED)
|
2018-08-04 19:22:08 -03:00
|
|
|
|
|
|
|
option(PYTHON_COVERAGE "Python code coverage" OFF)
|
|
|
|
if(PYTHON_COVERAGE)
|
|
|
|
message(STATUS "python coverage enabled")
|
|
|
|
set(PYTHON_EXECUTABLE coverage run -p)
|
|
|
|
else()
|
|
|
|
# run normally (broken under coveragepy)
|
|
|
|
px4_find_python_module(jinja2 REQUIRED)
|
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# build flags
|
|
|
|
#
|
2018-11-23 13:39:44 -04:00
|
|
|
include(px4_add_common_flags)
|
|
|
|
px4_add_common_flags()
|
|
|
|
px4_os_add_flags()
|
2015-09-08 00:58:31 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
2017-06-05 16:24:10 -03:00
|
|
|
# message, and airframe generation
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
2018-11-16 13:52:37 -04:00
|
|
|
include(px4_metadata)
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
add_subdirectory(msg EXCLUDE_FROM_ALL)
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
px4_generate_airframes_xml(BOARD ${PX4_BOARD})
|
2017-06-01 09:47:33 -03:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# DriverFramework
|
|
|
|
#
|
2017-11-21 21:22:48 -04:00
|
|
|
px4_add_git_submodule(TARGET git_driverframework PATH "src/lib/DriverFramework")
|
2018-11-16 13:52:37 -04:00
|
|
|
set(OS ${PX4_PLATFORM})
|
2018-04-11 16:10:51 -03:00
|
|
|
add_subdirectory(src/lib/DriverFramework/framework)
|
2017-11-21 21:22:48 -04:00
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
# List the DriverFramework drivers
|
|
|
|
if (DEFINED config_df_driver_list)
|
|
|
|
message("DF Drivers: ${config_df_driver_list}")
|
2017-01-12 20:58:58 -04:00
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
set(df_driver_libs)
|
|
|
|
foreach(driver ${config_df_driver_list})
|
|
|
|
add_subdirectory(src/lib/DriverFramework/drivers/${driver})
|
|
|
|
list(APPEND df_driver_libs df_${driver})
|
|
|
|
message("Adding DF driver: ${driver}")
|
|
|
|
endforeach()
|
|
|
|
|
2015-10-03 15:51:12 -03:00
|
|
|
#=============================================================================
|
|
|
|
# external projects
|
|
|
|
#
|
2016-08-18 16:37:23 -03:00
|
|
|
set(ep_base ${PX4_BINARY_DIR}/external)
|
2015-10-03 15:51:12 -03:00
|
|
|
set_property(DIRECTORY PROPERTY EP_BASE ${ep_base})
|
|
|
|
|
|
|
|
# add external project install folders to build
|
|
|
|
link_directories(${ep_base}/Install/lib)
|
|
|
|
include_directories(${ep_base}/Install/include)
|
2015-10-10 05:47:17 -03:00
|
|
|
# add the directories so cmake won't warn
|
|
|
|
execute_process(COMMAND cmake -E make_directory ${ep_base}/Install/lib)
|
|
|
|
execute_process(COMMAND cmake -E make_directory ${ep_base}/Install/include)
|
2015-10-03 15:51:12 -03:00
|
|
|
|
2016-09-07 09:05:22 -03:00
|
|
|
#=============================================================================
|
|
|
|
# external modules
|
|
|
|
#
|
2017-11-21 01:44:23 -04:00
|
|
|
set(external_module_paths)
|
2017-06-01 09:47:33 -03:00
|
|
|
if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
|
2016-09-07 09:05:22 -03:00
|
|
|
message(STATUS "External modules: ${EXTERNAL_MODULES_LOCATION}")
|
2017-11-21 01:44:23 -04:00
|
|
|
add_subdirectory("${EXTERNAL_MODULES_LOCATION}/src" external_modules)
|
2016-09-07 09:05:22 -03:00
|
|
|
|
|
|
|
foreach(external_module ${config_module_list_external})
|
2017-11-21 01:44:23 -04:00
|
|
|
add_subdirectory(${EXTERNAL_MODULES_LOCATION}/src/${external_module} external_modules/${external_module})
|
|
|
|
list(APPEND external_module_paths ${EXTERNAL_MODULES_LOCATION}/src/${external_module})
|
2016-09-07 09:05:22 -03:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2019-03-02 13:18:00 -04:00
|
|
|
#=============================================================================
|
|
|
|
# Testing - Automatic unit and integration testing with CTest
|
|
|
|
#
|
|
|
|
|
2019-04-14 15:55:35 -03:00
|
|
|
# optionally enable cmake testing (supported only on posix)
|
|
|
|
option(CMAKE_TESTING "Configure test targets" OFF)
|
2019-05-09 17:31:24 -03:00
|
|
|
if (${PX4_CONFIG} STREQUAL "px4_sitl_test")
|
|
|
|
set(CMAKE_TESTING ON)
|
|
|
|
endif()
|
2019-04-14 15:55:35 -03:00
|
|
|
if(CMAKE_TESTING)
|
2019-04-23 06:22:14 -03:00
|
|
|
include(CTest) # sets BUILD_TESTING variable
|
2019-04-14 15:55:35 -03:00
|
|
|
endif()
|
2019-04-23 06:22:14 -03:00
|
|
|
|
|
|
|
# enable test filtering to run only specific tests with the ctest -R regex functionality
|
2019-04-23 04:36:03 -03:00
|
|
|
set(TESTFILTER "" CACHE STRING "Filter string for ctest to selectively only run specific tests (ctest -R)")
|
2019-03-02 13:18:00 -04:00
|
|
|
|
2019-04-23 06:22:14 -03:00
|
|
|
# if testing is enabled download and configure gtest
|
2019-03-02 13:18:00 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/gtest/)
|
|
|
|
include(px4_add_gtest)
|
2019-04-14 15:55:35 -03:00
|
|
|
if(BUILD_TESTING)
|
|
|
|
include(gtest)
|
2019-03-02 13:18:00 -04:00
|
|
|
endif()
|
|
|
|
|
2019-04-23 06:22:14 -03:00
|
|
|
add_custom_target(test_results
|
|
|
|
COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test -R ${TESTFILTER} USES_TERMINAL
|
|
|
|
DEPENDS
|
|
|
|
px4
|
|
|
|
examples__dyn_hello
|
|
|
|
test_mixer_multirotor
|
|
|
|
USES_TERMINAL
|
|
|
|
COMMENT "Running tests"
|
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
|
|
|
set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# subdirectories
|
|
|
|
#
|
2018-04-11 16:10:51 -03:00
|
|
|
add_library(parameters_interface INTERFACE)
|
2018-11-23 12:26:41 -04:00
|
|
|
|
|
|
|
include(px4_add_library)
|
2018-04-11 16:10:51 -03:00
|
|
|
add_subdirectory(src/lib EXCLUDE_FROM_ALL)
|
2018-11-23 12:26:41 -04:00
|
|
|
|
2019-01-22 15:13:20 -04:00
|
|
|
add_subdirectory(src/platforms EXCLUDE_FROM_ALL)
|
2018-04-11 16:10:51 -03:00
|
|
|
add_subdirectory(src/modules/uORB EXCLUDE_FROM_ALL) # TODO: platform layer
|
|
|
|
add_subdirectory(src/drivers/boards EXCLUDE_FROM_ALL)
|
2018-01-15 16:34:18 -04:00
|
|
|
|
2018-12-01 13:42:48 -04:00
|
|
|
if(EXISTS "${PX4_BOARD_DIR}/CMakeLists.txt")
|
|
|
|
add_subdirectory(${PX4_BOARD_DIR})
|
|
|
|
endif()
|
|
|
|
|
2015-09-11 00:43:59 -03:00
|
|
|
foreach(module ${config_module_list})
|
2017-11-21 01:44:23 -04:00
|
|
|
add_subdirectory(src/${module})
|
2015-09-10 00:00:58 -03:00
|
|
|
endforeach()
|
2015-09-07 21:37:45 -03:00
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
# must be the last module before firmware
|
|
|
|
add_subdirectory(src/lib/parameters EXCLUDE_FROM_ALL)
|
|
|
|
target_link_libraries(parameters_interface INTERFACE parameters)
|
|
|
|
|
|
|
|
# firmware added last to generate the builtin for included modules
|
2018-11-16 13:52:37 -04:00
|
|
|
add_subdirectory(platforms/${PX4_PLATFORM})
|
2017-12-11 07:01:09 -04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# uORB graph generation: add a custom target 'uorb_graph'
|
|
|
|
#
|
2018-11-16 13:52:37 -04:00
|
|
|
set(uorb_graph_config ${PX4_BOARD})
|
2017-12-11 07:01:09 -04:00
|
|
|
|
|
|
|
set(graph_module_list "")
|
|
|
|
foreach(module ${config_module_list})
|
|
|
|
set(graph_module_list "${graph_module_list}" "--src-path" "src/${module}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${uorb_graph_config}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/uorb_graph/create.py
|
|
|
|
${module_list}
|
|
|
|
--exclude-path src/examples
|
|
|
|
--file ${PX4_SOURCE_DIR}/Tools/uorb_graph/graph_${uorb_graph_config}
|
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
|
|
|
COMMENT "Generating uORB graph"
|
|
|
|
)
|
|
|
|
add_custom_target(uorb_graph DEPENDS ${uorb_graph_config})
|
|
|
|
|
2018-05-03 23:07:24 -03:00
|
|
|
#=============================================================================
|
|
|
|
# Doxygen
|
|
|
|
#
|
|
|
|
option(BUILD_DOXYGEN "Build doxygen documentation" OFF)
|
|
|
|
|
2018-05-04 00:52:08 -03:00
|
|
|
if (BUILD_DOXYGEN)
|
|
|
|
find_package(Doxygen)
|
|
|
|
if (DOXYGEN_FOUND)
|
|
|
|
# set input and output files
|
|
|
|
set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/Documentation/Doxyfile.in)
|
|
|
|
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
|
|
|
|
|
|
|
# request to configure the file
|
|
|
|
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
|
|
|
|
|
|
|
# note the option ALL which allows to build the docs together with the application
|
|
|
|
add_custom_target(doxygen ALL
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMENT "Generating documentation with Doxygen"
|
|
|
|
DEPENDS uorb_msgs parameters
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2018-05-03 23:07:24 -03:00
|
|
|
|
2018-05-04 00:52:08 -03:00
|
|
|
else()
|
|
|
|
message("Doxygen needs to be installed to generate documentation")
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-05-03 23:07:24 -03:00
|
|
|
|
2018-08-04 19:22:08 -03:00
|
|
|
#=============================================================================
|
|
|
|
# Metadata - helpers for generating documentation
|
|
|
|
#
|
|
|
|
|
|
|
|
add_custom_target(metadata_airframes
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/docs
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
2018-11-16 13:52:37 -04:00
|
|
|
-v -a ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d
|
2018-08-04 19:22:08 -03:00
|
|
|
--markdown ${PX4_BINARY_DIR}/docs/airframes.md
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
2018-11-16 13:52:37 -04:00
|
|
|
-v -a ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d
|
2018-08-04 19:22:08 -03:00
|
|
|
--xml ${PX4_BINARY_DIR}/docs/airframes.xml
|
|
|
|
COMMENT "Generating full airframe metadata (markdown and xml)"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2018-08-27 06:35:11 -03:00
|
|
|
file(GLOB_RECURSE yaml_config_files ${PX4_SOURCE_DIR}/src/modules/*.yaml
|
|
|
|
${PX4_SOURCE_DIR}/src/drivers/*.yaml ${PX4_SOURCE_DIR}/src/lib/*.yaml)
|
2018-08-04 19:22:08 -03:00
|
|
|
add_custom_target(metadata_parameters
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/docs
|
2018-08-27 06:35:11 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
|
|
${PX4_SOURCE_DIR}/Tools/serial/generate_config.py --all-ports --params-file ${PX4_SOURCE_DIR}/src/generated_serial_params.c --config-files ${yaml_config_files}
|
2018-08-04 19:22:08 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/src/lib/parameters/px_process_params.py
|
|
|
|
--src-path `find ${PX4_SOURCE_DIR}/src -maxdepth 4 -type d`
|
|
|
|
--inject-xml ${PX4_SOURCE_DIR}/src/lib/parameters/parameters_injected.xml
|
|
|
|
--markdown ${PX4_BINARY_DIR}/docs/parameters.md
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/src/lib/parameters/px_process_params.py
|
|
|
|
--src-path `find ${PX4_SOURCE_DIR}/src -maxdepth 4 -type d`
|
|
|
|
--inject-xml ${PX4_SOURCE_DIR}/src/lib/parameters/parameters_injected.xml
|
|
|
|
--xml ${PX4_BINARY_DIR}/docs/parameters.xml
|
|
|
|
COMMENT "Generating full parameter metadata (markdown and xml)"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(metadata_module_documentation
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/docs
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_module_doc.py -v --src-path ${PX4_SOURCE_DIR}/src
|
|
|
|
--markdown ${PX4_BINARY_DIR}/docs/modules
|
|
|
|
COMMENT "Generating module documentation"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(all_metadata
|
|
|
|
DEPENDS
|
|
|
|
metadata_airframes
|
|
|
|
metadata_parameters
|
|
|
|
metadata_module_documentation
|
|
|
|
)
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# packaging
|
|
|
|
#
|
|
|
|
# Important to having packaging at end of cmake file.
|
|
|
|
#
|
2018-11-23 13:39:44 -04:00
|
|
|
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${PX4_CONFIG})
|
2018-06-21 12:41:03 -03:00
|
|
|
set(CPACK_PACKAGE_VERSION ${PX4_GIT_TAG})
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CPACK_PACKAGE_CONTACT ${package-contact})
|
2018-11-16 13:52:37 -04:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # TODO: review packaging for linux boards
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
2018-04-11 16:10:51 -03:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The PX4 Pro autopilot.")
|
2018-11-23 13:39:44 -04:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_CONFIG}-${PX4_GIT_TAG}")
|
2018-06-21 12:41:03 -03:00
|
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_GIT_TAG}")
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
|
2017-01-12 18:03:52 -04:00
|
|
|
set(CPACK_PACKAGING_INSTALL_PREFIX "")
|
2016-08-25 16:47:45 -03:00
|
|
|
set(CPACK_SET_DESTDIR "OFF")
|
2018-04-11 16:10:51 -03:00
|
|
|
|
2016-07-24 14:07:14 -03:00
|
|
|
if ("${CMAKE_SYSTEM}" MATCHES "Linux")
|
2018-05-07 13:38:53 -03:00
|
|
|
set(CPACK_GENERATOR "TBZ2")
|
2016-08-25 16:47:45 -03:00
|
|
|
find_program(DPKG_PROGRAM dpkg)
|
|
|
|
if (EXISTS ${DPKG_PROGRAM})
|
|
|
|
list (APPEND CPACK_GENERATOR "DEB")
|
|
|
|
endif()
|
2018-06-01 18:52:33 -03:00
|
|
|
else()
|
2018-05-07 13:38:53 -03:00
|
|
|
set(CPACK_GENERATOR "ZIP")
|
2016-07-24 14:07:14 -03:00
|
|
|
endif()
|
2018-05-07 13:38:53 -03:00
|
|
|
|
2018-06-07 09:02:47 -03:00
|
|
|
include(CPack)
|
2019-08-04 17:11:59 -03:00
|
|
|
include(bloaty)
|