-
Notifications
You must be signed in to change notification settings - Fork 912
/
CMakeLists.txt
144 lines (127 loc) · 4.73 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
cmake_minimum_required(VERSION 2.8.3)
project(roscpp)
find_package(catkin REQUIRED COMPONENTS
cpp_common message_generation rosconsole roscpp_serialization roscpp_traits rosgraph_msgs rostime std_msgs xmlrpcpp
)
catkin_package_xml()
# split version in parts and pass to extra file
string(REPLACE "." ";" roscpp_VERSION_LIST "${roscpp_VERSION}")
list(LENGTH roscpp_VERSION_LIST _count)
if(NOT _count EQUAL 3)
message(FATAL_ERROR "roscpp version '${roscpp_VERSION}' does not match 'MAJOR.MINOR.PATCH' pattern")
endif()
list(GET roscpp_VERSION_LIST 0 roscpp_VERSION_MAJOR)
list(GET roscpp_VERSION_LIST 1 roscpp_VERSION_MINOR)
list(GET roscpp_VERSION_LIST 2 roscpp_VERSION_PATCH)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/ros/common.h.in ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros/common.h)
find_package(Boost REQUIRED COMPONENTS signals filesystem system)
include_directories(include ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
add_message_files(
DIRECTORY msg
FILES Logger.msg
)
add_service_files(
DIRECTORY srv
FILES Empty.srv GetLoggers.srv SetLoggerLevel.srv
)
generate_messages()
set(PTHREAD_LIB "")
find_package(Threads)
if(CMAKE_THREAD_LIBS_INIT)
string(LENGTH ${CMAKE_THREAD_LIBS_INIT} _length)
if(_length GREATER 2)
string(SUBSTRING ${CMAKE_THREAD_LIBS_INIT} 0 2 _prefix)
if(${_prefix} STREQUAL "-l")
math(EXPR _rest_len "${_length} - 2")
string(SUBSTRING ${CMAKE_THREAD_LIBS_INIT} 2 ${_rest_len} PTHREAD_LIB)
endif()
endif()
endif()
catkin_package(
INCLUDE_DIRS include ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros
LIBRARIES roscpp ${PTHREAD_LIB}
CATKIN_DEPENDS cpp_common message_runtime rosconsole roscpp_serialization roscpp_traits rosgraph_msgs rostime std_msgs xmlrpcpp
DEPENDS Boost
)
include(CheckIncludeFiles)
include(CheckFunctionExists)
# Not everybody has <ifaddrs.h> (e.g., embedded arm-linux)
CHECK_INCLUDE_FILES(ifaddrs.h HAVE_IFADDRS_H)
# Not everybody has trunc (e.g., Windows, embedded arm-linux)
CHECK_FUNCTION_EXISTS(trunc HAVE_TRUNC)
# Output test results to config.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libros/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(roscpp
src/libros/master.cpp
src/libros/network.cpp
src/libros/subscriber.cpp
src/libros/common.cpp
src/libros/publisher_link.cpp
src/libros/service_publication.cpp
src/libros/connection.cpp
src/libros/single_subscriber_publisher.cpp
src/libros/param.cpp
src/libros/service_server.cpp
src/libros/wall_timer.cpp
src/libros/xmlrpc_manager.cpp
src/libros/publisher.cpp
src/libros/timer.cpp
src/libros/io.cpp
src/libros/names.cpp
src/libros/topic.cpp
src/libros/topic_manager.cpp
src/libros/poll_manager.cpp
src/libros/publication.cpp
src/libros/intraprocess_subscriber_link.cpp
src/libros/intraprocess_publisher_link.cpp
src/libros/callback_queue.cpp
src/libros/service_server_link.cpp
src/libros/service_client.cpp
src/libros/node_handle.cpp
src/libros/connection_manager.cpp
src/libros/file_log.cpp
src/libros/transport/transport_udp.cpp
src/libros/transport/transport_tcp.cpp
src/libros/subscriber_link.cpp
src/libros/service_client_link.cpp
src/libros/transport_publisher_link.cpp
src/libros/transport_subscriber_link.cpp
src/libros/service_manager.cpp
src/libros/rosout_appender.cpp
src/libros/init.cpp
src/libros/subscription.cpp
src/libros/subscription_queue.cpp
src/libros/spinner.cpp
src/libros/internal_timer_manager.cpp
src/libros/message_deserializer.cpp
src/libros/header.cpp
src/libros/poll_set.cpp
src/libros/service.cpp
src/libros/this_node.cpp
)
add_dependencies(roscpp roscpp_gencpp rosgraph_msgs_gencpp std_msgs_gencpp)
target_link_libraries(roscpp
${catkin_LIBRARIES}
${Boost_LIBRARIES}
)
#explicitly install library and includes
install(TARGETS roscpp
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
install(FILES ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros/common.h
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros)
# install legacy infrastructure needed by rosbuild
install(FILES rosbuild/roscpp.cmake
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/rosbuild)
install(PROGRAMS
rosbuild/scripts/genmsg_cpp.py
rosbuild/scripts/gensrv_cpp.py
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/rosbuild/scripts)
install(FILES
rosbuild/scripts/msg_gen.py
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/rosbuild/scripts)