2015-09-08 21:50:18 -03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2015-09-08 19:39:13 -03:00
|
|
|
px4_posix_generate_builtin_commands(
|
2016-10-21 10:54:48 -03:00
|
|
|
OUT apps
|
2015-09-10 00:00:58 -03:00
|
|
|
MODULE_LIST ${module_libraries})
|
2015-09-08 19:39:13 -03:00
|
|
|
|
2016-04-15 18:42:47 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
function(px4_add_sitl_app)
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_sitl_app
|
|
|
|
ONE_VALUE APP_NAME MAIN_SRC UPLOAD_NAME
|
|
|
|
REQUIRED APP_NAME MAIN_SRC
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
|
|
|
|
|
|
|
|
include(fastrpc)
|
|
|
|
include(linux_app)
|
|
|
|
|
|
|
|
FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")
|
|
|
|
LINUX_APP(
|
|
|
|
APP_NAME ${APP_NAME}
|
|
|
|
IDL_NAME px4muorb
|
|
|
|
APPS_DEST "/home/linaro"
|
|
|
|
SOURCES
|
|
|
|
px4muorb_stub.c
|
|
|
|
${MAIN_SRC}
|
|
|
|
apps.cpp
|
|
|
|
LINK_LIBS
|
|
|
|
-Wl,--start-group
|
|
|
|
${module_libraries}
|
|
|
|
${df_driver_libs}
|
|
|
|
${FASTRPC_ARM_LIBS}
|
|
|
|
pthread m rt
|
|
|
|
-Wl,--end-group
|
|
|
|
)
|
|
|
|
|
|
|
|
px4_add_adb_push(OUT ${UPLOAD_NAME}
|
|
|
|
OS ${OS}
|
|
|
|
BOARD ${BOARD}
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}
|
|
|
|
${PX4_SOURCE_DIR}/posix-configs/eagle/flight/mainapp.config
|
|
|
|
DEPENDS ${APP_NAME}
|
|
|
|
DEST /home/linaro)
|
2016-04-15 18:42:47 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
elseif ("${BOARD}" STREQUAL "rpi")
|
2015-09-08 21:50:18 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
px4_add_executable(${APP_NAME}
|
|
|
|
${MAIN_SRC}
|
2016-10-21 10:54:48 -03:00
|
|
|
apps.cpp
|
2016-12-08 00:41:46 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${APP_NAME}
|
2016-05-03 05:03:28 -03:00
|
|
|
-Wl,--start-group
|
|
|
|
${module_libraries}
|
2016-12-08 00:41:46 -04:00
|
|
|
df_driver_framework
|
2016-05-03 05:03:28 -03:00
|
|
|
${df_driver_libs}
|
|
|
|
pthread m rt
|
|
|
|
-Wl,--end-group
|
2016-12-08 00:41:46 -04:00
|
|
|
)
|
2016-04-29 01:09:23 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
file(GLOB RPI_CONFIG_FILES ${PX4_SOURCE_DIR}/posix-configs/rpi/*.config)
|
|
|
|
px4_add_scp_push(OUT ${UPLOAD_NAME}
|
|
|
|
OS ${OS}
|
|
|
|
BOARD ${BOARD}
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}
|
|
|
|
${RPI_CONFIG_FILES}
|
|
|
|
${PX4_SOURCE_DIR}/ROMFS
|
|
|
|
DEPENDS ${APP_NAME}
|
|
|
|
DEST /home/pi)
|
2016-05-20 19:11:33 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
elseif ("${BOARD}" STREQUAL "bebop")
|
2016-04-29 01:09:23 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
|
2016-04-01 06:36:27 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
px4_add_executable(${APP_NAME}
|
|
|
|
${MAIN_SRC}
|
|
|
|
apps.cpp
|
|
|
|
)
|
2016-05-31 08:04:22 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
if (NOT APPLE)
|
|
|
|
target_link_libraries(${APP_NAME}
|
|
|
|
-Wl,--start-group
|
|
|
|
${module_libraries}
|
|
|
|
${df_driver_libs}
|
|
|
|
pthread m rt
|
|
|
|
-Wl,--end-group
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
target_link_libraries(${APP_NAME}
|
|
|
|
${module_libraries}
|
|
|
|
${df_driver_libs}
|
|
|
|
pthread m
|
|
|
|
)
|
|
|
|
endif()
|
2016-05-31 08:04:22 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
px4_add_adb_push_to_bebop(OUT ${UPLOAD_NAME}
|
|
|
|
OS ${OS}
|
|
|
|
BOARD ${BOARD}
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}
|
|
|
|
DEPENDS ${APP_NAME}
|
|
|
|
DEST /usr/bin)
|
2016-05-31 08:04:22 -03:00
|
|
|
|
|
|
|
else()
|
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
px4_add_executable(${APP_NAME}
|
|
|
|
${MAIN_SRC}
|
|
|
|
apps.cpp
|
|
|
|
)
|
2016-07-29 06:15:10 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
if (NOT APPLE)
|
|
|
|
target_link_libraries(${APP_NAME}
|
|
|
|
-Wl,--start-group
|
|
|
|
${module_libraries}
|
|
|
|
${df_driver_libs}
|
|
|
|
pthread m rt
|
|
|
|
-Wl,--end-group
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
target_link_libraries(${APP_NAME}
|
|
|
|
${module_libraries}
|
|
|
|
${df_driver_libs}
|
|
|
|
pthread m
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
2016-05-31 08:04:22 -03:00
|
|
|
|
2016-12-08 00:41:46 -04:00
|
|
|
SET(SITL_RUNNER_MAIN_CPP ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp)
|
|
|
|
px4_add_sitl_app(APP_NAME px4
|
|
|
|
UPLOAD_NAME upload
|
|
|
|
MAIN_SRC ${SITL_RUNNER_MAIN_CPP}
|
2015-10-19 18:46:18 -03:00
|
|
|
)
|
2016-09-01 20:12:05 -03:00
|
|
|
|
2016-08-25 16:47:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# sitl run targets
|
|
|
|
#
|
|
|
|
|
|
|
|
set(SITL_WORKING_DIR ${PX4_BINARY_DIR}/tmp)
|
|
|
|
file(MAKE_DIRECTORY ${SITL_WORKING_DIR})
|
|
|
|
|
2015-10-25 12:18:14 -03:00
|
|
|
add_custom_target(run_config
|
2016-08-25 16:47:45 -03:00
|
|
|
COMMAND Tools/sitl_run.sh
|
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
${config_sitl_rcS_dir}
|
|
|
|
${config_sitl_debugger}
|
|
|
|
${config_sitl_viewer}
|
|
|
|
${config_sitl_model}
|
|
|
|
${PX4_SOURCE_DIR}
|
|
|
|
${PX4_BINARY_DIR}
|
|
|
|
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
2015-10-25 07:20:28 -03:00
|
|
|
USES_TERMINAL
|
2015-10-24 11:57:46 -03:00
|
|
|
)
|
2016-07-28 10:52:46 -03:00
|
|
|
add_dependencies(run_config px4)
|
2015-10-25 12:18:14 -03:00
|
|
|
|
2016-08-25 16:47:45 -03:00
|
|
|
# project to build sitl_gazebo if necessary
|
|
|
|
ExternalProject_Add(sitl_gazebo
|
|
|
|
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/sitl_gazebo
|
|
|
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
|
|
|
BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo
|
|
|
|
INSTALL_COMMAND ""
|
|
|
|
)
|
|
|
|
set_target_properties(sitl_gazebo PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
|
|
|
|
|
|
# create targets for each viewer/model/debugger combination
|
|
|
|
set(viewers none jmavsim gazebo replay)
|
2016-12-08 00:41:46 -04:00
|
|
|
set(debuggers none ide gdb lldb ddd valgrind)
|
2016-08-25 16:47:45 -03:00
|
|
|
set(models none iris iris_opt_flow tailsitter standard_vtol plane solo typhoon_h480)
|
2016-09-02 19:45:15 -03:00
|
|
|
set(all_posix_vmd_make_targets)
|
2016-08-25 16:47:45 -03:00
|
|
|
foreach(viewer ${viewers})
|
|
|
|
foreach(debugger ${debuggers})
|
|
|
|
foreach(model ${models})
|
2015-10-29 06:35:35 -03:00
|
|
|
if (debugger STREQUAL "none")
|
|
|
|
if (model STREQUAL "none")
|
|
|
|
set(_targ_name "${viewer}")
|
|
|
|
else()
|
|
|
|
set(_targ_name "${viewer}_${model}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if (model STREQUAL "none")
|
|
|
|
set(_targ_name "${viewer}___${debugger}")
|
|
|
|
else()
|
|
|
|
set(_targ_name "${viewer}_${model}_${debugger}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-12-08 00:41:46 -04:00
|
|
|
|
|
|
|
if (debugger STREQUAL "ide" AND viewer STREQUAL "gazebo")
|
|
|
|
SET(SITL_RUNNER_SOURCE_DIR ${PX4_SOURCE_DIR})
|
|
|
|
SET(SITL_RUNNER_MODEL_FILE ${PX4_SOURCE_DIR}/${config_sitl_rcS_dir}/${model})
|
|
|
|
SET(SITL_RUNNER_WORKING_DIRECTORY ${SITL_WORKING_DIR})
|
|
|
|
|
|
|
|
CONFIGURE_FILE(${PX4_SOURCE_DIR}/src/platforms/posix/sitl_runner_main.cpp.in sitl_runner_main_${model}.cpp @ONLY)
|
|
|
|
|
|
|
|
px4_add_sitl_app(APP_NAME px4_${model}
|
|
|
|
UPLOAD_NAME upload_${model}
|
|
|
|
MAIN_SRC ${CMAKE_CURRENT_BINARY_DIR}/sitl_runner_main_${model}.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-10-29 06:35:35 -03:00
|
|
|
add_custom_target(${_targ_name}
|
2016-08-25 16:47:45 -03:00
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
|
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
${config_sitl_rcS_dir}
|
|
|
|
${debugger}
|
|
|
|
${viewer}
|
|
|
|
${model}
|
|
|
|
${PX4_SOURCE_DIR}
|
|
|
|
${PX4_BINARY_DIR}
|
|
|
|
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
2015-10-29 06:35:35 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2016-09-02 19:45:15 -03:00
|
|
|
list(APPEND all_posix_vmd_make_targets ${_targ_name})
|
2016-08-25 16:47:45 -03:00
|
|
|
if (viewer STREQUAL "gazebo")
|
|
|
|
add_dependencies(${_targ_name} sitl_gazebo)
|
|
|
|
endif()
|
2015-10-29 06:35:35 -03:00
|
|
|
endforeach()
|
2015-10-25 12:18:14 -03:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
2015-10-24 11:57:46 -03:00
|
|
|
|
2016-09-02 19:45:15 -03:00
|
|
|
px4_join(OUT posix_vmd_make_target_list LIST ${all_posix_vmd_make_targets} GLUE "\\n")
|
|
|
|
add_custom_target(list_vmd_make_targets
|
|
|
|
COMMAND sh -c "printf \"${posix_vmd_make_target_list}\\n\""
|
|
|
|
COMMENT "List of acceptable '${CONFIG}' <viewer_model_debugger> targets:"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2016-07-24 14:07:14 -03:00
|
|
|
#=============================================================================
|
|
|
|
# install
|
|
|
|
#
|
|
|
|
|
2016-08-25 16:47:45 -03:00
|
|
|
install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2016-07-24 14:07:14 -03:00
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
|
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
|
|
|
|
|
2016-08-25 16:47:45 -03:00
|
|
|
#=============================================================================
|
|
|
|
# tests
|
|
|
|
#
|
|
|
|
|
|
|
|
add_test(NAME rcS_tests
|
|
|
|
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
|
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
posix-configs/SITL/init/test
|
|
|
|
none
|
|
|
|
none
|
|
|
|
none
|
|
|
|
${PX4_SOURCE_DIR}
|
|
|
|
${PX4_BINARY_DIR}
|
|
|
|
WORKING_DIRECTORY ${SITL_WORKING_DIR})
|
|
|
|
set_tests_properties(rcS_tests PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "All tests passed")
|
|
|
|
|
2015-09-08 16:18:59 -03:00
|
|
|
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|