CMakeLists.txt 9.62 KB
Newer Older
Francois Bleibel's avatar
Francois Bleibel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#
#  Copyright
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

SET(PROJECT_NAME sot-dynamic)
project(${PROJECT_NAME})

SET(PROJECT_VERSION 1.0)

SET(CMAKE_VERBOSE_MAKEFILE true)

Francois Bleibel's avatar
Francois Bleibel committed
14
15
enable_testing()

Francois Bleibel's avatar
Francois Bleibel committed
16
17
18
19
20
21
22
23
24
25
26
27
IF(WIN32)
  SET(LIBDIR_KW "/LIBPATH:")
  SET(LIBINCL_KW "")
  SET(LIB_EXT ".lib")
ENDIF(WIN32)

IF(UNIX)
  SET(LIBDIR_KW "-L")
  SET(LIBINCL_KW "-l")
  SET(LIB_EXT "")
ENDIF(UNIX)

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -------------------------------------------------------------------
# --- UTILS ---------------------------------------------------------
# -------------------------------------------------------------------
MACRO(LIST2STRING _VAR_ARG _LIST_ARG)
  SET(${_VAR_ARG})
  SET(_FIRST_STEP 1)
  FOREACH(_ITEM ${ARGV})
     IF(_FIRST_STEP)
	SET(_FIRST_STEP 0)
     ELSE(_FIRST_STEP)
           SET (${_VAR_ARG} "${${_VAR_ARG}} ${_ITEM}")
     ENDIF(_FIRST_STEP)
  ENDFOREACH(_ITEM)
ENDMACRO(LIST2STRING)

Francois Bleibel's avatar
Francois Bleibel committed
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
#
# Look for dependencies
#

# Load Pkgconfig macros
INCLUDE(FindPkgConfig)
SET(PACKAGE_REQUIREMENTS "")

#
#  Dependency to package dynamicsJRLJapan
#
SET(DYNAMICSJRLJAPAN_FOUND 0)
SET(DYNAMICSJRLJAPAN_REQUIRED "dynamicsJRLJapan >= 1.16.1")
PKG_CHECK_MODULES(DYNAMICSJRLJAPAN REQUIRED ${DYNAMICSJRLJAPAN_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir dynamicsJRLJapan
  OUTPUT_VARIABLE DYNAMICSJRLJAPAN_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "DYNAMICSJRLJAPAN_DOCDIR=${DYNAMICSJRLJAPAN_DOCDIR}")
SET(DYNAMICSJRLJAPAN_FOUND 1)

IF(NOT ${DYNAMICSJRLJAPAN_FOUND})
  MESSAGE(FATAL_ERROR "Check that package dynamicsJRLJapan is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${DYNAMICSJRLJAPAN_FOUND})
  
IF(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS ${DYNAMICSJRLJAPAN_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${DYNAMICSJRLJAPAN_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")

73
# --- HRP2DYNAMICS ---------------------------------------
74
75
SET(HRP2DYNAMICS_FOUND 0)
SET(HRP2DYNAMICS_REQUIRED "hrp2Dynamics >= 1.3.0")
76
PKG_CHECK_MODULES(HRP2DYNAMICS REQUIRED ${HRP2DYNAMICS_REQUIRED})
77

78
IF(${HRP2DYNAMICS_FOUND})
79
SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${HRP2DYNAMICS_REQUIRED}")
80
#  MESSAGE(FATAL_ERROR "Check that package hrp2Dynamics is installed in a directory pointed out by PKG_CONFIG_PATH.")
81
82
MESSAGE(STATUS "h2D libs are '${HRP2DYNAMICS_LIBRARIES}'")
ENDIF(${HRP2DYNAMICS_FOUND})
83
84
85
86

# --- HRP2-10-Optimized ---------------------------------------
SET(_hrp210optimized_FOUND 0)
SET(_hrp210optimized_REQUIRED "hrp2-10-optimized >= 1.0")
87
#PKG_CHECK_MODULES(HRP2DYNAMICS REQUIRED ${HRP2DYNAMICS_REQUIRED})
88
89
90
PKG_CHECK_MODULES(_hrp210optimized ${_hrp210optimized_REQUIRED})

IF(${_hrp210optimized_FOUND})
91
SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${_hrp210optimized_REQUIRED}")
92
93
94
95
96
97
98
99
100
101
102
#  MESSAGE(FATAL_ERROR "Check that package hrp2Dynamics is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(${_hrp210optimized_FOUND})

# --- Robots ---------------------------------------

SET(_hrp2_10_small_FOUND 0)
SET(_hrp2_10_small_package "hrp2_10-small")
PKG_CHECK_MODULES(_hrp2_10_small ${_hrp2_10_small_package})
IF(NOT ${_hrp2_10_small_FOUND})
  MESSAGE(STATUS "hrp2_10_small not found.")
ELSE(NOT ${_hrp2_10_small_FOUND})
103
  EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS hrp2_10-small --variable=datadir
104
105
106
107
108
109
110
111
112
113
    OUTPUT_VARIABLE HRP2_10-SMALL_DIRECTORY )  
  MESSAGE(STATUS "HRP2_10-SMALL_DIRECTORY: ${HRP2_10-SMALL_DIRECTORY}") 
ENDIF(NOT ${_hrp2_10_small_FOUND})

SET(_hrp2_10_small_old_FOUND 0)
SET(_hrp2_10_small_old_package "hrp2_10-small-old")
PKG_CHECK_MODULES(_hrp2_10_small_old ${_hrp2_10_small_old_package})
IF(NOT ${_hrp2_10_small_old_FOUND})
  MESSAGE(STATUS "hrp2_10_small_old not found.")
ELSE(NOT ${_hrp2_10_small_old_FOUND})
114
  EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS hrp2_10-small-old --variable=datadir
115
116
117
118
119
120
121
122
123
124
125
    OUTPUT_VARIABLE HRP2_10-SMALL-OLD_DIRECTORY )  
  MESSAGE(STATUS "HRP2_10-SMALL-OLD_DIRECTORY: ${HRP2_10-SMALL-OLD_DIRECTORY}") 
ENDIF(NOT ${_hrp2_10_small_old_FOUND})


SET(_hrp2_10_FOUND 0)
SET(_hrp2_10_package "hrp2_10")
PKG_CHECK_MODULES(_hrp2_10 ${_hrp2_10_package})
IF(NOT ${_hrp2_10_FOUND})
  MESSAGE(STATUS "hrp2_10 not found.")
ELSE(NOT ${_hrp2_10_FOUND})
126
  EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS hrp2_10 --variable=datadir
127
128
129
    OUTPUT_VARIABLE HRP2_10_DIRECTORY )  
  MESSAGE(STATUS "HRP2_10_DIRECTORY: ${HRP2_10_DIRECTORY}") 
ENDIF(NOT ${_hrp2_10_FOUND})
Francois Bleibel's avatar
Francois Bleibel committed
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

#
#  Dependency to package dynamic-graph
#
SET(DYNAMIC_GRAPH_FOUND 0)
SET(DYNAMIC_GRAPH_REQUIRED "dynamic-graph >= 1.0")
PKG_CHECK_MODULES(DYNAMIC_GRAPH REQUIRED ${DYNAMIC_GRAPH_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir dynamic-graph
  OUTPUT_VARIABLE DYNAMIC_GRAPH_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "DYNAMIC_GRAPH_DOCDIR=${DYNAMIC_GRAPH_DOCDIR}")
SET(DYNAMIC_GRAPH_FOUND 1)

IF(NOT ${DYNAMIC_GRAPH_FOUND})
  MESSAGE(FATAL_ERROR "Check that package dynamic-graph is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${DYNAMIC_GRAPH_FOUND})
  
IF(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS ${DYNAMIC_GRAPH_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${DYNAMIC_GRAPH_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")


#
#  Dependency to package sot-core
#
SET(SOT_CORE_FOUND 0)
SET(SOT_CORE_REQUIRED "sot-core >= 1.0")
PKG_CHECK_MODULES(SOT_CORE REQUIRED ${SOT_CORE_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir sot-core
  OUTPUT_VARIABLE SOT_CORE_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "SOT_CORE_DOCDIR=${SOT_CORE_DOCDIR}")
SET(SOT_CORE_FOUND 1)

IF(NOT ${SOT_CORE_FOUND})
  MESSAGE(FATAL_ERROR "Check that package sot-core is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${SOT_CORE_FOUND})
  
IF(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS ${SOT_CORE_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${SOT_CORE_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")


#
#  Dependency to package MatrixAbstractLayer
#
SET(MATRIXABSTRACTLAYER_FOUND 0)
SET(MATRIXABSTRACTLAYER_REQUIRED "MatrixAbstractLayer >= 1.8.0")
PKG_CHECK_MODULES(MATRIXABSTRACTLAYER REQUIRED ${MATRIXABSTRACTLAYER_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir MatrixAbstractLayer
  OUTPUT_VARIABLE MATRIXABSTRACTLAYER_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "MATRIXABSTRACTLAYER_DOCDIR=${MATRIXABSTRACTLAYER_DOCDIR}")
SET(MATRIXABSTRACTLAYER_FOUND 1)

IF(NOT ${MATRIXABSTRACTLAYER_FOUND})
  MESSAGE(FATAL_ERROR "Check that package MatrixAbstractLayer is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${MATRIXABSTRACTLAYER_FOUND})
  
IF(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS ${MATRIXABSTRACTLAYER_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${MATRIXABSTRACTLAYER_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")

#
# pkg-config file
#

SET(install_pkg_prefix "\${prefix}")
SET(install_pkg_exec_prefix "\${exec_prefix}")
SET(install_pkg_libdir "\${libdir}")
SET(install_pkg_datarootdir "\${datarootdir}")
SET(install_pkg_include_dir "\${includedir}")

209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# the shared libraries that will be listed in the .pc file
SET(libs
	zmpreffromcom
	force-compensation
	integrator-force-exact
	mass-apparent
	integrator-force-rk4
	integrator-force
	angle-estimator
	waist-attitude-from-sensor
)

IF(${DYNAMICSJRLJAPAN_FOUND})
  LIST(APPEND libs dynamic)
	IF(${HRP2DYNAMICS_FOUND})
	  LIST(APPEND libs dynamic-hrp2)
	  SET (dynamic-hrp2_plugins_dependencies dynamic)
	ENDIF(${HRP2DYNAMICS_FOUND})
ENDIF(${DYNAMICSJRLJAPAN_FOUND})

IF(${_hrp210optimized_FOUND})
  LIST(APPEND libs dynamic-hrp2_10)
  SET (dynamic-hrp2_10_plugins_dependencies dynamic)
  SET(dynamic-hrp2_10_plugins_compile_flags 
       ${_dynamicsJRLJapan_CFLAGS} ${_hrp210optimized_CFLAGS})
  SET(dynamic-hrp2_10_plugins_link_flags 
       ${_dynamicsJRLJapan_LDFLAGS} ${_hrp210optimized_LDFLAGS})

  LIST(APPEND libs dynamic-hrp2_10_old)
  SET (dynamic-hrp2_10_plugins_dependencies dynamic)
  SET(dynamic-hrp2_10_old_plugins_compile_flags 
       ${_dynamicsJRLJapan_CFLAGS} ${_hrp210optimized_CFLAGS})
  SET(dynamic-hrp2_10_old_plugins_link_flags 
       ${_dynamicsJRLJapan_LDFLAGS} ${_hrp210optimized_LDFLAGS})

ENDIF(${_hrp210optimized_FOUND})	

# Add libs to the .pc file
FOREACH(lib ${libs})
	SET(pc-libs "${pc-libs} ${LIBINCL_KW}${lib}${CMAKE_IMPORT_LIBRARY_SUFFIX}")
ENDFOREACH(lib)

Francois Bleibel's avatar
Francois Bleibel committed
251
IF(UNIX)
252
  SET (${PROJECT_NAME}_LDFLAGS "-Wl,-R${install_pkg_libdir} ${pc-libs} ${${PROJECT_NAME}_LDFLAGS}")
Francois Bleibel's avatar
Francois Bleibel committed
253
254
255
ENDIF(UNIX)

IF(WIN32)
256
  SET (${PROJECT_NAME}_LDFLAGS "${pc-libs}")
Francois Bleibel's avatar
Francois Bleibel committed
257
258
ENDIF(WIN32)

259

Francois Bleibel's avatar
Francois Bleibel committed
260
261
262
263
264
265
266
267
268
269
# Install the file in the appropriate place.
SET(install_libdir_pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
  DESTINATION ${install_libdir_pkgconfig}	
  PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)

Francois Bleibel's avatar
Francois Bleibel committed
270
271
272
273
274
275
276
277
278
279
# Uninstall target.
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")


280
281
282
283
IF(WIN32)
  ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4251 /wd4275 /wd4101 /wd4355")
ENDIF(WIN32)

Francois Bleibel's avatar
Francois Bleibel committed
284
285
286
287
288
289
290
291
292
293
294
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(unitTesting)

#
# Documentation produced by doxygen
#
INCLUDE(FindDoxygen)
IF(DOXYGEN_FOUND)
  add_subdirectory(doc)
ENDIF(DOXYGEN_FOUND)