forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.cmake
387 lines (326 loc) · 13.6 KB
/
options.cmake
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
include(CMakeDependentOption)
#------------------------------------------------------------------------------
# Add an option with optional dependencies.
#
# Arguments:
# <DEFAULT_STATE> - Is the option enabled by default? (`ON` or `OFF`)
#
# DEPENDS <expression>
# A list of expressions which must evaluate to true for the component to
# be made available. (Otherwise, the component will not be enabled, and the
# option for the component will be hidden.)
#
# Extra arguments are combined (with a single space) to form the description of
# the option. A ';' appearing in the description text should be escaped to
# prevent it being seen as an argument separator.
#
# This creates an option <NAME>, which may be either a dependent option or an
# unconditional option.
#------------------------------------------------------------------------------
function(drake_option NAME DEFAULT_STATE)
# "Fix" escaping so cmake_parse_arguments will split properly (note:
# cmake_parse_arguments splits twice, so escape two more levels).
string(REPLACE "\\;" "\\\\\\;" _args "${ARGN}")
# Parse arguments.
cmake_parse_arguments(_opt "" "DEPENDS" "" ${_args})
# Join description snippets.
set(_description)
foreach(_snippet IN LISTS _opt_UNPARSED_ARGUMENTS)
set(_description "${_description} ${_snippet}")
endforeach()
string(STRIP "${_description}" _description)
# Create option.
if(DEFINED _opt_DEPENDS)
string(REPLACE "\\;" ";" _opt_DEPENDS "${_opt_DEPENDS}")
cmake_dependent_option(${NAME}
"${_description}"
${DEFAULT_STATE}
"${_opt_DEPENDS}" OFF)
else()
option(${NAME} "${_description}" ${DEFAULT_STATE})
endif()
# Propagate option value to caller.
set(${NAME} "${${NAME}}" PARENT_SCOPE)
endfunction()
#------------------------------------------------------------------------------
# Add an option whether to use the system or internal version of a dependency.
#
# Arguments:
# OPTIONAL - Dependency is not required.
#
# PREFER_SYSTEM_VERSION
# Default to using the system version of the dependency rather than the
# internal version.
#
# REQUIRES <package>
# Name of package (as passed to `find_package`) that must be found if the
# system version is selected.
#
# VERSION <version>
# Required version of the system package (passed to `find_package`).
#
# ADDITIONAL_VERSIONS <version>
# Versions of the system package to be accepted in addition to the named
# VERSION.
#
# DEPENDS <expression>
# A list of expressions which must evaluate to true for the component to
# be made available. (Otherwise, the component will not be enabled, and the
# option for the component will be hidden.)
#
# Extra arguments are combined (with a single space) to form the description of
# the option. A ';' appearing in the description text should be escaped to
# prevent it being seen as an argument separator.
#
# This creates an option USE_SYSTEM_<NAME> that selects if the system version
# of the dependency will be used. If the component is required, and the system
# version is not selected, the internal version will be enabled. Otherwise, the
# user will be given an option (WITH_<NAME>, defaulting to ON) if the component
# should be built.
#
# Internally, this sets HAVE_<NAME> to indicate if the external is available,
# and WITH_<NAME> to indicate if our internal version of the external should be
# built.
#------------------------------------------------------------------------------
function(drake_system_dependency NAME)
# "Fix" escaping so cmake_parse_arguments will split properly (note:
# cmake_parse_arguments splits twice, so escape two more levels).
string(REPLACE "\\;" "\\\\\\;" _args "${ARGN}")
# Parse arguments
cmake_parse_arguments("_sd"
"OPTIONAL;PREFER_SYSTEM_VERSION;--"
"REQUIRES;VERSION;DEPENDS"
"ADDITIONAL_VERSIONS"
${_args})
# Check for required arguments.
if(NOT DEFINED _sd_REQUIRES)
message(FATAL_ERROR "drake_system_dependency: REQUIRES must be specified")
endif()
# Fix up arguments
if(_sd_OPTIONAL)
set(_else)
else()
set(_else "(if OFF, the internal version will be used)")
endif()
if(DEFINED _sd_DEPENDS)
set(_sd_DEPENDS DEPENDS "${_sd_DEPENDS}")
endif()
if(_sd_PREFER_SYSTEM_VERSION)
set(_default ON)
else()
set(_default OFF)
endif()
# Create option for using system version of external.
drake_option(USE_SYSTEM_${NAME} ${_default}
"${_sd_DEPENDS}"
"Use the system-provided"
"${_sd_UNPARSED_ARGUMENTS}"
"${_else}"
)
set(HAVE_${NAME} FALSE PARENT_SCOPE)
# Handle optional dependencies.
if(_sd_OPTIONAL)
# Set option dependencies so option to build internal version is only shown
# if system version is not selected.
if(NOT DEFINED _sd_DEPENDS)
set(_sd_DEPENDS DEPENDS "NOT USE_SYSTEM_${NAME}")
else()
set(_sd_DEPENDS "${_sd_DEPENDS}\;NOT USE_SYSTEM_${NAME}")
endif()
# Add option to build internal version.
drake_option(WITH_${NAME} ON
"${_sd_DEPENDS}"
"${_sd_UNPARSED_ARGUMENTS}")
set(WITH_${NAME} "${WITH_${NAME}}" PARENT_SCOPE)
set(HAVE_${NAME} "${WITH_${NAME}}" PARENT_SCOPE)
else()
# Internally, externals use WITH_<NAME> to decide if an external is enabled,
# so map the option value to that name.
if(USE_SYSTEM_${NAME})
set(WITH_${NAME} OFF PARENT_SCOPE)
else()
set(WITH_${NAME} ON PARENT_SCOPE)
endif()
endif()
# If using system version, ensure it is available.
if(USE_SYSTEM_${NAME})
set(_user_dir "${${NAME}_DIR}")
foreach(_version ${_sd_ADDITIONAL_VERSIONS})
find_package(${_sd_REQUIRES} ${_version} QUIET)
if(${NAME}_FOUND)
set(HAVE_${NAME} TRUE PARENT_SCOPE)
return()
endif()
set(${NAME}_DIR "${_user_dir}" CACHE PATH
"The directory containing a CMake configuration file for ${NAME}."
FORCE)
endforeach()
find_package(${_sd_REQUIRES} ${_sd_VERSION} REQUIRED)
set(HAVE_${NAME} TRUE PARENT_SCOPE)
endif()
endfunction()
#------------------------------------------------------------------------------
# Add an option whether or not to build an optional component.
#
# The arguments are the same as drake_option. The option will be named
# WITH_<NAME>. HAVE_<NAME> will reflect if the external is available.
#------------------------------------------------------------------------------
function(drake_optional_external NAME DEFAULT_STATE)
# Re-escape ARGN so drake_option will receive ARGN split the same way.
string(REPLACE "\\;" "\\\\;" _args "${ARGN}")
# Create option and make corresponding variables available to caller.
drake_option(WITH_${NAME} ${DEFAULT_STATE} ${_args})
set(WITH_${NAME} "${WITH_${NAME}}" PARENT_SCOPE)
set(HAVE_${NAME} "${WITH_${NAME}}" PARENT_SCOPE)
endfunction()
#------------------------------------------------------------------------------
# Set internal flag indicating whether or not to build an optional component.
#
# This sets the variables WITH_<NAME> and HAVE_<NAME>, indicating if the
# specified external is available and will be built. These will be true iff
# <WHEN> is also true.
#------------------------------------------------------------------------------
function(drake_dependent_external NAME WHEN)
string(REPLACE " " ";" WHEN "${WHEN}") # Force splitting
if(${WHEN})
set(_value ON)
else()
set(_value OFF)
endif()
set(WITH_${NAME} "${_value}" PARENT_SCOPE)
set(HAVE_${NAME} "${_value}" PARENT_SCOPE)
endfunction()
#------------------------------------------------------------------------------
# Set up options
#------------------------------------------------------------------------------
macro(drake_setup_options)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN "system" dependencies
# These are packages that we can build, but which we allow the user to use
# their own copy (usually provided by the system) if preferred. Some of these
# may be required.
drake_system_dependency(
EIGEN REQUIRES Eigen3 VERSION 3.2.92
"Eigen C++ matrix library")
drake_system_dependency(
GOOGLETEST REQUIRES GTest
"Google testing framework")
drake_system_dependency(
GFLAGS REQUIRES gflags
"Google command-line flags processing library")
drake_system_dependency(
PYBIND11 OPTIONAL REQUIRES pybind11
DEPENDS "NOT DISABLE_PYTHON"
"Python/C++11 interoperability tool")
drake_system_dependency(
LCM OPTIONAL REQUIRES lcm
"Lightweight Communications and Marshaling IPC suite")
drake_system_dependency(
BOT_CORE_LCMTYPES OPTIONAL REQUIRES bot2-core
DEPENDS "HAVE_LCM"
"libbot2 robotics suite LCM types")
drake_system_dependency(
PROTOBUF REQUIRES Protobuf
"Google protocol buffers")
drake_system_dependency(
ROBOTLOCOMOTION_LCMTYPES OPTIONAL REQUIRES robotlocomotion-lcmtypes
DEPENDS "HAVE_BOT_CORE_LCMTYPES"
"robotlocomotion LCM types")
drake_system_dependency(
VTK OPTIONAL PREFER_SYSTEM_VERSION REQUIRES VTK VERSION 5.10
ADDITIONAL_VERSIONS 5.8 7.1 8.0 --
"Visualization ToolKit")
drake_system_dependency(
TINYOBJLOADER REQUIRES tinyobjloader
"library for reading wavefront mesh files")
drake_system_dependency(YAML_CPP OPTIONAL REQUIRES yaml-cpp
"C++ library for reading and writing YAML configuration files")
# END "system" dependencies
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN external projects that are ON by default
drake_optional_external(BULLET ON "Bullet library for collision detection")
drake_optional_external(CCD ON "Convex shape Collision Detection library")
drake_optional_external(DIRECTOR ON
DEPENDS "HAVE_VTK\;HAVE_LCM\;HAVE_BOT_CORE_LCMTYPES\;NOT DISABLE_PYTHON"
"VTK-based visualization tool and robot user interface")
drake_optional_external(GOOGLE_STYLEGUIDE ON
DEPENDS "NOT DISABLE_PYTHON"
"Google code style tools for cpplint.py style checking" ON)
# IPOPT is currently disabled on Mac when MATLAB is enabled due to MATLAB
# compatibility issues:
# https://github.com/RobotLocomotion/drake/issues/2578
drake_optional_external(IPOPT ON
DEPENDS "NOT APPLE OR NOT Matlab_FOUND\;NOT DISABLE_FORTRAN"
"Interior Point Optimizer, for solving non-linear optimizations")
drake_optional_external(IGNITION_MATH ON
"Math classes and functions for robot applications")
drake_optional_external(IGNITION_RNDF ON
DEPENDS "WITH_IGNITION_MATH"
"Classes and functions for parsing RNDF road networks")
drake_optional_external(LIBBOT ON
DEPENDS "NOT USE_SANITIZER"
"libbot2 robotics suite\;"
"used for its simple open-gl visualizer + lcmgl for director")
drake_optional_external(NLOPT ON "Non-linear optimization solver")
drake_optional_external(OCTOMAP ON
"3D occupancy mapping library\; provides oct-tree data structures")
# Needs to be below ccd and octomap.
drake_optional_external(FCL ON
DEPENDS "WITH_CCD\;WITH_OCTOMAP"
"Flexible collision detection library")
drake_optional_external(SPDLOG ON
"Fast C++ text logging facility\; disabling will turn off text logging")
# END external projects that are ON by default
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN external projects that are only needed when MATLAB is in use
# The following projects are default ON when MATLAB is present and enabled.
# Otherwise, they are hidden and default OFF.
drake_optional_external(SEDUMI ON
DEPENDS "NOT DISABLE_MATLAB\;Matlab_FOUND"
"semi-definite programming solver")
drake_optional_external(SPOTLESS ON
DEPENDS "NOT DISABLE_MATLAB\;Matlab_FOUND"
"polynomial optimization front-end for MATLAB")
# The following projects are default OFF when MATLAB is present and enabled.
# Otherwise, they are hidden and default OFF. Some of them may also be hidden
# on Windows regardless of the status of MATLAB.
drake_optional_external(YALMIP OFF
DEPENDS "NOT DISABLE_MATLAB\;Matlab_FOUND"
"free optimization front-end for MATLAB")
# END external projects that are only needed when MATLAB is in use
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN external projects that are OFF by default
drake_optional_external(AVL OFF
DEPENDS "NOT DISABLE_FORTRAN"
"use w/ AVL to compute aerodynamic coefficients for airfoils")
drake_optional_external(GUROBI OFF
"Convex/integer optimization solver\; free for academics")
drake_optional_external(IRIS OFF
DEPENDS "WITH_MOSEK"
"fast approximate convex segmentation")
drake_optional_external(MESHCONVERTERS OFF
"uses vcglib to convert a few standard filetypes")
drake_optional_external(MOSEK OFF
"Convex optimization solver\; free for academics")
drake_optional_external(SIGNALSCOPE OFF
"Live plotting tool for LCM messages")
drake_optional_external(SNOPT OFF
"Sparse Non-linear Optimizer\;"
"requires access to RobotLocomotion/snopt-pod")
drake_optional_external(TEXTBOOK OFF
"The Underactuated Robotics textbook and its examples")
drake_optional_external(XFOIL OFF
DEPENDS "NOT DISABLE_FORTRAN"
"use w/ XFOIL to compute aerodynamic coefficients for airfoils")
# END external projects that are OFF by default
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BEGIN indirectly optional external projects
# The following projects are enabled iff their related externals are enabled.
drake_dependent_external(CTK_PYTHON_CONSOLE
"WITH_DIRECTOR OR WITH_SIGNALSCOPE")
drake_dependent_external(PYTHONQT
"WITH_DIRECTOR OR WITH_SIGNALSCOPE")
drake_dependent_external(QT_PROPERTY_BROWSER
"WITH_DIRECTOR")
# END indirectly optional external projects
endmacro()