|
1 | 1 | cmake_minimum_required(VERSION 3.5)
|
2 | 2 | project(wiimote)
|
3 | 3 |
|
4 |
| -set(CMAKE_CXX_STANDARD 11) |
5 |
| -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
6 |
| - |
7 |
| -# Save the command line compile commands in the build output |
8 |
| -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) |
9 |
| -# View the makefile commands during build |
10 |
| -#set(CMAKE_VERBOSE_MAKEFILE on) |
11 |
| - |
12 |
| -# Set compile flags |
13 |
| -set(CMAKE_CXX_FLAGS "-fPIE -fPIC -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -Wformat -Wformat-security -Wall ${CMAKE_CXX_FLAGS}") |
14 |
| -# Flags executables |
15 |
| -set(CMAKE_EXE_LINKER_FLAGS "-pie -z noexecstack -z relro -z now") |
16 |
| -# Flags shared libraries |
17 |
| -set(CMAKE_SHARED_LINKER_FLAGS "-z noexecstack -z relro -z now ${CMAKE_SHARED_LINKER_FLAGS}") |
18 |
| - |
19 |
| -# Load catkin and all dependencies required for this package |
20 |
| -set(CATKIN_DEPS geometry_msgs sensor_msgs std_msgs std_srvs rospy roscpp roslib genmsg roslint) |
21 |
| -find_package(catkin REQUIRED ${CATKIN_DEPS}) |
22 |
| - |
23 |
| -catkin_python_setup() |
24 |
| - |
25 |
| -# generate the messages |
26 |
| -add_message_files( |
27 |
| - DIRECTORY msg |
28 |
| - FILES |
29 |
| - IrSourceInfo.msg |
30 |
| - State.msg |
31 |
| - TimedSwitch.msg |
32 |
| -) |
| 4 | +# Default to C99 |
| 5 | +if(NOT CMAKE_C_STANDARD) |
| 6 | + set(CMAKE_C_STANDARD 99) |
| 7 | +endif() |
| 8 | + |
| 9 | +# Default to C++14 |
| 10 | +if(NOT CMAKE_CXX_STANDARD) |
| 11 | + set(CMAKE_CXX_STANDARD 14) |
| 12 | +endif() |
| 13 | + |
| 14 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 15 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 16 | +endif() |
| 17 | + |
| 18 | +find_library(BLUETOOTH_LIB bluetooth) |
| 19 | +if(BLUETOOTH_LIB) |
| 20 | + message(STATUS "Found bluetooth library.") |
| 21 | +else() |
| 22 | + message(FATAL_ERROR "bluetooth library not found.") |
| 23 | +endif() |
| 24 | + |
| 25 | +find_library(CWIID_LIB cwiid) |
| 26 | +if(CWIID_LIB) |
| 27 | + message(STATUS "Found cwiid library.") |
| 28 | +else() |
| 29 | + message(FATAL_ERROR "cwiid library not found.") |
| 30 | +endif() |
33 | 31 |
|
34 |
| -generate_messages(DEPENDENCIES geometry_msgs std_msgs sensor_msgs) |
35 |
| - |
36 |
| -# ROS Lint the code |
37 |
| -roslint_cpp() |
38 |
| -roslint_python() |
39 |
| - |
40 |
| -################################### |
41 |
| -## catkin specific configuration ## |
42 |
| -################################### |
43 |
| -## The catkin_package macro generates cmake config files for your package |
44 |
| -## Declare things to be passed to dependent projects |
45 |
| -## INCLUDE_DIRS: uncomment this if you package contains header files |
46 |
| -## LIBRARIES: libraries you create in this project that dependent projects also need |
47 |
| -## CATKIN_DEPENDS: catkin_packages dependent projects also need |
48 |
| -## DEPENDS: system dependencies of this project that dependent projects also need |
49 |
| -catkin_package( |
50 |
| - INCLUDE_DIRS include |
51 |
| - CATKIN_DEPENDS |
52 |
| - geometry_msgs |
53 |
| - sensor_msgs |
54 |
| - std_msgs |
55 |
| - std_srvs |
| 32 | + |
| 33 | +find_package(ament_cmake REQUIRED) |
| 34 | +find_package(ament_cmake_auto REQUIRED) |
| 35 | + |
| 36 | +ament_auto_find_build_dependencies( |
| 37 | + REQUIRED |
| 38 | + rclcpp |
| 39 | + rclcpp_components |
| 40 | + rclcpp_lifecycle |
| 41 | + sensor_msgs |
| 42 | + std_srvs |
| 43 | + wiimote_msgs |
56 | 44 | )
|
57 | 45 |
|
58 |
| -## Specify additional locations of header files |
59 |
| -include_directories( |
60 |
| - include |
61 |
| - ${catkin_INCLUDE_DIRS} |
| 46 | +## C++ Wiimote Lib |
| 47 | +set(wiimote_lib_HEADERS |
| 48 | + include/wiimote/wiimote_controller.hpp |
| 49 | + include/wiimote/stat_vector_3d.hpp) |
| 50 | + |
| 51 | +set(wiimote_lib_SOURCES |
| 52 | + src/wiimote_controller.cpp |
| 53 | + src/stat_vector_3d.cpp) |
| 54 | + |
| 55 | +ament_auto_add_library(wiimote_lib SHARED ${wiimote_lib_HEADERS} ${wiimote_lib_SOURCES}) |
| 56 | +target_link_libraries(wiimote_lib bluetooth cwiid) |
| 57 | + |
| 58 | +rclcpp_components_register_node( |
| 59 | + wiimote_lib |
| 60 | + PLUGIN "WiimoteNode" |
| 61 | + EXECUTABLE wiimote_node |
62 | 62 | )
|
| 63 | +## End C++ Wiimote Lib |
63 | 64 |
|
64 |
| -## C++ Wiimote Node: Declare cpp executables |
65 |
| -add_executable(wiimote_node src/wiimote_controller.cpp src/stat_vector_3d.cpp) |
66 |
| -target_link_libraries(wiimote_node ${catkin_LIBRARIES} bluetooth cwiid) |
67 |
| -add_dependencies(wiimote_node wiimote_generate_messages_cpp) |
68 |
| -## End of C++ Wiimote Node |
| 65 | +# C++ Teleop for Wiimote Node: Declare cpp executables |
| 66 | +set(teleop_wiimote_HEADERS include/wiimote/teleop_wiimote.hpp) |
| 67 | +set(teleop_wiimote_SOURCES src/teleop_wiimote.cpp) |
| 68 | +ament_auto_add_library(teleop_wiimote SHARED ${teleop_wiimote_HEADERS} ${teleop_wiimote_SOURCES}) |
69 | 69 |
|
70 |
| -## C++ Teleop for Wiimote Node: Declare cpp executables |
71 |
| -add_executable(teleop_wiimote src/teleop_wiimote.cpp) |
72 |
| -target_link_libraries(teleop_wiimote ${catkin_LIBRARIES}) |
73 |
| -add_dependencies(teleop_wiimote wiimote_generate_messages_cpp) |
74 |
| -## End C++ Teleop for Wiimote Node |
| 70 | +rclcpp_components_register_node( |
| 71 | + teleop_wiimote |
| 72 | + PLUGIN "TeleopWiimote" |
| 73 | + EXECUTABLE teleop_wiimote_node |
| 74 | +) |
| 75 | +# End C++ Teleop for Wiimote Node |
75 | 76 |
|
76 |
| -if(CATKIN_ENABLE_TESTING) |
77 |
| - roslint_add_test() |
| 77 | +if(BUILD_TESTING) |
| 78 | + find_package(ament_lint_auto REQUIRED) |
| 79 | + ament_lint_auto_find_test_dependencies() |
78 | 80 | endif()
|
79 | 81 |
|
80 |
| -# Install launch files |
81 |
| -install(DIRECTORY launch/ |
82 |
| - DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch |
83 |
| -) |
| 82 | +# Install lib |
| 83 | +install(TARGETS wiimote_lib teleop_wiimote |
| 84 | + ARCHIVE DESTINATION lib |
| 85 | + LIBRARY DESTINATION lib |
| 86 | + RUNTIME DESTINATION bin) |
| 87 | +install(DIRECTORY include/ DESTINATION include) |
| 88 | + |
| 89 | +# Install launch and config files |
| 90 | +install(DIRECTORY launch config |
| 91 | + DESTINATION share/${PROJECT_NAME}) |
84 | 92 |
|
85 |
| -# Install targets |
86 |
| -install(PROGRAMS nodes/feedbackTester.py nodes/wiimote_node.py |
87 |
| - DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} |
88 |
| - ) |
89 |
| -## Mark executables and/or libraries for installation |
| 93 | +# Install Executables |
90 | 94 | install(TARGETS wiimote_node
|
91 |
| - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
92 |
| - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
93 |
| - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} |
| 95 | + DESTINATION lib/${PROJECT_NAME}) |
| 96 | + |
| 97 | +install(PROGRAMS nodes/feedback_tester.py |
| 98 | + DESTINATION lib/${PROJECT_NAME} |
94 | 99 | )
|
| 100 | + |
| 101 | +ament_package() |
0 commit comments