You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
4.4 KiB
156 lines
4.4 KiB
8 years ago
|
|
||
|
function(px4_add_sitl_app)
|
||
7 years ago
|
px4_parse_function_args(NAME px4_add_sitl_app
|
||
8 years ago
|
ONE_VALUE APP_NAME MAIN_SRC UPLOAD_NAME
|
||
|
REQUIRED APP_NAME MAIN_SRC
|
||
8 years ago
|
ARGN ${ARGN}
|
||
|
)
|
||
8 years ago
|
|
||
|
px4_add_executable(${APP_NAME}
|
||
8 years ago
|
${MAIN_SRC}
|
||
|
apps.cpp
|
||
|
)
|
||
8 years ago
|
|
||
|
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()
|
||
|
endfunction()
|
||
|
|
||
|
#=============================================================================
|
||
|
# sitl run targets
|
||
|
#
|
||
|
|
||
8 years ago
|
set(SITL_RUNNER_MAIN_CPP ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp)
|
||
8 years ago
|
px4_add_sitl_app(APP_NAME px4
|
||
8 years ago
|
UPLOAD_NAME upload
|
||
|
MAIN_SRC ${SITL_RUNNER_MAIN_CPP}
|
||
|
)
|
||
8 years ago
|
|
||
|
set(SITL_WORKING_DIR ${PX4_BINARY_DIR}/tmp)
|
||
|
file(MAKE_DIRECTORY ${SITL_WORKING_DIR})
|
||
|
|
||
8 years ago
|
# add a symlink to the logs dir to make it easier to find them
|
||
8 years ago
|
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/logs
|
||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink ${SITL_WORKING_DIR}/rootfs/fs/microsd/log logs
|
||
|
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
||
|
add_custom_target(logs_symlink DEPENDS ${PX4_BINARY_DIR}/logs)
|
||
8 years ago
|
|
||
8 years ago
|
add_custom_target(run_config
|
||
8 years ago
|
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}
|
||
7 years ago
|
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
||
|
USES_TERMINAL
|
||
8 years ago
|
DEPENDS px4 logs_symlink
|
||
8 years ago
|
)
|
||
8 years ago
|
|
||
7 years ago
|
px4_add_git_submodule(TARGET git_gazebo PATH "${PX4_SOURCE_DIR}/Tools/sitl_gazebo")
|
||
|
px4_add_git_submodule(TARGET git_jmavsim PATH "${PX4_SOURCE_DIR}/Tools/jMAVSim")
|
||
|
|
||
8 years ago
|
# Add support for external project building
|
||
|
include(ExternalProject)
|
||
|
|
||
8 years ago
|
# 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 ""
|
||
7 years ago
|
DEPENDS
|
||
|
git_gazebo
|
||
8 years ago
|
)
|
||
|
set_target_properties(sitl_gazebo PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||
|
|
||
8 years ago
|
ExternalProject_Add_Step(sitl_gazebo forceconfigure
|
||
|
DEPENDEES update
|
||
|
DEPENDERS configure
|
||
7 years ago
|
ALWAYS 1
|
||
|
)
|
||
8 years ago
|
|
||
8 years ago
|
# create targets for each viewer/model/debugger combination
|
||
|
set(viewers none jmavsim gazebo replay)
|
||
8 years ago
|
set(debuggers none ide gdb lldb ddd valgrind callgrind)
|
||
8 years ago
|
set(models none iris iris_opt_flow iris_rplidar standard_vtol plane solo tailsitter typhoon_h480 rover hippocampus)
|
||
8 years ago
|
set(all_posix_vmd_make_targets)
|
||
|
foreach(viewer ${viewers})
|
||
|
foreach(debugger ${debuggers})
|
||
|
foreach(model ${models})
|
||
|
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()
|
||
|
|
||
|
if (debugger STREQUAL "ide" AND viewer STREQUAL "gazebo")
|
||
8 years ago
|
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})
|
||
8 years ago
|
|
||
8 years ago
|
configure_file(${PX4_SOURCE_DIR}/src/platforms/posix/sitl_runner_main.cpp.in sitl_runner_main_${model}.cpp @ONLY)
|
||
8 years ago
|
|
||
|
px4_add_sitl_app(APP_NAME px4_${model}
|
||
8 years ago
|
UPLOAD_NAME upload_${model}
|
||
|
MAIN_SRC ${CMAKE_CURRENT_BINARY_DIR}/sitl_runner_main_${model}.cpp
|
||
|
)
|
||
|
set_target_properties(px4_${model} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||
8 years ago
|
endif()
|
||
|
|
||
|
add_custom_target(${_targ_name}
|
||
8 years ago
|
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
|
||
|
$<TARGET_FILE:px4>
|
||
|
${config_sitl_rcS_dir}
|
||
|
${debugger}
|
||
|
${viewer}
|
||
|
${model}
|
||
|
${PX4_SOURCE_DIR}
|
||
|
${PX4_BINARY_DIR}
|
||
7 years ago
|
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
||
|
USES_TERMINAL
|
||
|
DEPENDS
|
||
|
logs_symlink
|
||
8 years ago
|
)
|
||
8 years ago
|
list(APPEND all_posix_vmd_make_targets ${_targ_name})
|
||
|
if (viewer STREQUAL "gazebo")
|
||
|
add_dependencies(${_targ_name} sitl_gazebo)
|
||
8 years ago
|
if (viewer STREQUAL "gazebo")
|
||
|
add_dependencies(${_targ_name} px4_${model})
|
||
|
endif()
|
||
7 years ago
|
elseif(viewer STREQUAL "jmavsim")
|
||
|
add_dependencies(${_targ_name} git_jmavsim)
|
||
8 years ago
|
endif()
|
||
|
endforeach()
|
||
|
endforeach()
|
||
|
endforeach()
|
||
|
|
||
|
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
|
||
|
)
|