px4-firmware/cmake/common/px4_base.cmake

687 lines
20 KiB
CMake
Raw Normal View History

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_join
# * px4_add_module
# * px4_add_common_flags
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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)
#
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
#=============================================================================
#
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> ]
# [ 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> ]
# [ SRCS <list> ]
# [ MODULE_CONFIG <list> ]
# [ EXTERNAL ]
# [ DYNAMIC ]
2015-09-07 21:37:45 -03:00
# )
#
# Input:
# MODULE : unique name of module
# MAIN : entry point, if not given, assumed to be library
# STACK : deprecated use stack main instead
# STACK_MAIN : size of stack for main function
# STACK_MAX : maximum stack size of any frame
# COMPILE_FLAGS : compile flags
2015-09-07 21:37:45 -03:00
# LINK_FLAGS : link flags
# SRCS : source files
# MODULE_CONFIG : yaml config file(s)
2015-09-07 21:37:45 -03:00
# INCLUDES : include directories
# DEPENDS : targets which this module depends on
# EXTERNAL : flag to indicate that this module is out-of-tree
# DYNAMIC : don't compile into the px4 binary, but build a separate dynamically loadable module (posix)
# UNITY_BUILD : merge all source files and build this module as a single compilation unit
2015-09-07 21:37:45 -03:00
#
# Output:
# Static library with name matching MODULE.
# (Or a shared library when DYNAMIC is specified.)
2015-09-07 21:37:45 -03:00
#
# Example:
# px4_add_module(MODULE test
# SRCS
# file.cpp
# 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
ONE_VALUE MODULE MAIN STACK STACK_MAIN STACK_MAX PRIORITY
MULTI_VALUE COMPILE_FLAGS LINK_FLAGS SRCS INCLUDES DEPENDS MODULE_CONFIG
OPTIONS EXTERNAL DYNAMIC UNITY_BUILD
REQUIRED MODULE MAIN
2015-09-07 21:37:45 -03:00
ARGN ${ARGN})
2015-09-12 01:49:10 -03:00
if(UNITY_BUILD AND (${OS} STREQUAL "nuttx"))
# build standalone test library to catch compilation errors and provide sane output
add_library(${MODULE}_original STATIC EXCLUDE_FROM_ALL ${SRCS})
if(DEPENDS)
add_dependencies(${MODULE}_original ${DEPENDS})
endif()
if(INCLUDES)
target_include_directories(${MODULE}_original PRIVATE ${INCLUDES})
endif()
2018-09-10 13:53:26 -03:00
target_compile_definitions(${MODULE}_original PRIVATE PX4_MAIN=${MAIN}_app_main)
target_compile_definitions(${MODULE}_original PRIVATE MODULE_NAME="${MAIN}_original")
2018-09-10 13:53:26 -03:00
# unity build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
COMMAND cat ${SRCS} > ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
DEPENDS ${MODULE}_original ${DEPENDS} ${SRCS}
COMMENT "${MODULE} merging source"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp PROPERTIES GENERATED true)
add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp)
target_include_directories(${MODULE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
elseif(DYNAMIC AND MAIN AND (${OS} STREQUAL "posix"))
add_library(${MODULE} SHARED ${SRCS})
target_compile_definitions(${MODULE} PRIVATE ${MAIN}_main=px4_module_main)
set_target_properties(${MODULE} PROPERTIES
PREFIX ""
SUFFIX ".px4mod"
)
target_link_libraries(${MODULE} PRIVATE px4)
if(APPLE)
# Postpone resolving symbols until loading time, which is the default on most systems, but not Mac.
set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
else()
add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${SRCS})
endif()
# all modules can potentially use parameters and uORB
add_dependencies(${MODULE} uorb_headers)
if(NOT DYNAMIC)
target_link_libraries(${MODULE} PRIVATE prebuild_targets parameters_interface platforms__common px4_layer systemlib)
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_LIBRARIES ${MODULE})
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_PATHS ${CMAKE_CURRENT_SOURCE_DIR})
endif()
px4_add_optimization_flags_for_target(${MODULE})
# Pass variable to the parent px4_add_module.
set(_no_optimization_for_target ${_no_optimization_for_target} PARENT_SCOPE)
2015-09-12 01:49:10 -03:00
# set defaults if not set
set(MAIN_DEFAULT MAIN-NOTFOUND)
set(STACK_MAIN_DEFAULT 1024)
set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT)
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})
if(${OS} STREQUAL "qurt")
set_property(TARGET ${MODULE} PROPERTY POSITION_INDEPENDENT_CODE TRUE)
elseif(${OS} STREQUAL "nuttx")
target_compile_options(${MODULE} PRIVATE -Wframe-larger-than=${STACK_MAX})
endif()
2015-09-12 02:35:09 -03:00
if(MAIN)
target_compile_definitions(${MODULE} PRIVATE PX4_MAIN=${MAIN}_app_main)
target_compile_definitions(${MODULE} PRIVATE MODULE_NAME="${MAIN}")
2016-06-02 07:11:04 -03:00
else()
target_compile_definitions(${MODULE} PRIVATE MODULE_NAME="${MODULE}")
endif()
if(COMPILE_FLAGS)
target_compile_options(${MODULE} PRIVATE ${COMPILE_FLAGS})
2015-09-12 02:35:09 -03:00
endif()
2015-09-07 21:37:45 -03:00
if(INCLUDES)
target_include_directories(${MODULE} PRIVATE ${INCLUDES})
2015-09-07 21:37:45 -03:00
endif()
2015-09-12 01:49:10 -03:00
2015-09-07 21:37:45 -03:00
if(DEPENDS)
# using target_link_libraries for dependencies provides linking
# as well as interface include and libraries
foreach(dep ${DEPENDS})
get_target_property(dep_type ${dep} TYPE)
if (${dep_type} STREQUAL "STATIC_LIBRARY")
target_link_libraries(${MODULE} PRIVATE ${dep})
else()
add_dependencies(${MODULE} ${dep})
endif()
endforeach()
2015-09-07 21:37:45 -03:00
endif()
2015-09-12 01:49:10 -03:00
# join list variables to get ready to send to compiler
foreach(prop LINK_FLAGS)
2015-09-07 21:37:45 -03:00
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
# STACK_MAIN, MAIN, PRIORITY are PX4 specific
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
if(COMPILE_FLAGS AND ${_no_optimization_for_target})
px4_strip_optimization(COMPILE_FLAGS ${COMPILE_FLAGS})
endif()
foreach (prop 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()
if(MODULE_CONFIG)
foreach(module_config ${MODULE_CONFIG})
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${module_config})
endforeach()
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_common_flags
#
Bug fixes, typos, indentation. Over time I made a few changes unrelated to what I'm really working on. These changes are hereby committed first. The bug fixes are related to what I'm doing in that I need them to be fixed for future commits. Tools/sitl_run.sh: rename label to rcS_dir and fix usage help. cmake/common/px4_base.cmake: Remove the check on OUT_UNPARSED_ARGUMENTS, and a few typos and indentation issues. cmake/configs/posix_sitl_replay.cmake: Set the correct variable (config_sitl_rcS_dir) to the correct directory. cmake/nuttx/px4_impl_nuttx.cmake: typos and indentation issues, and removal of a redundant FORCE (INTERNAL implies FORCE). cmake/posix/px4_impl_posix.cmake: typos and indentation issues. cmake/qurt/px4_impl_qurt.cmake: typos and indentation issues. src/modules/mavlink/mavlink_ftp.cpp : possible strict-aliasing breakage. NOTES The second argument passed to sitl_run.sh is the value of config_sitl_rcS_dir. This fact is missing from the usage help. I renamed 'label' to 'rcS_dir' to better reflect this. Also, for the 'replay' config the wrong variable was set causing the call to sitl_run.sh to skip an argument and fail (ie the debugger was passed as rcS_dir and so on). The check on OUT_UNPARSED_ARGUMENTS in px4_parse_function_args basically causes every passed IN variable to be REQUIRED and is therefore a bug. The test for the presence of the REQUIRED arguments follows directly after and is sufficient for this job. This bug went unnoticed because currently every argument to OPTIONS, ONE_VALUE, and MULTI_VALUE is actually passed to the function(s) calling px4_parse_function_args (them being REQUIRED or not). The changes in mavlink_ftp.cpp are to avoid a possible aliasing bug and (mostly) to avoid the compiler warning/error: dereferencing type- punned pointer will break strict-aliasing rules [-Werror=strict-aliasing].
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>
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
# OPTIMIZATION_FLAGS : optimization compile flags variable
Bug fixes, typos, indentation. Over time I made a few changes unrelated to what I'm really working on. These changes are hereby committed first. The bug fixes are related to what I'm doing in that I need them to be fixed for future commits. Tools/sitl_run.sh: rename label to rcS_dir and fix usage help. cmake/common/px4_base.cmake: Remove the check on OUT_UNPARSED_ARGUMENTS, and a few typos and indentation issues. cmake/configs/posix_sitl_replay.cmake: Set the correct variable (config_sitl_rcS_dir) to the correct directory. cmake/nuttx/px4_impl_nuttx.cmake: typos and indentation issues, and removal of a redundant FORCE (INTERNAL implies FORCE). cmake/posix/px4_impl_posix.cmake: typos and indentation issues. cmake/qurt/px4_impl_qurt.cmake: typos and indentation issues. src/modules/mavlink/mavlink_ftp.cpp : possible strict-aliasing breakage. NOTES The second argument passed to sitl_run.sh is the value of config_sitl_rcS_dir. This fact is missing from the usage help. I renamed 'label' to 'rcS_dir' to better reflect this. Also, for the 'replay' config the wrong variable was set causing the call to sitl_run.sh to skip an argument and fail (ie the debugger was passed as rcS_dir and so on). The check on OUT_UNPARSED_ARGUMENTS in px4_parse_function_args basically causes every passed IN variable to be REQUIRED and is therefore a bug. The test for the presence of the REQUIRED arguments follows directly after and is sufficient for this job. This bug went unnoticed because currently every argument to OPTIONS, ONE_VALUE, and MULTI_VALUE is actually passed to the function(s) calling px4_parse_function_args (them being REQUIRED or not). The changes in mavlink_ftp.cpp are to avoid a possible aliasing bug and (mostly) to avoid the compiler warning/error: dereferencing type- punned pointer will break strict-aliasing rules [-Werror=strict-aliasing].
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
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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
-Wextra
-Werror
-Warray-bounds
-Wdisabled-optimization
-Wdouble-promotion
-Wfatal-errors
2015-09-07 21:37:45 -03:00
-Wfloat-equal
-Wformat-security
-Winit-self
2017-06-03 12:52:10 -03:00
-Wlogical-op
2015-09-07 21:37:45 -03:00
-Wmissing-declarations
-Wpointer-arith
-Wshadow
-Wuninitialized
-Wunknown-pragmas
-Wunused-variable
-Wno-implicit-fallthrough # set appropriate level and update
-Wno-missing-field-initializers
-Wno-missing-include-dirs # TODO: fix and enable
2015-09-07 21:37:45 -03:00
-Wno-unused-parameter
)
2015-10-25 10:35:20 -03:00
if (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")
# 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
-Wno-unused-const-variable
-Wno-varargs
-Wno-address-of-packed-member
-Wno-unknown-warning-option
2017-08-01 07:46:42 -03:00
-Wunused-but-set-variable
)
endif()
else()
2015-09-07 21:37:45 -03:00
list(APPEND warnings
-Wunused-but-set-variable
2015-09-07 21:37:45 -03:00
-Wformat=1
)
endif()
set(_optimization_flags
-fno-strict-aliasing
-fomit-frame-pointer
-fno-math-errno
-funsafe-math-optimizations
-ffunction-sections
-fdata-sections
)
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-overloaded-virtual # TODO: fix and remove
-Wreorder
2015-09-07 21:37:45 -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
2017-01-29 16:32:18 -04:00
-std=gnu++11
2015-09-07 21:37:45 -03:00
-fno-threadsafe-statics
-DCONFIG_WCHAR_BUILTIN
-D__CUSTOM_FILE_IO__
)
2017-01-29 16:32:18 -04:00
# regular Clang or AppleClang
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# force color for clang (needed for clang + ccache)
list(APPEND _optimization_flags
-fcolor-diagnostics
)
else()
list(APPEND _optimization_flags
-fno-strength-reduce
-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
list(APPEND cxx_compile_flags
-fcheck-new
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
# force color for gcc > 4.9
list(APPEND _optimization_flags
-fdiagnostics-color=always
)
endif()
list(APPEND cxx_warnings
-Wno-format-truncation # TODO: fix
)
endif()
2015-09-07 21:37:45 -03:00
set(visibility_flags
-fvisibility=hidden
-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}
)
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
set(added_optimization_flags
${_optimization_flags}
)
include_directories(
${PX4_BINARY_DIR}
${PX4_BINARY_DIR}/src
${PX4_BINARY_DIR}/src/lib
${PX4_BINARY_DIR}/src/modules
${PX4_SOURCE_DIR}/src
${PX4_SOURCE_DIR}/src/drivers/boards/${BOARD}
${PX4_SOURCE_DIR}/src/include
${PX4_SOURCE_DIR}/src/lib
${PX4_SOURCE_DIR}/src/lib/DriverFramework/framework/include
${PX4_SOURCE_DIR}/src/lib/matrix
${PX4_SOURCE_DIR}/src/modules
${PX4_SOURCE_DIR}/src/platforms
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})
add_definitions(
2015-09-08 00:58:31 -03:00
-DCONFIG_ARCH_BOARD_${board_config}
-D__STDC_FORMAT_MACROS
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()
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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
#
set(all_posix_cmake_targets "" CACHE INTERNAL "All cmake targets for which optimization can be suppressed")
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
function(px4_add_optimization_flags_for_target target)
set(_no_optimization_for_target FALSE)
# 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()
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
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})
target_compile_definitions(${target} PRIVATE MODULE_NAME="${target}")
# all PX4 libraries have access to parameters and uORB
add_dependencies(${target} uorb_headers)
target_link_libraries(${target} PRIVATE prebuild_targets parameters_interface uorb_msgs)
# TODO: move to platform layer
if ("${OS}" MATCHES "nuttx")
target_link_libraries(${target} PRIVATE m nuttx_c)
endif()
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
px4_add_optimization_flags_for_target(${target})
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
# Pass variable to the parent px4_add_module.
set(_no_optimization_for_target ${_no_optimization_for_target} PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY PX4_LIBRARIES ${target})
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_PATHS ${CMAKE_CURRENT_SOURCE_DIR})
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
endfunction()
2015-09-19 14:44:02 -03:00
#=============================================================================
#
# px4_find_python_module
#
# Find a required python module
#
# Usage
# px4_find_python_module(module_name [REQUIRED])
#
function(px4_find_python_module module)
string(TOUPPER ${module} module_upper)
if(NOT PY_${module_upper})
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
set(PY_${module}_FIND_REQUIRED TRUE)
endif()
# A module's location is usually a directory, but for binary modules
# it's a .so file.
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _${module}_status)
set(PY_${module_upper} ${_${module}_location} CACHE STRING
"Location of Python module ${module}")
endif()
endif()
find_package_handle_standard_args(PY_${module}
"couldn't find python module ${module}:
\nfor debian systems try: \
\n\tsudo apt-get install python-${module} \
\nor for all other OSs/debian: \
\n\tsudo -H pip install ${module}\n" PY_${module_upper})
#if (NOT PY_${module}_FOUND)
#message(FATAL_ERROR "python module not found, exiting")
#endif()
endfunction(px4_find_python_module)