2015-09-07 21:37:45 -03:00
|
|
|
############################################################################
|
|
|
|
#
|
|
|
|
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# Defined functions in this file
|
|
|
|
#
|
|
|
|
# utility functions
|
|
|
|
#
|
|
|
|
# * px4_parse_function_args
|
|
|
|
# * px4_add_git_submodule
|
|
|
|
# * px4_prepend_string
|
|
|
|
# * px4_join
|
|
|
|
# * px4_add_module
|
|
|
|
# * px4_generate_messages
|
|
|
|
# * px4_add_upload
|
|
|
|
# * px4_add_common_flags
|
2016-09-01 20:12:05 -03:00
|
|
|
# * px4_add_optimization_flags_for_target
|
|
|
|
# * px4_add_executable
|
|
|
|
# * px4_add_library
|
2015-09-08 00:58:31 -03:00
|
|
|
#
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_parse_function_args
|
|
|
|
#
|
2017-01-04 23:19:08 -04:00
|
|
|
# This function simplifies usage of the cmake_parse_arguments module.
|
|
|
|
# It is intended to be called by other functions.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_parse_function_args(
|
|
|
|
# NAME <name>
|
|
|
|
# [ OPTIONS <list> ]
|
|
|
|
# [ ONE_VALUE <list> ]
|
|
|
|
# [ MULTI_VALUE <list> ]
|
|
|
|
# REQUIRED <list>
|
|
|
|
# ARGN <ARGN>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# NAME : the name of the calling function
|
|
|
|
# OPTIONS : boolean flags
|
|
|
|
# ONE_VALUE : single value variables
|
|
|
|
# MULTI_VALUE : multi value variables
|
|
|
|
# REQUIRED : required arguments
|
|
|
|
# ARGN : the function input arguments, typically ${ARGN}
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# The function arguments corresponding to the following are set:
|
|
|
|
# ${OPTIONS}, ${ONE_VALUE}, ${MULTI_VALUE}
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# function test()
|
|
|
|
# px4_parse_function_args(
|
|
|
|
# NAME TEST
|
|
|
|
# ONE_VALUE NAME
|
|
|
|
# MULTI_VALUE LIST
|
|
|
|
# REQUIRED NAME LIST
|
|
|
|
# ARGN ${ARGN})
|
|
|
|
# message(STATUS "name: ${NAME}")
|
|
|
|
# message(STATUS "list: ${LIST}")
|
|
|
|
# endfunction()
|
|
|
|
#
|
|
|
|
# test(NAME "hello" LIST a b c)
|
2016-01-19 03:16:31 -04:00
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# OUTPUT:
|
|
|
|
# name: hello
|
|
|
|
# list: a b c
|
|
|
|
#
|
|
|
|
function(px4_parse_function_args)
|
|
|
|
cmake_parse_arguments(IN "" "NAME" "OPTIONS;ONE_VALUE;MULTI_VALUE;REQUIRED;ARGN" "${ARGN}")
|
|
|
|
cmake_parse_arguments(OUT "${IN_OPTIONS}" "${IN_ONE_VALUE}" "${IN_MULTI_VALUE}" "${IN_ARGN}")
|
2016-12-12 19:11:51 -04:00
|
|
|
if (OUT_UNPARSED_ARGUMENTS)
|
|
|
|
message(FATAL_ERROR "${IN_NAME}: unparsed ${OUT_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
foreach(arg ${IN_REQUIRED})
|
|
|
|
if (NOT OUT_${arg})
|
2016-12-12 19:11:51 -04:00
|
|
|
if (NOT "${OUT_${arg}}" STREQUAL "0")
|
|
|
|
message(FATAL_ERROR "${IN_NAME} requires argument ${arg}\nARGN: ${IN_ARGN}")
|
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
foreach(arg ${IN_OPTIONS} ${IN_ONE_VALUE} ${IN_MULTI_VALUE})
|
|
|
|
set(${arg} ${OUT_${arg}} PARENT_SCOPE)
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_add_git_submodule
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# This function add a git submodule target.
|
|
|
|
#
|
|
|
|
# Usage:
|
2015-09-08 00:58:31 -03:00
|
|
|
# px4_add_git_submodule(TARGET <target> PATH <path>)
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# PATH : git submodule path
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# TARGET : git target
|
|
|
|
#
|
|
|
|
# Example:
|
2015-09-08 00:58:31 -03:00
|
|
|
# px4_add_git_submodule(TARGET git_nuttx PATH "NuttX")
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
function(px4_add_git_submodule)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_git_submodule
|
|
|
|
ONE_VALUE TARGET PATH
|
|
|
|
REQUIRED TARGET PATH
|
|
|
|
ARGN ${ARGN})
|
|
|
|
string(REPLACE "/" "_" NAME ${PATH})
|
2016-08-18 16:37:23 -03:00
|
|
|
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/git_init_${NAME}.stamp
|
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
|
|
|
COMMAND touch ${PX4_BINARY_DIR}/git_init_${NAME}.stamp
|
|
|
|
DEPENDS ${PX4_SOURCE_DIR}/.gitmodules
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
add_custom_target(${TARGET}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
2017-01-04 23:19:08 -04:00
|
|
|
# todo:Not have 2 list of submodules one (see the end of Tools/check_submodules.sh and Firmware/CMakeLists.txt)
|
2016-12-12 19:11:51 -04:00
|
|
|
# using the list of submodules from the CMake file to drive the test
|
|
|
|
# COMMAND Tools/check_submodules.sh ${PATH}
|
2016-08-18 16:37:23 -03:00
|
|
|
DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp
|
2015-10-14 12:05:51 -03:00
|
|
|
)
|
2015-09-07 21:37:45 -03:00
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_prepend_string
|
|
|
|
#
|
|
|
|
# This function prepends a string to a list
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_prepend_string(OUT <output-list> STR <string> LIST <list>)
|
|
|
|
#
|
|
|
|
# Input:
|
2017-01-04 23:19:08 -04:00
|
|
|
# STR : string to prepend
|
2015-09-07 21:37:45 -03:00
|
|
|
# LIST : list to prepend to
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# ${OUT} : prepended list
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_prepend_string(OUT test_str STR "path/to/" LIST src/file1.cpp src/file2.cpp)
|
|
|
|
# test_str would then be:
|
|
|
|
# path/to/src/file1.cpp
|
|
|
|
# path/to/src/file2.cpp
|
|
|
|
#
|
|
|
|
function(px4_prepend_string)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_prepend_string
|
|
|
|
ONE_VALUE OUT STR
|
|
|
|
MULTI_VALUE LIST
|
|
|
|
REQUIRED OUT STR LIST
|
|
|
|
ARGN ${ARGN})
|
|
|
|
set(${OUT})
|
|
|
|
foreach(file ${LIST})
|
|
|
|
list(APPEND ${OUT} ${STR}${file})
|
|
|
|
endforeach()
|
|
|
|
set(${OUT} ${${OUT}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# 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()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_add_module
|
|
|
|
#
|
|
|
|
# This function builds a static library from a module description.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_add_module(MODULE <string>
|
|
|
|
# [ MAIN <string> ]
|
2016-04-14 14:36:36 -03:00
|
|
|
# [ STACK <string> ] !!!!!DEPRECATED, USE STACK_MAIN INSTEAD!!!!!!!!!
|
|
|
|
# [ STACK_MAIN <string> ]
|
|
|
|
# [ STACK_MAX <string> ]
|
2015-09-07 21:37:45 -03:00
|
|
|
# [ COMPILE_FLAGS <list> ]
|
|
|
|
# [ INCLUDES <list> ]
|
|
|
|
# [ DEPENDS <string> ]
|
2016-09-07 09:05:22 -03:00
|
|
|
# [ EXTERNAL ]
|
2015-09-07 21:37:45 -03:00
|
|
|
# )
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# MODULE : unique name of module
|
|
|
|
# MAIN : entry point, if not given, assumed to be library
|
2016-04-14 14:36:36 -03:00
|
|
|
# STACK : deprecated use stack main instead
|
|
|
|
# STACK_MAIN : size of stack for main function
|
|
|
|
# STACK_MAX : maximum stack size of any frame
|
2016-12-12 19:11:51 -04:00
|
|
|
# COMPILE_FLAGS : compile flags
|
2015-09-07 21:37:45 -03:00
|
|
|
# LINK_FLAGS : link flags
|
|
|
|
# SRCS : source files
|
|
|
|
# INCLUDES : include directories
|
|
|
|
# DEPENDS : targets which this module depends on
|
2016-09-07 09:05:22 -03:00
|
|
|
# EXTERNAL : flag to indicate that this module is out-of-tree
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# Static library with name matching MODULE.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_add_module(MODULE test
|
|
|
|
# SRCS
|
|
|
|
# file.cpp
|
2016-04-14 14:36:36 -03:00
|
|
|
# STACK_MAIN 1024
|
2015-09-07 21:37:45 -03:00
|
|
|
# DEPENDS
|
|
|
|
# git_nuttx
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
function(px4_add_module)
|
2015-09-12 01:49:10 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_module
|
2016-04-14 14:36:36 -03:00
|
|
|
ONE_VALUE MODULE MAIN STACK STACK_MAIN STACK_MAX PRIORITY
|
2015-09-07 21:37:45 -03:00
|
|
|
MULTI_VALUE COMPILE_FLAGS LINK_FLAGS SRCS INCLUDES DEPENDS
|
2016-09-07 09:05:22 -03:00
|
|
|
OPTIONS EXTERNAL
|
2015-09-07 21:37:45 -03:00
|
|
|
REQUIRED MODULE
|
|
|
|
ARGN ${ARGN})
|
2015-09-12 01:49:10 -03:00
|
|
|
|
2016-09-07 09:05:22 -03:00
|
|
|
if(EXTERNAL)
|
|
|
|
px4_mangle_name("${EXTERNAL_MODULES_LOCATION}/src/${MODULE}" MODULE)
|
|
|
|
endif()
|
|
|
|
|
2016-09-01 20:12:05 -03:00
|
|
|
px4_add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${SRCS})
|
2015-09-12 01:49:10 -03:00
|
|
|
|
2016-04-14 14:36:36 -03:00
|
|
|
# set defaults if not set
|
|
|
|
set(MAIN_DEFAULT MAIN-NOTFOUND)
|
|
|
|
set(STACK_MAIN_DEFAULT 1024)
|
|
|
|
set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT)
|
|
|
|
|
|
|
|
# default stack max to stack main
|
|
|
|
if(NOT STACK_MAIN AND STACK)
|
|
|
|
set(STACK_MAIN ${STACK})
|
|
|
|
message(AUTHOR_WARNING "STACK deprecated, USE STACK_MAIN instead!!!!!!!!!!!!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(property MAIN STACK_MAIN PRIORITY)
|
|
|
|
if(NOT ${property})
|
|
|
|
set(${property} ${${property}_DEFAULT})
|
|
|
|
endif()
|
|
|
|
set_target_properties(${MODULE} PROPERTIES ${property}
|
|
|
|
${${property}})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# default stack max to stack main
|
|
|
|
if(NOT STACK_MAX)
|
|
|
|
set(STACK_MAX ${STACK_MAIN})
|
|
|
|
endif()
|
|
|
|
set_target_properties(${MODULE} PROPERTIES STACK_MAX
|
|
|
|
${STACK_MAX})
|
|
|
|
|
2016-01-10 03:00:59 -04:00
|
|
|
if(${OS} STREQUAL "qurt" )
|
|
|
|
set_property(TARGET ${MODULE} PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
2016-04-14 14:36:36 -03:00
|
|
|
elseif(${OS} STREQUAL "nuttx" )
|
|
|
|
list(APPEND COMPILE_FLAGS -Wframe-larger-than=${STACK_MAX})
|
2016-01-10 03:00:59 -04:00
|
|
|
endif()
|
|
|
|
|
2015-09-12 02:35:09 -03:00
|
|
|
if(MAIN)
|
|
|
|
set_target_properties(${MODULE} PROPERTIES
|
|
|
|
COMPILE_DEFINITIONS PX4_MAIN=${MAIN}_app_main)
|
2016-06-02 07:11:04 -03:00
|
|
|
add_definitions(-DMODULE_NAME="${MAIN}")
|
|
|
|
else()
|
2016-06-02 12:43:25 -03:00
|
|
|
add_definitions(-DMODULE_NAME="${MODULE}")
|
2015-09-12 02:35:09 -03:00
|
|
|
endif()
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
if(INCLUDES)
|
|
|
|
target_include_directories(${MODULE} ${INCLUDES})
|
|
|
|
endif()
|
2015-09-12 01:49:10 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
if(DEPENDS)
|
|
|
|
add_dependencies(${MODULE} ${DEPENDS})
|
|
|
|
endif()
|
2015-09-12 01:49:10 -03:00
|
|
|
|
|
|
|
# join list variables to get ready to send to compiler
|
2015-09-07 21:37:45 -03:00
|
|
|
foreach(prop LINK_FLAGS COMPILE_FLAGS)
|
|
|
|
if(${prop})
|
|
|
|
px4_join(OUT ${prop} LIST ${${prop}} GLUE " ")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-09-12 01:49:10 -03:00
|
|
|
|
|
|
|
# store module properties in target
|
|
|
|
# COMPILE_FLAGS and LINK_FLAGS are passed to compiler/linker by cmake
|
2016-04-14 14:36:36 -03:00
|
|
|
# STACK_MAIN, MAIN, PRIORITY are PX4 specific
|
2016-09-01 20:12:05 -03:00
|
|
|
if(COMPILE_FLAGS AND ${_no_optimization_for_target})
|
|
|
|
px4_strip_optimization(COMPILE_FLAGS ${COMPILE_FLAGS})
|
|
|
|
endif()
|
2016-04-14 14:36:36 -03:00
|
|
|
foreach (prop COMPILE_FLAGS LINK_FLAGS STACK_MAIN MAIN PRIORITY)
|
2015-09-07 21:37:45 -03:00
|
|
|
if (${prop})
|
2015-09-12 01:49:10 -03:00
|
|
|
set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}})
|
2015-09-07 21:37:45 -03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-09-12 01:49:10 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_generate_messages
|
|
|
|
#
|
|
|
|
# This function generates source code from ROS msg definitions.
|
2015-09-08 00:58:31 -03:00
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# Usage:
|
|
|
|
# px4_generate_messages(TARGET <target> MSGS <msg-files>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# MSG_FILES : the ROS msgs to generate files from
|
|
|
|
# OS : the operating system selected
|
|
|
|
# DEPENDS : dependencies
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# TARGET : the message generation target
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_generate_messages(TARGET <target>
|
|
|
|
# MSG_FILES <files> OS <operating-system>
|
|
|
|
# [ DEPENDS <dependencies> ]
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
function(px4_generate_messages)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_generate_messages
|
|
|
|
OPTIONS VERBOSE
|
|
|
|
ONE_VALUE OS TARGET
|
2016-04-25 18:36:13 -03:00
|
|
|
MULTI_VALUE MSG_FILES DEPENDS INCLUDES
|
2015-09-07 21:37:45 -03:00
|
|
|
REQUIRED MSG_FILES OS TARGET
|
|
|
|
ARGN ${ARGN})
|
2016-12-12 19:11:51 -04:00
|
|
|
if("${config_nuttx_config}" STREQUAL "bootloader")
|
|
|
|
else()
|
2015-09-07 21:37:45 -03:00
|
|
|
set(QUIET)
|
|
|
|
if(NOT VERBOSE)
|
|
|
|
set(QUIET "-q")
|
|
|
|
endif()
|
2016-04-25 18:36:13 -03:00
|
|
|
|
|
|
|
# headers
|
2016-08-18 16:37:23 -03:00
|
|
|
set(msg_out_path ${PX4_BINARY_DIR}/src/modules/uORB/topics)
|
2015-09-07 21:37:45 -03:00
|
|
|
set(msg_list)
|
|
|
|
foreach(msg_file ${MSG_FILES})
|
|
|
|
get_filename_component(msg ${msg_file} NAME_WE)
|
|
|
|
list(APPEND msg_list ${msg})
|
|
|
|
endforeach()
|
|
|
|
set(msg_files_out)
|
|
|
|
foreach(msg ${msg_list})
|
|
|
|
list(APPEND msg_files_out ${msg_out_path}/${msg}.h)
|
|
|
|
endforeach()
|
|
|
|
add_custom_command(OUTPUT ${msg_files_out}
|
2016-01-19 03:16:31 -04:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
2016-05-06 11:42:35 -03:00
|
|
|
Tools/px_generate_uorb_topic_files.py
|
|
|
|
--headers
|
2015-09-07 21:37:45 -03:00
|
|
|
${QUIET}
|
2016-08-25 08:28:44 -03:00
|
|
|
-f ${MSG_FILES}
|
2016-01-19 03:16:31 -04:00
|
|
|
-o ${msg_out_path}
|
2015-09-07 21:37:45 -03:00
|
|
|
-e msg/templates/uorb
|
2016-08-18 16:37:23 -03:00
|
|
|
-t ${PX4_BINARY_DIR}/topics_temporary_header
|
2015-09-07 21:37:45 -03:00
|
|
|
DEPENDS ${DEPENDS} ${MSG_FILES}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
2015-09-07 21:37:45 -03:00
|
|
|
COMMENT "Generating uORB topic headers"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2016-04-25 18:36:13 -03:00
|
|
|
# !sources
|
2016-08-18 16:37:23 -03:00
|
|
|
set(msg_source_out_path ${PX4_BINARY_DIR}/topics_sources)
|
2016-04-25 18:36:13 -03:00
|
|
|
set(msg_source_files_out ${msg_source_out_path}/uORBTopics.cpp)
|
|
|
|
foreach(msg ${msg_list})
|
|
|
|
list(APPEND msg_source_files_out ${msg_source_out_path}/${msg}.cpp)
|
|
|
|
endforeach()
|
|
|
|
add_custom_command(OUTPUT ${msg_source_files_out}
|
2016-06-02 07:11:04 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
2016-05-06 11:42:35 -03:00
|
|
|
Tools/px_generate_uorb_topic_files.py
|
|
|
|
--sources
|
2016-04-25 18:36:13 -03:00
|
|
|
${QUIET}
|
2016-08-25 08:28:44 -03:00
|
|
|
-f ${MSG_FILES}
|
2016-04-25 18:36:13 -03:00
|
|
|
-o ${msg_source_out_path}
|
2016-05-06 11:42:35 -03:00
|
|
|
-e msg/templates/uorb
|
2016-08-18 16:37:23 -03:00
|
|
|
-t ${PX4_BINARY_DIR}/topics_temporary_sources
|
2016-04-25 18:36:13 -03:00
|
|
|
DEPENDS ${DEPENDS} ${MSG_FILES}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
2016-04-25 18:36:13 -03:00
|
|
|
COMMENT "Generating uORB topic sources"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
set_source_files_properties(${msg_source_files_out} PROPERTIES GENERATED TRUE)
|
|
|
|
|
2016-05-16 04:22:34 -03:00
|
|
|
# We remove uORBTopics.cpp to make sure the generator is re-run, which is
|
|
|
|
# necessary when a .msg file is removed and because uORBTopics.cpp depends
|
|
|
|
# on all topics.
|
|
|
|
execute_process(COMMAND rm uORBTopics.cpp
|
|
|
|
WORKING_DIRECTORY ${msg_source_out_path}
|
|
|
|
ERROR_QUIET)
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
# multi messages for target OS
|
|
|
|
set(msg_multi_out_path
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_BINARY_DIR}/src/platforms/${OS}/px4_messages)
|
2015-09-07 21:37:45 -03:00
|
|
|
set(msg_multi_files_out)
|
|
|
|
foreach(msg ${msg_list})
|
|
|
|
list(APPEND msg_multi_files_out ${msg_multi_out_path}/px4_${msg}.h)
|
|
|
|
endforeach()
|
|
|
|
add_custom_command(OUTPUT ${msg_multi_files_out}
|
2016-01-19 03:16:31 -04:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
2016-05-06 11:42:35 -03:00
|
|
|
Tools/px_generate_uorb_topic_files.py
|
|
|
|
--headers
|
2015-09-07 21:37:45 -03:00
|
|
|
${QUIET}
|
2016-08-25 08:28:44 -03:00
|
|
|
-f ${MSG_FILES}
|
2016-01-19 03:16:31 -04:00
|
|
|
-o ${msg_multi_out_path}
|
2015-09-07 21:37:45 -03:00
|
|
|
-e msg/templates/px4/uorb
|
2016-08-18 16:37:23 -03:00
|
|
|
-t ${PX4_BINARY_DIR}/multi_topics_temporary/${OS}
|
2015-09-07 21:37:45 -03:00
|
|
|
-p "px4_"
|
|
|
|
DEPENDS ${DEPENDS} ${MSG_FILES}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
2015-09-07 21:37:45 -03:00
|
|
|
COMMENT "Generating uORB topic multi headers for ${OS}"
|
|
|
|
VERBATIM
|
|
|
|
)
|
2016-04-25 18:36:13 -03:00
|
|
|
|
2016-09-01 20:12:05 -03:00
|
|
|
px4_add_library(${TARGET}
|
2016-04-25 18:36:13 -03:00
|
|
|
${msg_source_files_out}
|
|
|
|
${msg_multi_files_out}
|
|
|
|
${msg_files_out}
|
|
|
|
)
|
2016-12-12 19:11:51 -04:00
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_add_upload
|
|
|
|
#
|
|
|
|
# This function generates source code from ROS msg definitions.
|
2015-09-08 00:58:31 -03:00
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# Usage:
|
|
|
|
# px4_add_upload(OUT <target> BUNDLE <file.px4>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# BUNDLE : the firmware.px4 file
|
|
|
|
# OS : the operating system
|
|
|
|
# BOARD : the board
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# OUT : the firmware target
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_add_upload(OUT upload
|
|
|
|
# BUNDLE main.px4
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
function(px4_add_upload)
|
|
|
|
px4_parse_function_args(
|
2015-09-08 11:15:22 -03:00
|
|
|
NAME px4_add_upload
|
2015-09-07 21:37:45 -03:00
|
|
|
ONE_VALUE OS BOARD OUT BUNDLE
|
|
|
|
REQUIRED OS BOARD OUT BUNDLE
|
|
|
|
ARGN ${ARGN})
|
|
|
|
set(serial_ports)
|
|
|
|
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
list(APPEND serial_ports
|
|
|
|
/dev/serial/by-id/usb-3D_Robotics*
|
2016-07-12 09:47:39 -03:00
|
|
|
/dev/serial/by-id/usb-The_Autopilot*
|
2016-09-21 18:20:08 -03:00
|
|
|
/dev/serial/by-id/usb-Bitcraze*
|
2015-09-07 21:37:45 -03:00
|
|
|
/dev/serial/by-id/pci-3D_Robotics*
|
2016-09-30 17:23:34 -03:00
|
|
|
/dev/serial/by-id/pci-Bitcraze*
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
|
|
|
|
list(APPEND serial_ports
|
|
|
|
/dev/tty.usbmodemPX*,/dev/tty.usbmodem*
|
|
|
|
)
|
|
|
|
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
|
|
|
foreach(port RANGE 32 0)
|
2015-10-14 14:25:06 -03:00
|
|
|
list(APPEND serial_ports
|
|
|
|
"COM${port}")
|
2015-09-07 21:37:45 -03:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
px4_join(OUT serial_ports LIST "${serial_ports}" GLUE ",")
|
|
|
|
add_custom_target(${OUT}
|
2015-10-12 11:47:09 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${BUNDLE}
|
2015-09-07 21:37:45 -03:00
|
|
|
DEPENDS ${BUNDLE}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2015-09-07 21:37:45 -03:00
|
|
|
COMMENT "uploading ${BUNDLE}"
|
|
|
|
VERBATIM
|
2015-10-25 07:20:28 -03:00
|
|
|
USES_TERMINAL
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-04-01 06:36:27 -03:00
|
|
|
|
|
|
|
function(px4_add_adb_push)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_upload
|
|
|
|
ONE_VALUE OS BOARD OUT DEST
|
|
|
|
MULTI_VALUE FILES DEPENDS
|
|
|
|
REQUIRED OS BOARD OUT FILES DEPENDS DEST
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
add_custom_target(${OUT}
|
2016-08-18 16:37:23 -03:00
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/adb_upload.sh ${FILES} ${DEST}
|
2016-04-01 06:36:27 -03:00
|
|
|
DEPENDS ${DEPENDS}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2016-04-01 06:36:27 -03:00
|
|
|
COMMENT "uploading ${BUNDLE}"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-05-31 08:04:22 -03:00
|
|
|
function(px4_add_adb_push_to_bebop)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_upload_to_bebop
|
|
|
|
ONE_VALUE OS BOARD OUT DEST
|
|
|
|
MULTI_VALUE FILES DEPENDS
|
|
|
|
REQUIRED OS BOARD OUT FILES DEPENDS DEST
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
add_custom_target(${OUT}
|
2016-08-18 16:37:23 -03:00
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/adb_upload_to_bebop.sh ${FILES} ${DEST}
|
2016-05-31 08:04:22 -03:00
|
|
|
DEPENDS ${DEPENDS}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2016-05-31 08:04:22 -03:00
|
|
|
COMMENT "uploading ${BUNDLE}"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-04-29 01:09:23 -03:00
|
|
|
function(px4_add_scp_push)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_upload
|
|
|
|
ONE_VALUE OS BOARD OUT DEST
|
|
|
|
MULTI_VALUE FILES DEPENDS
|
|
|
|
REQUIRED OS BOARD OUT FILES DEPENDS DEST
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
add_custom_target(${OUT}
|
2016-08-18 16:37:23 -03:00
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/scp_upload.sh ${FILES} ${DEST}
|
2016-04-29 01:09:23 -03:00
|
|
|
DEPENDS ${DEPENDS}
|
2016-08-18 16:37:23 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2016-04-29 01:09:23 -03:00
|
|
|
COMMENT "uploading ${BUNDLE}"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-10-05 16:31:40 -03:00
|
|
|
function(px4_add_upload_aero)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_upload_aero
|
|
|
|
ONE_VALUE OS BOARD OUT BUNDLE
|
|
|
|
REQUIRED OS BOARD OUT BUNDLE
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
add_custom_target(${OUT}
|
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/aero_upload.sh ${BUNDLE}
|
|
|
|
DEPENDS ${BUNDLE}
|
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
COMMENT "uploading ${BUNDLE}"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-04-01 06:36:27 -03:00
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# px4_add_common_flags
|
|
|
|
#
|
2016-09-01 05:59:26 -03:00
|
|
|
# Set the default build flags.
|
2015-09-07 21:37:45 -03:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_add_common_flags(
|
2015-09-08 00:58:31 -03:00
|
|
|
# BOARD <in-string>
|
2015-09-07 21:37:45 -03:00
|
|
|
# C_FLAGS <inout-variable>
|
|
|
|
# CXX_FLAGS <inout-variable>
|
2016-09-01 20:12:05 -03:00
|
|
|
# OPTIMIZATION_FLAGS <inout-variable>
|
2015-09-07 21:37:45 -03:00
|
|
|
# EXE_LINKER_FLAGS <inout-variable>
|
|
|
|
# INCLUDE_DIRS <inout-variable>
|
|
|
|
# LINK_DIRS <inout-variable>
|
|
|
|
# DEFINITIONS <inout-variable>)
|
|
|
|
#
|
2015-09-08 00:58:31 -03:00
|
|
|
# Input:
|
|
|
|
# BOARD : board
|
|
|
|
#
|
2015-09-07 21:37:45 -03:00
|
|
|
# Input/Output: (appends to existing variable)
|
|
|
|
# C_FLAGS : c compile flags variable
|
|
|
|
# CXX_FLAGS : c++ compile flags variable
|
2016-09-01 20:12:05 -03:00
|
|
|
# OPTIMIZATION_FLAGS : optimization compile flags variable
|
2016-09-01 05:59:26 -03:00
|
|
|
# EXE_LINKER_FLAGS : executable linker flags variable
|
|
|
|
# INCLUDE_DIRS : include directories
|
2015-09-07 21:37:45 -03:00
|
|
|
# LINK_DIRS : link directories
|
|
|
|
# DEFINITIONS : definitions
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_add_common_flags(
|
2015-09-08 00:58:31 -03:00
|
|
|
# BOARD px4fmu-v2
|
2015-09-07 21:37:45 -03:00
|
|
|
# C_FLAGS CMAKE_C_FLAGS
|
|
|
|
# CXX_FLAGS CMAKE_CXX_FLAGS
|
2016-09-01 20:12:05 -03:00
|
|
|
# OPTIMIZATION_FLAGS optimization_flags
|
2015-09-07 21:37:45 -03:00
|
|
|
# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS
|
|
|
|
# INCLUDES <list>)
|
|
|
|
#
|
|
|
|
function(px4_add_common_flags)
|
|
|
|
|
|
|
|
set(inout_vars
|
2016-09-01 20:12:05 -03:00
|
|
|
C_FLAGS CXX_FLAGS OPTIMIZATION_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS)
|
2015-09-07 21:37:45 -03:00
|
|
|
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_common_flags
|
2015-09-08 00:58:31 -03:00
|
|
|
ONE_VALUE ${inout_vars} BOARD
|
|
|
|
REQUIRED ${inout_vars} BOARD
|
2015-09-07 21:37:45 -03:00
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
set(warnings
|
|
|
|
-Wall
|
2015-10-06 17:31:18 -03:00
|
|
|
-Werror
|
2015-09-07 21:37:45 -03:00
|
|
|
-Wextra
|
2016-02-29 11:32:41 -04:00
|
|
|
-Wno-sign-compare
|
2016-05-04 19:34:35 -03:00
|
|
|
-Wshadow
|
2015-09-07 21:37:45 -03:00
|
|
|
-Wfloat-equal
|
|
|
|
-Wpointer-arith
|
|
|
|
-Wmissing-declarations
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Werror=format-security
|
|
|
|
-Werror=array-bounds
|
|
|
|
-Wfatal-errors
|
|
|
|
-Werror=unused-variable
|
|
|
|
-Werror=reorder
|
|
|
|
-Werror=uninitialized
|
2015-09-11 16:47:50 -03:00
|
|
|
-Werror=init-self
|
2015-09-07 21:37:45 -03:00
|
|
|
#-Wcast-qual - generates spurious noreturn attribute warnings,
|
|
|
|
# try again later
|
|
|
|
#-Wconversion - would be nice, but too many "risky-but-safe"
|
|
|
|
# conversions in the code
|
|
|
|
#-Wcast-align - would help catch bad casts in some cases,
|
|
|
|
# but generates too many false positives
|
|
|
|
)
|
|
|
|
|
2015-10-25 10:35:20 -03:00
|
|
|
if (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")
|
2015-09-21 12:58:38 -03:00
|
|
|
# QuRT 6.4.X compiler identifies as Clang but does not support this option
|
|
|
|
if (NOT ${OS} STREQUAL "qurt")
|
|
|
|
list(APPEND warnings
|
2016-04-26 14:04:58 -03:00
|
|
|
-Qunused-arguments
|
2015-09-21 12:58:38 -03:00
|
|
|
-Wno-unused-const-variable
|
2015-10-22 14:07:22 -03:00
|
|
|
-Wno-varargs
|
2015-09-21 12:58:38 -03:00
|
|
|
)
|
|
|
|
endif()
|
2015-09-12 16:47:23 -03:00
|
|
|
else()
|
2015-09-07 21:37:45 -03:00
|
|
|
list(APPEND warnings
|
|
|
|
-Werror=unused-but-set-variable
|
|
|
|
-Wformat=1
|
|
|
|
#-Wlogical-op # very verbose due to eigen
|
|
|
|
-Wdouble-promotion
|
|
|
|
-Werror=double-promotion
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-01-02 03:46:11 -04:00
|
|
|
# optimization flags and santiziers (ASAN, TSAN, UBSAN)
|
|
|
|
if ($ENV{PX4_ASAN} MATCHES "1")
|
2016-06-21 12:52:23 -03:00
|
|
|
message(STATUS "address sanitizer enabled")
|
2017-01-02 03:46:11 -04:00
|
|
|
|
|
|
|
# environment variables
|
|
|
|
# ASAN_OPTIONS=detect_stack_use_after_return=1
|
|
|
|
# ASAN_OPTIONS=check_initialization_order=1
|
|
|
|
|
|
|
|
set(max_optimization -O1)
|
2016-02-06 20:32:03 -04:00
|
|
|
|
2016-09-01 20:12:05 -03:00
|
|
|
# Do not use optimization_flags (without _) as that is already used.
|
|
|
|
set(_optimization_flags
|
2016-02-06 20:32:03 -04:00
|
|
|
-fno-strict-aliasing
|
|
|
|
-fno-omit-frame-pointer
|
|
|
|
-funsafe-math-optimizations
|
|
|
|
-ffunction-sections
|
|
|
|
-fdata-sections
|
2016-05-21 13:43:02 -03:00
|
|
|
-g3 -fsanitize=address
|
2017-01-02 03:46:11 -04:00
|
|
|
#-fsanitize-address-use-after-scope
|
|
|
|
)
|
|
|
|
|
|
|
|
elseif ($ENV{PX4_TSAN} MATCHES "1")
|
|
|
|
message(STATUS "thread sanitizer enabled")
|
|
|
|
|
|
|
|
# needs some optimization for usable performance
|
|
|
|
set(max_optimization -O1)
|
|
|
|
|
|
|
|
# Do not use optimization_flags (without _) as that is already used.
|
|
|
|
set(_optimization_flags
|
|
|
|
-fno-strict-aliasing
|
|
|
|
-fno-omit-frame-pointer
|
|
|
|
-funsafe-math-optimizations
|
|
|
|
-ffunction-sections
|
|
|
|
-fdata-sections
|
|
|
|
-g3 -fsanitize=thread
|
2016-02-06 20:32:03 -04:00
|
|
|
)
|
2017-01-02 03:46:11 -04:00
|
|
|
|
|
|
|
elseif ($ENV{PX4_UBSAN} MATCHES "1")
|
|
|
|
message(STATUS "undefined behaviour sanitizer enabled")
|
|
|
|
|
|
|
|
set(max_optimization -O2)
|
|
|
|
|
|
|
|
# Do not use optimization_flags (without _) as that is already used.
|
|
|
|
set(_optimization_flags
|
|
|
|
-fno-strict-aliasing
|
|
|
|
-fno-omit-frame-pointer
|
|
|
|
-funsafe-math-optimizations
|
|
|
|
-ffunction-sections
|
|
|
|
-fdata-sections
|
|
|
|
-g3
|
|
|
|
#-fsanitize=alignment
|
|
|
|
-fsanitize=bool
|
|
|
|
-fsanitize=bounds
|
|
|
|
-fsanitize=enum
|
|
|
|
#-fsanitize=float-cast-overflow
|
|
|
|
-fsanitize=float-divide-by-zero
|
|
|
|
#-fsanitize=function
|
|
|
|
-fsanitize=integer-divide-by-zero
|
|
|
|
-fsanitize=nonnull-attribute
|
|
|
|
-fsanitize=null
|
|
|
|
-fsanitize=object-size
|
|
|
|
-fsanitize=return
|
|
|
|
-fsanitize=returns-nonnull-attribute
|
|
|
|
-fsanitize=shift
|
|
|
|
-fsanitize=signed-integer-overflow
|
|
|
|
-fsanitize=unreachable
|
|
|
|
#-fsanitize=unsigned-integer-overflow
|
|
|
|
-fsanitize=vla-bound
|
|
|
|
-fsanitize=vptr
|
|
|
|
)
|
|
|
|
|
2016-02-06 20:32:03 -04:00
|
|
|
else()
|
2016-09-27 11:56:28 -03:00
|
|
|
if ("${OS}" STREQUAL "nuttx")
|
|
|
|
set(max_optimization -Os)
|
2016-10-18 17:40:50 -03:00
|
|
|
elseif (${BOARD} STREQUAL "bebop")
|
|
|
|
set(max_optimization -Os)
|
2016-09-27 11:56:28 -03:00
|
|
|
else()
|
|
|
|
set(max_optimization -O2)
|
|
|
|
endif()
|
2016-02-06 20:32:03 -04:00
|
|
|
|
2016-01-22 01:09:12 -04:00
|
|
|
if ("${OS}" STREQUAL "qurt")
|
|
|
|
set(PIC_FLAG -fPIC)
|
|
|
|
endif()
|
2016-09-01 20:12:05 -03:00
|
|
|
set(_optimization_flags
|
2016-02-06 20:32:03 -04:00
|
|
|
-fno-strict-aliasing
|
|
|
|
-fomit-frame-pointer
|
|
|
|
-funsafe-math-optimizations
|
|
|
|
-ffunction-sections
|
|
|
|
-fdata-sections
|
2016-01-22 01:09:12 -04:00
|
|
|
${PIC_FLAG}
|
2016-02-06 20:32:03 -04:00
|
|
|
)
|
|
|
|
endif()
|
2017-01-01 22:53:49 -04:00
|
|
|
|
|
|
|
# code coverage
|
|
|
|
if ($ENV{PX4_CODE_COVERAGE} MATCHES "1")
|
2017-01-09 17:08:40 -04:00
|
|
|
#set(max_optimization -O0)
|
2017-01-01 22:53:49 -04:00
|
|
|
endif()
|
2015-10-13 01:47:58 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
set(c_warnings
|
2015-10-14 11:53:55 -03:00
|
|
|
-Wbad-function-cast
|
2015-09-07 21:37:45 -03:00
|
|
|
-Wstrict-prototypes
|
|
|
|
-Wmissing-prototypes
|
|
|
|
-Wnested-externs
|
|
|
|
)
|
|
|
|
|
|
|
|
set(c_compile_flags
|
2015-09-19 13:13:17 -03:00
|
|
|
-g
|
2015-09-07 21:37:45 -03:00
|
|
|
-std=gnu99
|
|
|
|
-fno-common
|
|
|
|
)
|
|
|
|
|
|
|
|
set(cxx_warnings
|
|
|
|
-Wno-missing-field-initializers
|
2017-01-02 02:50:21 -04:00
|
|
|
#-Weffc++
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
2015-10-13 01:47:58 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
set(cxx_compile_flags
|
2015-09-19 13:13:17 -03:00
|
|
|
-g
|
2015-09-07 21:37:45 -03:00
|
|
|
-fno-exceptions
|
|
|
|
-fno-rtti
|
|
|
|
-std=gnu++0x
|
|
|
|
-fno-threadsafe-statics
|
|
|
|
-DCONFIG_WCHAR_BUILTIN
|
|
|
|
-D__CUSTOM_FILE_IO__
|
|
|
|
)
|
|
|
|
|
2017-01-02 01:56:48 -04:00
|
|
|
# clang
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
# force color for clang (needed for clang + ccache)
|
|
|
|
list(APPEND _optimization_flags
|
|
|
|
-fcolor-diagnostics
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
list(APPEND _optimization_flags
|
|
|
|
-fno-strength-reduce
|
|
|
|
-fno-builtin-printf
|
|
|
|
)
|
|
|
|
|
2016-05-11 07:59:41 -03:00
|
|
|
# -fcheck-new is a no-op for Clang in general
|
|
|
|
# and has no effect, but can generate a compile
|
|
|
|
# error for some OS
|
2016-05-11 04:32:05 -03:00
|
|
|
list(APPEND cxx_compile_flags
|
|
|
|
-fcheck-new
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
set(visibility_flags
|
|
|
|
-fvisibility=hidden
|
2015-10-13 01:47:58 -03:00
|
|
|
-include visibility.h
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
set(added_c_flags
|
|
|
|
${c_compile_flags}
|
|
|
|
${warnings}
|
|
|
|
${c_warnings}
|
|
|
|
${visibility_flags}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(added_cxx_flags
|
|
|
|
${cxx_compile_flags}
|
|
|
|
${warnings}
|
|
|
|
${cxx_warnings}
|
|
|
|
${visibility_flags}
|
|
|
|
)
|
|
|
|
|
2016-09-01 20:12:05 -03:00
|
|
|
set(added_optimization_flags
|
|
|
|
${max_optimization}
|
|
|
|
${_optimization_flags}
|
|
|
|
)
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
set(added_include_dirs
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_BINARY_DIR}
|
|
|
|
${PX4_BINARY_DIR}/src
|
|
|
|
${PX4_BINARY_DIR}/src/modules
|
2017-01-02 01:56:48 -04:00
|
|
|
${PX4_BINARY_DIR}/src/modules/px4_messages
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_SOURCE_DIR}/mavlink/include/mavlink
|
2017-01-02 01:56:48 -04:00
|
|
|
${PX4_SOURCE_DIR}/src
|
|
|
|
${PX4_SOURCE_DIR}/src/drivers/boards/${BOARD}
|
|
|
|
${PX4_SOURCE_DIR}/src/include
|
|
|
|
${PX4_SOURCE_DIR}/src/lib
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_SOURCE_DIR}/src/lib/DriverFramework/framework/include
|
2017-01-02 01:56:48 -04:00
|
|
|
${PX4_SOURCE_DIR}/src/modules
|
|
|
|
${PX4_SOURCE_DIR}/src/platforms
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
|
2015-09-15 16:22:58 -03:00
|
|
|
list(APPEND added_include_dirs
|
2015-11-05 20:29:04 -04:00
|
|
|
src/lib/matrix
|
2015-09-15 16:22:58 -03:00
|
|
|
)
|
2015-09-08 22:39:51 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
set(added_link_dirs) # none used currently
|
2016-12-04 20:10:24 -04:00
|
|
|
set(added_exe_linker_flags)
|
2015-09-07 21:37:45 -03:00
|
|
|
|
2015-09-08 00:58:31 -03:00
|
|
|
string(TOUPPER ${BOARD} board_upper)
|
|
|
|
string(REPLACE "-" "_" board_config ${board_upper})
|
2016-09-22 18:06:05 -03:00
|
|
|
set (added_target_definitions)
|
|
|
|
if (NOT ${target_definitions})
|
|
|
|
px4_prepend_string(OUT added_target_definitions STR "-D" LIST ${target_definitions})
|
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
set(added_definitions
|
2015-09-08 00:58:31 -03:00
|
|
|
-DCONFIG_ARCH_BOARD_${board_config}
|
2016-07-07 18:06:43 -03:00
|
|
|
-D__STDC_FORMAT_MACROS
|
2016-09-22 18:06:05 -03:00
|
|
|
${added_target_definitions}
|
2015-09-07 21:37:45 -03:00
|
|
|
)
|
|
|
|
|
2016-04-26 14:04:58 -03:00
|
|
|
if (NOT (APPLE AND (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")))
|
|
|
|
set(added_exe_linker_flags
|
2015-09-12 06:25:48 -03:00
|
|
|
-Wl,--warn-common
|
2015-10-25 10:36:58 -03:00
|
|
|
-Wl,--gc-sections
|
2016-05-11 04:32:05 -03:00
|
|
|
#,--print-gc-sections
|
2015-10-25 10:36:58 -03:00
|
|
|
)
|
|
|
|
endif()
|
2015-09-07 21:37:45 -03:00
|
|
|
|
2016-12-04 20:10:24 -04:00
|
|
|
# code coverage
|
|
|
|
if ($ENV{PX4_CODE_COVERAGE} MATCHES "1")
|
|
|
|
message(STATUS "Code coverage build flags enabled")
|
|
|
|
list(APPEND added_cxx_flags
|
|
|
|
-fprofile-arcs -ftest-coverage --coverage -g3 -O0 -fno-elide-constructors -Wno-invalid-offsetof -fno-default-inline -fno-inline
|
|
|
|
)
|
|
|
|
list(APPEND added_c_flags
|
|
|
|
-fprofile-arcs -ftest-coverage --coverage -g3 -O0 -fno-default-inline -fno-inline
|
|
|
|
)
|
|
|
|
list(APPEND added_exe_linker_flags
|
|
|
|
-ftest-coverage --coverage -lgcov
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
# output
|
|
|
|
foreach(var ${inout_vars})
|
|
|
|
string(TOLOWER ${var} lower_var)
|
|
|
|
set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)
|
2015-09-08 01:07:41 -03:00
|
|
|
#message(STATUS "set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)")
|
2015-09-07 21:37:45 -03:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
|
2015-09-08 18:36:09 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_mangle_name
|
|
|
|
#
|
|
|
|
# Convert a path name to a module name
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_mangle_name(dirname newname)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# dirname : path to module dir
|
|
|
|
#
|
2016-01-19 03:16:31 -04:00
|
|
|
# Output:
|
2015-09-08 18:36:09 -03:00
|
|
|
# newname : module name
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_mangle_name(${dirpath} mangled_name)
|
|
|
|
# message(STATUS "module name is ${mangled_name}")
|
|
|
|
#
|
|
|
|
function(px4_mangle_name dirname newname)
|
|
|
|
set(tmp)
|
|
|
|
string(REPLACE "/" "__" tmp ${dirname})
|
|
|
|
set(${newname} ${tmp} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2015-09-10 00:00:58 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_create_git_hash_header
|
|
|
|
#
|
|
|
|
# Create a header file containing the git hash of the current tree
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# HEADER : path of the header file to generate
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h)
|
|
|
|
#
|
|
|
|
function(px4_create_git_hash_header)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_create_git_hash_header
|
2016-12-20 16:12:12 -04:00
|
|
|
ONE_VALUE OUT
|
|
|
|
REQUIRED OUT
|
2015-09-10 00:00:58 -03:00
|
|
|
ARGN ${ARGN})
|
2016-12-20 16:12:12 -04:00
|
|
|
file(WRITE ${OUT} "")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT __fake
|
2016-12-30 21:00:49 -04:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${OUT} > ${PX4_BINARY_DIR}/git_header.log
|
2016-12-21 07:48:21 -04:00
|
|
|
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
|
2016-12-20 16:12:12 -04:00
|
|
|
COMMENT "Generating git hash header"
|
|
|
|
)
|
|
|
|
add_custom_target(ver_gen ALL
|
|
|
|
DEPENDS ${OUT} __fake)
|
2015-09-10 00:00:58 -03:00
|
|
|
endfunction()
|
|
|
|
|
2015-09-11 06:33:42 -03:00
|
|
|
#=============================================================================
|
2015-09-13 19:30:32 -03:00
|
|
|
#
|
2015-10-06 15:10:31 -03:00
|
|
|
# px4_generate_parameters_xml
|
|
|
|
#
|
|
|
|
# Generates a parameters.xml file.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_generate_parameters_xml(OUT <param-xml_file>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# BOARD : the board
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# OUT : the generated xml file
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_generate_parameters_xml(OUT parameters.xml)
|
|
|
|
#
|
|
|
|
function(px4_generate_parameters_xml)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_generate_parameters_xml
|
2016-12-22 09:16:23 -04:00
|
|
|
ONE_VALUE OUT BOARD SCOPE
|
2015-10-06 15:10:31 -03:00
|
|
|
REQUIRED OUT BOARD
|
|
|
|
ARGN ${ARGN})
|
2016-08-18 16:37:23 -03:00
|
|
|
set(path ${PX4_SOURCE_DIR}/src)
|
2015-10-10 05:15:22 -03:00
|
|
|
file(GLOB_RECURSE param_src_files
|
2016-08-18 16:37:23 -03:00
|
|
|
${PX4_SOURCE_DIR}/src/*params.c
|
2015-10-10 05:15:22 -03:00
|
|
|
)
|
2015-10-06 15:10:31 -03:00
|
|
|
add_custom_command(OUTPUT ${OUT}
|
2016-08-18 16:37:23 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_params.py
|
2016-12-22 09:16:23 -04:00
|
|
|
-s ${path} --board CONFIG_ARCH_${BOARD} --xml --inject-xml --scope ${SCOPE}
|
2017-01-05 16:02:39 -04:00
|
|
|
DEPENDS ${param_src_files} ${PX4_SOURCE_DIR}/Tools/px_process_params.py
|
|
|
|
${PX4_SOURCE_DIR}/Tools/px_generate_params.py
|
2015-10-06 15:10:31 -03:00
|
|
|
)
|
|
|
|
set(${OUT} ${${OUT}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_generate_parameters_source
|
2015-09-13 19:30:32 -03:00
|
|
|
#
|
|
|
|
# Generates a source file with all parameters.
|
|
|
|
#
|
|
|
|
# Usage:
|
2015-11-05 17:48:35 -04:00
|
|
|
# px4_generate_parameters_source(OUT <list-source-files> XML <param-xml-file> [SCOPE <cmake file for scoping>])
|
2015-10-06 15:10:31 -03:00
|
|
|
#
|
|
|
|
# Input:
|
2015-11-05 17:48:35 -04:00
|
|
|
# XML : the parameters.xml file
|
|
|
|
# SCOPE : the cmake file used to limit scope of the paramaters
|
|
|
|
# DEPS : target dependencies
|
2015-09-13 19:30:32 -03:00
|
|
|
#
|
|
|
|
# Output:
|
2015-10-06 15:10:31 -03:00
|
|
|
# OUT : the generated source files
|
2015-09-13 19:30:32 -03:00
|
|
|
#
|
|
|
|
# Example:
|
2015-11-05 17:48:35 -04:00
|
|
|
# px4_generate_parameters_source(OUT param_files XML parameters.xml SCOPE ${OS}_${BOARD}_${LABEL}.cmake )
|
2015-09-11 06:33:42 -03:00
|
|
|
#
|
2015-10-06 15:10:31 -03:00
|
|
|
function(px4_generate_parameters_source)
|
2015-09-13 19:30:32 -03:00
|
|
|
px4_parse_function_args(
|
2015-10-06 15:10:31 -03:00
|
|
|
NAME px4_generate_parameters_source
|
2015-11-05 17:48:35 -04:00
|
|
|
ONE_VALUE OUT XML SCOPE DEPS
|
2015-10-06 15:10:31 -03:00
|
|
|
REQUIRED OUT XML
|
2015-09-13 19:30:32 -03:00
|
|
|
ARGN ${ARGN})
|
|
|
|
set(generated_files
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/px4_parameters.h
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/px4_parameters.c)
|
|
|
|
set_source_files_properties(${generated_files}
|
|
|
|
PROPERTIES GENERATED TRUE)
|
2016-05-04 18:25:35 -03:00
|
|
|
if ("${config_generate_parameters_scope}" STREQUAL "ALL")
|
|
|
|
set(SCOPE "")
|
|
|
|
endif()
|
2015-09-13 19:30:32 -03:00
|
|
|
add_custom_command(OUTPUT ${generated_files}
|
2016-08-18 16:37:23 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_generate_params.py ${XML} ${SCOPE}
|
2016-05-04 18:25:35 -03:00
|
|
|
DEPENDS ${XML} ${DEPS} ${SCOPE}
|
2015-09-11 06:33:42 -03:00
|
|
|
)
|
2015-09-13 19:30:32 -03:00
|
|
|
set(${OUT} ${generated_files} PARENT_SCOPE)
|
2015-09-11 06:33:42 -03:00
|
|
|
endfunction()
|
|
|
|
|
2015-10-06 15:10:31 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_generate_airframes_xml
|
|
|
|
#
|
|
|
|
# Generates airframes.xml
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_generate_airframes_xml(OUT <airframe-xml-file>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# XML : the airframes.xml file
|
|
|
|
# BOARD : the board
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# OUT : the generated source files
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_generate_airframes_xml(OUT airframes.xml)
|
|
|
|
#
|
|
|
|
function(px4_generate_airframes_xml)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_generate_airframes_xml
|
|
|
|
ONE_VALUE OUT BOARD
|
|
|
|
REQUIRED OUT BOARD
|
|
|
|
ARGN ${ARGN})
|
2016-08-18 16:37:23 -03:00
|
|
|
set(process_airframes ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py)
|
2015-10-06 15:10:31 -03:00
|
|
|
add_custom_command(OUTPUT ${OUT}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${process_airframes}
|
2016-12-12 19:11:51 -04:00
|
|
|
-a ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d
|
2015-10-06 15:10:31 -03:00
|
|
|
--board CONFIG_ARCH_BOARD_${BOARD} --xml
|
|
|
|
)
|
|
|
|
set(${OUT} ${${OUT}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2015-09-19 14:44:02 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_copy_tracked
|
|
|
|
#
|
|
|
|
# Copy files to a directory and keep track of dependencies.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_copy_tracked(OUT <dest-files> FILES <in-files> DIR <dir-name>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# FILES : the source files
|
|
|
|
# DEST : the directory to copy files to
|
|
|
|
# RELATIVE : relative directory for source files
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# OUT : the copied files
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_copy_tracked(OUT copied_files FILES src_files DEST path RELATIVE path_rel)
|
|
|
|
#
|
|
|
|
function(px4_copy_tracked)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_copy_tracked
|
|
|
|
ONE_VALUE DEST OUT RELATIVE
|
|
|
|
MULTI_VALUE FILES
|
|
|
|
REQUIRED DEST OUT FILES
|
|
|
|
ARGN ${ARGN})
|
|
|
|
set(files)
|
|
|
|
# before build, make sure dest directory exists
|
|
|
|
execute_process(
|
|
|
|
COMMAND cmake -E make_directory ${DEST})
|
|
|
|
# create rule to copy each file and set dependency as source file
|
|
|
|
set(_files_out)
|
|
|
|
foreach(_file ${FILES})
|
|
|
|
if (RELATIVE)
|
|
|
|
file(RELATIVE_PATH _file_path ${RELATIVE} ${_file})
|
|
|
|
else()
|
|
|
|
set(_file_path ${_file})
|
|
|
|
endif()
|
|
|
|
set(_dest_file ${DEST}/${_file_path})
|
|
|
|
#message(STATUS "copy ${_file} -> ${_dest_file}")
|
|
|
|
add_custom_command(OUTPUT ${_dest_file}
|
|
|
|
COMMAND cmake -E copy ${_file} ${_dest_file}
|
|
|
|
DEPENDS ${_file})
|
|
|
|
list(APPEND _files_out ${_dest_file})
|
|
|
|
endforeach()
|
|
|
|
set(${OUT} ${_files_out} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2016-12-12 19:11:51 -04:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_share_subdirectory
|
|
|
|
#
|
|
|
|
# This function simplifes sharing a sub directory
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# px4_share_subdirectory(RELDIR <relative path> ARGS <args>)
|
|
|
|
#
|
|
|
|
# Input:
|
|
|
|
# RELDIR : The relitive path to share.
|
|
|
|
# ARGS : Any optional arguments to pass to add_subdirectory
|
|
|
|
#
|
|
|
|
# Output:
|
|
|
|
# : None
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_share_subdirectory(RELDIR ../uavcan/libuavcan ARGS EXCLUDE_FROM_ALL)
|
|
|
|
#
|
|
|
|
function(px4_share_subdirectory)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_share_subdirectory
|
|
|
|
ONE_VALUE OUT RELDIR
|
|
|
|
MULTI_VALUE ARGS
|
|
|
|
REQUIRED RELDIR
|
|
|
|
ARGN ${ARGN})
|
|
|
|
add_subdirectory(${RELDIR} ${RELDIR}/${RELDIR} ${ARGS})
|
|
|
|
endfunction()
|
2016-09-01 20:12:05 -03:00
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_strip_optimization
|
|
|
|
#
|
|
|
|
function(px4_strip_optimization name)
|
|
|
|
set(_compile_flags)
|
|
|
|
separate_arguments(_args UNIX_COMMAND ${ARGN})
|
|
|
|
foreach(_flag ${_args})
|
|
|
|
if(NOT "${_flag}" MATCHES "^-O")
|
|
|
|
set(_compile_flags "${_compile_flags} ${_flag}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
string(STRIP "${_compile_flags}" _compile_flags)
|
|
|
|
set(${name} "${_compile_flags}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_add_optimization_flags_for_target
|
|
|
|
#
|
2016-09-02 19:45:15 -03:00
|
|
|
set(all_posix_cmake_targets "" CACHE INTERNAL "All cmake targets for which optimization can be suppressed")
|
2016-09-01 20:12:05 -03:00
|
|
|
function(px4_add_optimization_flags_for_target target)
|
|
|
|
set(_no_optimization_for_target FALSE)
|
2016-09-02 19:45:15 -03:00
|
|
|
# If the current CONFIG is posix_sitl_* then suppress optimization for certain targets.
|
|
|
|
if(CONFIG MATCHES "^posix_sitl_")
|
|
|
|
foreach(_regexp $ENV{PX4_NO_OPTIMIZATION})
|
|
|
|
if("${target}" MATCHES "${_regexp}")
|
|
|
|
set(_no_optimization_for_target TRUE)
|
|
|
|
set(_matched_regexp "${_regexp}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
# Create a full list of targets that optimization can be suppressed for.
|
|
|
|
list(APPEND all_posix_cmake_targets ${target})
|
|
|
|
set(all_posix_cmake_targets ${all_posix_cmake_targets} CACHE INTERNAL "All cmake targets for which optimization can be suppressed")
|
|
|
|
endif()
|
2016-09-01 20:12:05 -03:00
|
|
|
if(NOT ${_no_optimization_for_target})
|
|
|
|
target_compile_options(${target} PRIVATE ${optimization_flags})
|
|
|
|
else()
|
|
|
|
message(STATUS "Disabling optimization for target '${target}' because it matches the regexp '${_matched_regexp}' in env var PX4_NO_OPTIMIZATION")
|
|
|
|
target_compile_options(${target} PRIVATE -O0)
|
|
|
|
endif()
|
|
|
|
# Pass variable to the parent px4_add_library.
|
|
|
|
set(_no_optimization_for_target ${_no_optimization_for_target} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_add_executable
|
|
|
|
#
|
|
|
|
# Like add_executable but with optimization flag fixup.
|
|
|
|
#
|
|
|
|
function(px4_add_executable target)
|
|
|
|
add_executable(${target} ${ARGN})
|
|
|
|
px4_add_optimization_flags_for_target(${target})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_add_library
|
|
|
|
#
|
|
|
|
# Like add_library but with optimization flag fixup.
|
|
|
|
#
|
|
|
|
function(px4_add_library target)
|
|
|
|
add_library(${target} ${ARGN})
|
|
|
|
px4_add_optimization_flags_for_target(${target})
|
|
|
|
# Pass variable to the parent px4_add_module.
|
|
|
|
set(_no_optimization_for_target ${_no_optimization_for_target} PARENT_SCOPE)
|
|
|
|
endfunction()
|
2015-09-19 14:44:02 -03:00
|
|
|
|
2015-09-07 21:37:45 -03:00
|
|
|
# vim: set noet fenc=utf-8 ff=unix nowrap:
|