CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/ros2/ardupilot_sitl/CMakeLists.txt
Views: 1799
1
cmake_minimum_required(VERSION 3.20)
2
project(ardupilot_sitl)
3
4
# --------------------------------------------------------------------------- #
5
# Find dependencies.
6
find_package(ament_cmake REQUIRED)
7
find_package(ament_cmake_python REQUIRED)
8
9
# --------------------------------------------------------------------------- #
10
# Add custom targets to configure and build ardupilot.
11
12
# TODO(srmainwaring): add cache variables for vehicle type, debug etc.
13
# set(ARDUPILOT_VEHICLE "copter" CACHE STRING "Vehicle type")
14
15
option(ARDUPILOT_DISABLE_NETWORKING "Disable the networking API code" OFF)
16
option(ARDUPILOT_DISABLE_SCRIPTING "Disable the scripting API code" OFF)
17
option(ARDUPILOT_DISABLE_WATCHDOG "Build with watchdog disabled" OFF)
18
option(ARDUPILOT_ENABLE_DDS "Enable the DDS client" ON)
19
option(ARDUPILOT_ENABLE_NETWORKING_TESTS "Enable the networking test code" OFF)
20
option(ARDUPILOT_ENABLE_PPP "Enable PPP networking" OFF)
21
set(ARDUPILOT_WAF_CONFIGURE_ARGS "" CACHE STRING "Arbitrary waf configure arguments")
22
set(ARDUPILOT_WAF_BUILD_ARGS "" CACHE STRING "Arbitrary waf build arguments")
23
24
25
# NOTE: look for `waf` and set source and build directories to top level.
26
# ${PROJECT_SOURCE_DIR} = ./Tools/ros2/ardupilot
27
#
28
cmake_path(SET ARDUPILOT_ROOT NORMALIZE ${PROJECT_SOURCE_DIR}/../../..)
29
30
find_program(WAF_COMMAND waf HINTS ${ARDUPILOT_ROOT})
31
message(STATUS "WAF_COMMAND: ${WAF_COMMAND}")
32
33
# Set the build config.
34
set(WAF_CONFIG $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:"--debug">)
35
set(WAF_DISABLE_NETWORKING $<$<BOOL:${ARDUPILOT_DISABLE_NETWORKING}>:"--disable-networking">)
36
set(WAF_DISABLE_SCRIPTING $<$<BOOL:${ARDUPILOT_DISABLE_SCRIPTING}>:"--disable-scripting">)
37
set(WAF_DISABLE_WATCHDOG $<$<BOOL:${ARDUPILOT_DISABLE_WATCHDOG}>:"--disable-watchdog">)
38
set(WAF_ENABLE_DDS $<$<BOOL:${ARDUPILOT_ENABLE_DDS}>:"--enable-dds">)
39
set(WAF_ENABLE_NETWORKING_TESTS $<$<BOOL:${ARDUPILOT_ENABLE_NETWORKING_TESTS}>:"--enable-networking-tests">)
40
set(WAF_ENABLE_PPP $<$<BOOL:${ARDUPILOT_ENABLE_PPP}>:"--enable-PPP">)
41
42
add_custom_target(ardupilot_configure ALL
43
${WAF_COMMAND} configure --board sitl
44
${WAF_CONFIG}
45
${WAF_DISABLE_NETWORKING}
46
${WAF_DISABLE_SCRIPTING}
47
${WAF_DISABLE_WATCHDOG}
48
${WAF_ENABLE_DDS}
49
${WAF_ENABLE_NETWORKING_TESTS}
50
${WAF_ENABLE_PPP}
51
${ARDUPILOT_WAF_CONFIGURE_ARGS}
52
WORKING_DIRECTORY ${ARDUPILOT_ROOT}
53
)
54
55
add_custom_target(ardupilot_build ALL
56
${WAF_COMMAND} build --enable-dds ${WAF_CONFIG} ${ARDUPILOT_WAF_BUILD_ARGS}
57
WORKING_DIRECTORY ${ARDUPILOT_ROOT}
58
)
59
add_dependencies(ardupilot_build ardupilot_configure)
60
61
# --------------------------------------------------------------------------- #
62
# Install.
63
64
# Install executables.
65
install(PROGRAMS
66
${ARDUPILOT_ROOT}/build/sitl/bin/antennatracker
67
${ARDUPILOT_ROOT}/build/sitl/bin/arducopter
68
${ARDUPILOT_ROOT}/build/sitl/bin/arducopter-heli
69
${ARDUPILOT_ROOT}/build/sitl/bin/arduplane
70
${ARDUPILOT_ROOT}/build/sitl/bin/ardurover
71
${ARDUPILOT_ROOT}/build/sitl/bin/ardusub
72
${ARDUPILOT_ROOT}/build/sitl/bin/blimp
73
DESTINATION bin/
74
)
75
76
# Install libs.
77
install(DIRECTORY
78
${ARDUPILOT_ROOT}/build/sitl/lib
79
DESTINATION ./
80
)
81
82
# Install launch files.
83
install(DIRECTORY
84
launch
85
DESTINATION share/${PROJECT_NAME}/
86
)
87
88
# Install additional default params.
89
install(DIRECTORY
90
config/default_params
91
DESTINATION share/${PROJECT_NAME}/config
92
)
93
94
# Install autotest default params.
95
install(DIRECTORY
96
${ARDUPILOT_ROOT}/Tools/autotest/default_params
97
DESTINATION share/${PROJECT_NAME}/config/
98
)
99
100
# Install additional autotest model params.
101
install(DIRECTORY
102
${ARDUPILOT_ROOT}/Tools/autotest/models
103
DESTINATION share/${PROJECT_NAME}/config/
104
)
105
106
# Install Python package.
107
ament_python_install_package(${PROJECT_NAME}
108
PACKAGE_DIR src/${PROJECT_NAME}
109
)
110
111
# --------------------------------------------------------------------------- #
112
# build tests
113
114
if(BUILD_TESTING)
115
# Add linters.
116
find_package(ament_lint_auto REQUIRED)
117
ament_lint_auto_find_test_dependencies()
118
119
# Add python tests.
120
find_package(ament_cmake_pytest REQUIRED)
121
set(_pytest_tests
122
# Add tests here, for example:
123
# tests/test_a.py
124
)
125
foreach(_test_path ${_pytest_tests})
126
get_filename_component(_test_name ${_test_path} NAME_WE)
127
ament_add_pytest_test(${_test_name} ${_test_path}
128
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
129
TIMEOUT 60
130
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
131
)
132
endforeach()
133
endif()
134
135
# --------------------------------------------------------------------------- #
136
# Call last.
137
138
ament_package()
139
140