forked from francoisferland/meka_omnibase_control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·189 lines (158 loc) · 6.36 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
###############################################################################
# States that CMake required version must be greater than 2.8
cmake_minimum_required(VERSION 2.8)
###############################################################################
# Project name is not mandatory, but you should use it
project(meka_omnibase_control)
###############################################################################
# Set the PROJECT_ROOT variable
set(PROJECT_ROOT ${PROJECT_SOURCE_DIR})
###############################################################################
# Set where to find the FindXXX.cmake
set(CMAKE_MODULE_PATH "${PROJECT_ROOT}/cmake/Modules/" $ENV{M3_CMAKE_MODULES} ${CMAKE_MODULE_PATH})
###############################################################################
# Set all bunch of usefull variables
set(PROJECT_INCLUDE_DIR ${PROJECT_ROOT}/include)
set(PROJECT_PROTO_DIR ${PROJECT_ROOT}/proto)
set(PROJECT_SRC_DIR ${PROJECT_ROOT}/src)
set(PROJECT_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_ROOT}/bin)
set(PROJECT_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_ROOT}/lib)
set(PROJECT_PYTHON_DIR ${PROJECT_ROOT}/python)
# Forcing the generation dirs to be local
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_LIBRARY_OUTPUT_DIRECTORY})
###############################################################################
# Find catkin
find_package(catkin REQUIRED COMPONENTS
roscpp
controller_manager
hardware_interface
controller_interface
control_toolbox
realtime_tools
m3meka_msgs
nav_msgs
actionlib
actionlib_msgs
message_generation
tf
)
if(catkin_FOUND)
# catkin_python_setup()
else(catkin_FOUND)
endif(catkin_FOUND)
set(LIBRARIES ${LIBRARIES} ${catkin_LIBRARIES})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
###############################################################################
# Find M3
find_package(M3 COMPONENTS HARDWARE CHAINS TOOLBOX VEHICLES REQUIRED)
set(LIBRARIES ${LIBRARIES} ${M3_LIBRARIES})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${M3_INCLUDE_DIR})
###############################################################################
# Find M3RT
find_package(M3rt REQUIRED)
set(LIBRARIES ${LIBRARIES} ${M3RT_LIBRARIES})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${M3RT_INCLUDE_DIR})
###############################################################################
# Find google protobuff
find_package(Protobuf REQUIRED)
set(PROTOBUF_IMPORT_DIRS ${INCLUDE_DIRS} ${M3RT_INCLUDE_DIR} ${M3_INCLUDE_DIR})
file(GLOB ProtoFiles "${PROJECT_PROTO_DIR}/*.proto")
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${CMAKE_CURRENT_BINARY_DIR} ${ProtoFiles})
set_source_files_properties(${ProtoSources} ${ProtoHeaders} PROPERTIES
GENERATED TRUE)
add_custom_target(${PROJECT_NAME}_cpp_protobuf_output ALL DEPENDS ${ProtoSources}) # Force the re-generation c++
PROTOBUF_GENERATE_PYTHON(PySources ${PROJECT_PYTHON_DIR} ${ProtoFiles})
add_custom_target(${PROJECT_NAME}_python_protobuf_output ALL DEPENDS ${PySources}) # Force the re-generation python
set(LIBRARIES ${LIBRARIES} ${PROTOBUF_LIBRARIES})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIR})
###############################################################################
# Find Eigen
find_package(Eigen3 REQUIRED)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
###############################################################################
# Find boost packages
find_package(Boost 1.34 COMPONENTS filesystem system serialization REQUIRED)
set(LIBRARIES ${LIBRARIES} ${Boost_LIBRARIES})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
###############################################################################
# Find Yamlcpp
find_package(PkgConfig REQUIRED)
pkg_check_modules(YAMLCPP REQUIRED yaml-cpp)
if(NOT ${YAMLCPP_VERSION} VERSION_LESS "0.5")
find_package(YamlCpp REQUIRED)
set_property(
DIRECTORY
PROPERTY COMPILE_DEFINITIONS YAMLCPP_05
)
endif(NOT ${YAMLCPP_VERSION} VERSION_LESS "0.5")
link_directories(${YAMLCPP_LIBRARY_DIRS})
###############################################################################
# other
set(LIBRARIES ${LIBRARIES} omni_kinematics pthread)
###############################################################################
# Include directories
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src # For Protobuf-generated files.
${PROJECT_ROOT}/include
${PROJECT_ROOT}/omni_kinematics/include
${INCLUDE_DIRS}
${ProtoHeaders}
${M3_SRC} # HACK : Include this 4 directories for the generated protobufs headers from m3core
${M3RT_SRC}
${CMAKE_BINARY_DIR}/m3core/src
${CMAKE_BINARY_DIR}/m3core/src/m3rt/base
)
set(ALL_SRCS
src/caster_control.cpp
src/meka_omnibase_control.cpp
src/factory_proxy.cpp
)
set(ALL_HDRS
include/meka_omnibase_control/caster_control.hpp
include/meka_omnibase_control/meka_omnibase_control.hpp
)
list(APPEND ALL_SRCS
${ProtoSources}
)
list(APPEND ALL_HDRS
${ProtoHeaders}
${ProtoFiles}
)
###############################################################################
## Building
set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
# This enables writing the state of the base directly to the server output:
add_definitions(-DDEBUG_OUTPUT=0)
add_subdirectory(omni_kinematics)
add_subdirectory(python)
add_library(${PROJECT_NAME} SHARED ${ALL_SRCS})
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})
set_target_properties(${PROJECT_NAME} PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
## Installing
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES ${ALL_HDRS} DESTINATION include/m3/${PROJECT_NAME})
execute_process (
COMMAND ${PYTHON_EXECUTABLE} -c
"import site, sys; sys.stdout.write(site.PREFIXES[-1])"
OUTPUT_VARIABLE PYTHON_PREFIX
)
file ( TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX )
execute_process (
COMMAND ${PYTHON_EXECUTABLE} -c
"import site, sys; sys.stdout.write(site.getsitepackages()[-1])"
OUTPUT_VARIABLE PYTHON_SITE_DIR
)
file ( TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR )
string ( REGEX REPLACE "^${PYTHON_PREFIX}/" ""
PYTHON_SITE_DIR "${PYTHON_SITE_DIR}"
)
install ( FILES ${PySources}
DESTINATION ${PYTHON_SITE_DIR}/m3
COMPONENT library
)