2015-09-07 21:37:45 -03:00
|
|
|
############################################################################
|
|
|
|
#
|
2017-01-14 22:59:45 -04:00
|
|
|
# Copyright (c) 2017 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
|
2015-09-08 01:30:35 -03:00
|
|
|
# px_impl_${OS}.cmake or px4_impl_${OS}_${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
|
|
|
|
# resuse functions.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
# Don't do "${OS}" STREQUAL "posix",
|
|
|
|
# instead type ${OS} STREQUAL "posix". This will throw an
|
|
|
|
# error when ${OS} is not defined instead of silently
|
|
|
|
# evaluating to false.
|
|
|
|
#
|
|
|
|
#=============================================================================
|
|
|
|
|
2015-10-25 10:47:21 -03:00
|
|
|
# Warning: Changing this modifies CMake's internal workings
|
|
|
|
# and leads to wrong toolchain detection
|
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}")
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
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})
|
|
|
|
|
2017-12-06 21:40:48 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# git
|
|
|
|
#
|
|
|
|
include(common/px4_git)
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --always --tags
|
|
|
|
OUTPUT_VARIABLE git_tag
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
px4_add_git_submodule(TARGET git_ecl PATH "src/lib/ecl")
|
|
|
|
px4_add_git_submodule(TARGET git_matrix PATH "src/lib/matrix")
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
define_property(GLOBAL PROPERTY PX4_LIBRARIES
|
|
|
|
BRIEF_DOCS "PX4 libs"
|
|
|
|
FULL_DOCS "List of all PX4 module libraries"
|
|
|
|
)
|
2016-08-25 16:47:45 -03:00
|
|
|
|
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
|
|
|
#
|
|
|
|
|
2016-08-03 18:04:35 -03:00
|
|
|
set(CONFIG "posix_sitl_default" CACHE STRING "desired configuration")
|
2017-01-29 16:32:18 -04:00
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
string(REPLACE "_" ";" config_args ${CONFIG})
|
|
|
|
list(GET config_args 0 OS)
|
|
|
|
list(GET config_args 1 BOARD)
|
|
|
|
list(GET config_args 2 LABEL)
|
2017-10-20 10:20:30 -03:00
|
|
|
set(target_name "${OS}_${BOARD}_${LABEL}")
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2015-09-11 00:43:59 -03:00
|
|
|
file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake")
|
|
|
|
set_property(CACHE CONFIG PROPERTY STRINGS ${configs})
|
2017-01-29 16:32:18 -04:00
|
|
|
|
|
|
|
set(THREADS "4" CACHE STRING "number of threads to use for external build processes")
|
2015-09-13 15:31:58 -03:00
|
|
|
set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port")
|
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()
|
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
set(config_module "configs/${CONFIG}")
|
|
|
|
include(${config_module})
|
|
|
|
|
|
|
|
include(common/coverage)
|
|
|
|
include(common/sanitizers)
|
|
|
|
|
|
|
|
# CMake build type
|
|
|
|
# Debug Release RelWithDebInfo MinSizeRel Coverage
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
if (${OS} STREQUAL "nuttx")
|
|
|
|
set(PX4_BUILD_TYPE "MinSizeRel")
|
|
|
|
elseif (${OS} STREQUAL "bebop")
|
|
|
|
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()
|
|
|
|
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage")
|
|
|
|
|
|
|
|
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
|
2017-01-14 10:38:28 -04:00
|
|
|
message(STATUS "PX4 VERSION: ${git_tag}")
|
|
|
|
message(STATUS "CONFIG: ${target_name}")
|
2017-11-21 21:22:48 -04:00
|
|
|
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# project definition
|
|
|
|
#
|
|
|
|
project(px4 CXX C ASM)
|
|
|
|
|
|
|
|
set(package-contact "px4users@googlegroups.com")
|
|
|
|
|
|
|
|
#=============================================================================
|
2016-12-12 18:53:12 -04:00
|
|
|
|
2017-01-14 10:38:28 -04:00
|
|
|
# The URL for the elf file for crash logging
|
2016-12-12 18:53:12 -04:00
|
|
|
if (DEFINED ENV{BUILD_URI})
|
2017-01-14 10:38:28 -04:00
|
|
|
set(BUILD_URI $ENV{BUILD_URI})
|
2016-12-12 18:53:12 -04:00
|
|
|
else()
|
2017-01-14 10:38:28 -04:00
|
|
|
set(BUILD_URI "localhost")
|
2016-12-12 18:53:12 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(-DBUILD_URI=${BUILD_URI})
|
|
|
|
|
2016-07-24 14:07:14 -03:00
|
|
|
# Setup install paths
|
2017-08-29 18:22:05 -03:00
|
|
|
if (${OS} STREQUAL "posix")
|
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()
|
2017-11-21 21:22:48 -04:00
|
|
|
|
|
|
|
# cmake testing only on posix
|
|
|
|
enable_testing()
|
|
|
|
include(CTest)
|
2016-07-24 14:07:14 -03:00
|
|
|
endif()
|
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
#=============================================================================
|
2015-09-08 05:17:54 -03:00
|
|
|
# require px4 module interface
|
2015-09-11 00:43:59 -03:00
|
|
|
set(px4_required_interface
|
2015-09-08 00:58:31 -03:00
|
|
|
px4_os_prebuild_targets
|
|
|
|
px4_os_add_flags
|
|
|
|
)
|
2015-09-11 00:43:59 -03:00
|
|
|
foreach(cmd ${px4_required_interface})
|
2017-06-01 09:47:33 -03:00
|
|
|
if (NOT COMMAND ${cmd})
|
2015-09-11 00:43:59 -03:00
|
|
|
message(FATAL_ERROR "${config_module} must implement ${cmd}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-06-01 09:47:33 -03:00
|
|
|
|
|
|
|
set(px4_required_config config_module_list)
|
2015-09-11 00:43:59 -03:00
|
|
|
foreach(conf ${px4_required_config})
|
2017-06-01 09:47:33 -03:00
|
|
|
if (NOT DEFINED ${conf})
|
2015-09-11 00:53:25 -03:00
|
|
|
message(FATAL_ERROR "cmake/${config_module} must define ${conf}")
|
2015-09-08 00:58:31 -03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-09-08 06:32:55 -03:00
|
|
|
|
2016-08-25 16:47:45 -03:00
|
|
|
# force static lib build
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
|
2017-01-14 22:59:45 -04:00
|
|
|
#=============================================================================
|
|
|
|
# ccache
|
|
|
|
#
|
|
|
|
option(CCACHE "Use ccache if available" OFF)
|
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
2017-06-01 09:47:33 -03:00
|
|
|
if (CCACHE AND CCACHE_PROGRAM)
|
2017-01-14 22:59:45 -04:00
|
|
|
message(STATUS "Enabled ccache: ${CCACHE_PROGRAM}")
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
|
|
|
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)
|
2017-02-04 17:46:03 -04:00
|
|
|
px4_find_python_module(jinja2 REQUIRED)
|
2015-09-07 21:37:45 -03:00
|
|
|
|
2016-07-19 18:12:09 -03:00
|
|
|
#=============================================================================
|
|
|
|
# generate compile command database
|
|
|
|
#
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# check required toolchain variables
|
|
|
|
#
|
2017-01-29 16:32:18 -04:00
|
|
|
|
|
|
|
# PX4 requires c++11
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
# PX4 requires c99
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
2017-06-01 09:47:33 -03:00
|
|
|
set(required_variables CMAKE_C_COMPILER_ID CMAKE_CXX_COMPILER_ID)
|
2015-09-11 00:43:59 -03:00
|
|
|
foreach(var ${required_variables})
|
2015-09-07 21:37:45 -03:00
|
|
|
if (NOT ${var})
|
2015-09-11 00:43:59 -03:00
|
|
|
message(FATAL_ERROR "Toolchain/config must define ${var}")
|
2015-09-07 21:37:45 -03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2017-01-14 10:38:28 -04:00
|
|
|
# print full c compiler version
|
|
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} --version
|
|
|
|
OUTPUT_VARIABLE c_compiler_version
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
STRING(REGEX MATCH "[^\n]*" c_compiler_version_short ${c_compiler_version})
|
|
|
|
message(STATUS "C compiler: ${c_compiler_version_short}")
|
|
|
|
|
|
|
|
# print full c++ compiler version
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
|
|
|
|
OUTPUT_VARIABLE cxx_compiler_version
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
STRING(REGEX MATCH "[^\n]*" cxx_compiler_version_short ${cxx_compiler_version})
|
|
|
|
message(STATUS "C++ compiler: ${cxx_compiler_version_short}")
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# external libraries
|
|
|
|
#
|
2015-09-08 00:58:31 -03:00
|
|
|
px4_os_prebuild_targets(OUT prebuild_targets
|
|
|
|
BOARD ${BOARD}
|
|
|
|
THREADS ${THREADS})
|
2014-11-03 02:41:05 -04:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# build flags
|
|
|
|
#
|
2015-09-08 00:58:31 -03:00
|
|
|
px4_os_add_flags(
|
|
|
|
BOARD ${BOARD}
|
2015-09-07 21:37:45 -03:00
|
|
|
C_FLAGS c_flags
|
|
|
|
CXX_FLAGS cxx_flags
|
2016-09-01 20:12:05 -03:00
|
|
|
OPTIMIZATION_FLAGS optimization_flags
|
2015-09-07 21:37:45 -03:00
|
|
|
EXE_LINKER_FLAGS exe_linker_flags
|
|
|
|
INCLUDE_DIRS include_dirs
|
|
|
|
LINK_DIRS link_dirs
|
|
|
|
DEFINITIONS definitions)
|
2015-09-08 05:20:48 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
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 " ")
|
2015-09-08 00:58:31 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
include_directories(${include_dirs})
|
|
|
|
link_directories(${link_dirs})
|
|
|
|
add_definitions(${definitions})
|
|
|
|
|
|
|
|
#=============================================================================
|
2017-06-05 16:24:10 -03:00
|
|
|
# message, and airframe generation
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
2017-06-01 09:47:33 -03:00
|
|
|
include(common/px4_metadata)
|
|
|
|
|
2016-05-16 04:22:34 -03:00
|
|
|
add_subdirectory(msg)
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2017-06-05 16:24:10 -03:00
|
|
|
px4_generate_airframes_xml(BOARD ${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")
|
|
|
|
|
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()
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# subdirectories
|
|
|
|
#
|
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
|
|
|
|
2015-09-10 00:00:58 -03:00
|
|
|
add_subdirectory(src/firmware/${OS})
|
2015-09-19 14:44:02 -03:00
|
|
|
|
2016-09-02 19:45:15 -03:00
|
|
|
#=============================================================================
|
|
|
|
# generate custom target to print for all executable and module cmake targets
|
|
|
|
#
|
2017-06-01 09:47:33 -03:00
|
|
|
if (all_posix_cmake_targets)
|
2016-09-02 19:45:15 -03:00
|
|
|
list(SORT all_posix_cmake_targets)
|
|
|
|
px4_join(OUT posix_cmake_target_list LIST ${all_posix_cmake_targets} GLUE "\\n")
|
|
|
|
add_custom_target(list_cmake_targets
|
|
|
|
COMMAND sh -c "printf \"${posix_cmake_target_list}\\n\""
|
|
|
|
COMMENT "List of cmake targets that can be matched by PX4_NO_OPTIMIZATION:"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-12-11 07:01:09 -04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# uORB graph generation: add a custom target 'uorb_graph'
|
|
|
|
#
|
|
|
|
set(uorb_graph_config ${BOARD})
|
|
|
|
|
|
|
|
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})
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# packaging
|
|
|
|
#
|
|
|
|
# Important to having packaging at end of cmake file.
|
|
|
|
#
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${CONFIG})
|
2017-06-01 09:47:33 -03:00
|
|
|
set(CPACK_PACKAGE_VERSION ${git_version})
|
2016-07-24 14:07:14 -03:00
|
|
|
set(CPACK_PACKAGE_CONTACT ${package-contact})
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
|
|
|
set(short-description "The px4 autopilot.")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${short-description})
|
2015-09-10 22:54:58 -03:00
|
|
|
set(CPACK_GENERATOR "ZIP")
|
2016-08-29 23:17:19 -03:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CONFIG}-${git_tag}")
|
2017-06-01 09:47:33 -03:00
|
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${git_version}")
|
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")
|
2016-07-24 14:07:14 -03:00
|
|
|
if ("${CMAKE_SYSTEM}" MATCHES "Linux")
|
2016-08-25 16:47:45 -03:00
|
|
|
find_program(DPKG_PROGRAM dpkg)
|
|
|
|
if (EXISTS ${DPKG_PROGRAM})
|
|
|
|
list (APPEND CPACK_GENERATOR "DEB")
|
|
|
|
endif()
|
2016-07-24 14:07:14 -03:00
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
include(CPack)
|
|
|
|
|
|
|
|
# vim: set noet fenc=utf-8 ff=unix ft=cmake :
|