-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
76 lines (65 loc) · 1.87 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
cmake_minimum_required(VERSION 2.8.3)
project(ros_modbus_device_driver)
# find dependencies
find_package(catkin REQUIRED
COMPONENTS
rospy
catkin_virtualenv
std_msgs
message_generation
)
# get ROS python interpreter version based on ROS_PYTHON_VERSION or ROS_DISTRO envvar
if(DEFINED ENV{ROS_PYTHON_VERSION})
set(PYTHON_VENV_INTERPRETER python$ENV{ROS_PYTHON_VERSION})
else()
message(WARNING "environment variable ROS_PYTHON_VERSION not defined! testing for ROS_DISTRO...")
# test ROS_DISTRO name
if(DEFINED ENV{ROS_DISTRO})
string(TOLOWER $ENV{ROS_DISTRO} ROS_DISTRO_NORM)
if(${ROS_DISTRO_NORM} STRLESS noetic)
set(PYTHON_VENV_INTERPRETER python2)
else()
set(PYTHON_VENV_INTERPRETER python3)
endif()
message(STATUS "assuming ${PYTHON_VENV_INTERPRETER} based on ROS distro $ENV{ROS_DISTRO}")
else()
message(FATAL_ERROR "non of environment varibales ROS_PYTHON_VERSION or ROS_DISTRO are defined! cannot identify python interpreter!")
endif()
endif()
message(STATUS "using python interpreter ${PYTHON_VENV_INTERPRETER}")
# init python environment
catkin_python_setup()
catkin_generate_virtualenv(
PYTHON_INTERPRETER ${PYTHON_VENV_INTERPRETER}
)
# add message definitions
add_message_files(
FILES
Byte.msg
Word.msg
DWord.msg
LWord.msg
)
# generate message bindings
generate_messages(
DEPENDENCIES
std_msgs
)
# init catkin package
catkin_package(CATKIN_DEPENDS message_runtime)
# catkin virtualenv package
install(FILES requirements.txt
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
catkin_install_python(PROGRAMS
scripts/modbus_device_driver.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
# install(FILES
# launch/ros_modbus_device.launch
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
# )
# if (CATKIN_ENABLE_TESTING)
# find_package(rostest REQUIRED)
# add_rostest(sometestfile.test)
# endif()