forked from mavlink/mavros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
111 lines (90 loc) · 3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
cmake_minimum_required(VERSION 3.5)
project(libmavconn)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# we dont use add_compile_options with pedantic in message packages
# because the Python C extensions dont comply with it
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()
find_package(ament_cmake REQUIRED)
# add package modules path, not needed in dependend packages
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
## System dependencies are found with CMake's conventions
find_package(console_bridge REQUIRED)
find_package(ASIO REQUIRED)
find_package(mavlink REQUIRED)
include(em_expand)
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}/generated/include
${ASIO_INCLUDE_DIRS}
${mavlink_INCLUDE_DIRS}
${console_bridge_INCLUDE_DIRS}
)
## Declare a cpp library
add_library(mavconn SHARED
${CMAKE_CURRENT_BINARY_DIR}/generated/src/mavlink_helpers.cpp
src/interface.cpp
src/serial.cpp
src/tcp.cpp
src/udp.cpp
)
ament_target_dependencies(mavconn
"console_bridge"
)
# Use em_expand macros to generate source files
em_expand(${CMAKE_CURRENT_SOURCE_DIR}/mavlink.context.py.in
${CMAKE_CURRENT_BINARY_DIR}/generated/mavlink.context.py
${CMAKE_CURRENT_SOURCE_DIR}/include/mavconn/mavlink_dialect.hpp.em
${CMAKE_CURRENT_BINARY_DIR}/generated/include/mavconn/mavlink_dialect.hpp)
em_expand(${CMAKE_CURRENT_SOURCE_DIR}/mavlink.context.py.in
${CMAKE_CURRENT_BINARY_DIR}/generated/mavlink.context.py
${CMAKE_CURRENT_SOURCE_DIR}/src/mavlink_helpers.cpp.em
${CMAKE_CURRENT_BINARY_DIR}/generated/src/mavlink_helpers.cpp)
message(STATUS "Copy mavlink_dialect.hpp to source tree")
file(
COPY ${CMAKE_CURRENT_BINARY_DIR}/generated/include/mavconn/mavlink_dialect.hpp
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include/mavconn/
)
install(TARGETS mavconn
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/
DESTINATION include
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated/include/mavconn/
DESTINATION include/mavconn
FILES_MATCHING PATTERN "*.hpp"
)
install(DIRECTORY cmake
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(ament_lint_auto REQUIRED)
# NOTE(vooon): Does not support our custom triple-license, tiered to make it to work.
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright)
ament_lint_auto_find_test_dependencies()
ament_add_gtest(test_mavconn test/test_mavconn.cpp)
target_link_libraries(test_mavconn mavconn)
ament_target_dependencies(test_mavconn
"console_bridge"
)
endif()
ament_export_dependencies(console_bridge)
ament_export_include_directories(include)
ament_export_libraries(mavconn)
#ament_export_targets(mavconn)
ament_package(
CONFIG_EXTRAS "libmavconn-extras.cmake"
)
# vim: ts=2 sw=2 et: