forked from dartsim/dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
716 lines (638 loc) · 27.2 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
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
#===============================================================================
# CMake settings
#===============================================================================
if(MSVC)
cmake_minimum_required(VERSION 3.1.3)
else()
cmake_minimum_required(VERSION 2.8.6)
endif()
# Use MACOSX_RPATH by default on OS X. This was added in CMake 2.8.12 and
# became default in CMake 3.0. Explicitly setting this policy is necessary to
# suppress a warning in CMake 3.0 and above.
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
# Simplify variable reference and escape sequence evaluation. This was added in
# CMake 3.1. Explicitly setting this policy is necessary to suppress a warning
# in CMake 3.1 and above.
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
# Disables a warning about a change in Cygwin Cmake
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_CXX_WARNING_LEVEL 4)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(${CMAKE_MODULE_PATH}/DARTMacros.cmake)
# System install paths on Windows
if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Golems" CACHE PATH "Install prefix" FORCE)
endif()
#===============================================================================
# Project settings
#===============================================================================
#
# If you change the version, please update the <version> tag in package.xml.
project(dart)
set(DART_MAJOR_VERSION "5")
set(DART_MINOR_VERSION "1")
set(DART_PATCH_VERSION "6")
set(DART_VERSION "${DART_MAJOR_VERSION}.${DART_MINOR_VERSION}.${DART_PATCH_VERSION}")
set(DART_PKG_DESC "Dynamic Animation and Robotics Toolkit.")
set(DART_PKG_EXTERNAL_DEPS "flann, ccd, fcl")
#===============================================================================
# Print intro
#===============================================================================
message(STATUS "")
message(STATUS "============================================")
message(STATUS " DART ${DART_VERSION}")
message(STATUS "============================================")
#===============================================================================
# Build options
#===============================================================================
option(ENABLE_OPENMP "Build with OpenMP parallaization enabled" ON)
option(BUILD_CORE_ONLY "Build only the core of DART" OFF)
if(MSVC)
set(DART_RUNTIME_LIBRARY "/MD" CACHE STRING "BaseName chosen by the user at CMake configure time")
set_property(CACHE DART_RUNTIME_LIBRARY PROPERTY STRINGS /MD /MT)
option(DART_MSVC_DEFAULT_OPTIONS "Build DART with default Visual Studio options" OFF)
else()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
endif()
option(DART_BUILD_OSGDART "Build osgDart library" ON)
option(DART_BUILD_EXAMPLES "Build examples" ON)
option(DART_BUILD_TUTORIALS "Build tutorials" ON)
option(DART_BUILD_UNITTESTS "Build unit tests" ON)
#===============================================================================
# Build type settings
#===============================================================================
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug | Release | RelWithDebInfo | MinSizeRel" FORCE)
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
set(BUILD_TYPE_DEBUG FALSE)
set(BUILD_TYPE_RELEASE FALSE)
set(BUILD_TYPE_RELWITHDEBINFO FALSE)
set(BUILD_TYPE_MINSIZEREL FALSE)
if("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "DEBUG")
set(BUILD_TYPE_DEBUG TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELEASE")
set(BUILD_TYPE_RELEASE TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELWITHDEBINFO")
set(BUILD_TYPE_RELWITHDEBINFO TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "MINSIZEREL")
set(BUILD_TYPE_MINSIZEREL TRUE)
else()
build_error("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} unknown. Valid options are: Debug | Release | RelWithDebInfo | MinSizeRel")
endif()
#===============================================================================
# Find dependencies
#===============================================================================
#
# If you add a dependency, please add the corresponding rosdep key as a
# dependency in package.xml.
#------------------------
# Mandatory dependencies
#------------------------
message(STATUS "")
message(STATUS "[ Mandatory dependencies ]")
# Eigen
find_package(EIGEN3 3.0.5 QUIET)
if(EIGEN3_FOUND)
message(STATUS "Looking for EIGEN3 - ${EIGEN3_VERSION} found")
else()
if(PC_EIGEN3_VERSION)
message(SEND_ERROR "Looking for EIGEN3 - ${EIGEN3_VERSION} found, ${PROJECT_NAME} requires 3.0.5 or greater.")
else()
message(SEND_ERROR "Looking for EIGEN3 - NOT found, please install libeigen3-dev")
endif()
endif()
# CCD
find_package(CCD 1.4.0 QUIET)
if(CCD_FOUND)
message(STATUS "Looking for CCD - ${CCD_VERSION} found")
else()
if(CCD_VERSION)
message(SEND_ERROR "Looking for CCD - ${CCD_VERSION} found, ${PROJECT_NAME} requires 1.4.0 or greater.")
else()
message(SEND_ERROR "Looking for CCD - NOT found, please install libccd-dev")
endif()
endif()
# FCL
# TODO: We need to increate the minimum required fcl version to 0.4.0 for DART
# 5.0 once fcl 0.4.0 is released.
find_package(FCL 0.2.9 QUIET)
if(FCL_FOUND)
message(STATUS "Looking for FCL - ${FCL_VERSION} found")
else()
if(FCL_VERSION)
message(SEND_ERROR "Looking for FCL - ${FCL_VERSION} found, ${PROJECT_NAME} requires 0.2.9 or greater.")
else()
message(SEND_ERROR "Looking for FCL - NOT found, please install libfcl-dev")
endif()
endif()
# ASSIMP
find_package(ASSIMP 3.0.0 QUIET)
if(ASSIMP_FOUND)
message(STATUS "Looking for ASSIMP - ${ASSIMP_VERSION} found")
# Check for missing symbols in ASSIMP (see #451)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS "")
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_INCLUDES ${ASSIMP_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ASSIMP_LIBRARIES})
check_cxx_source_compiles(
"
#include <assimp/scene.h>
int main()
{
aiScene* scene = new aiScene;
delete scene;
return 1;
}
"
ASSIMP_AISCENE_CTOR_DTOR_DEFINED)
if(NOT ASSIMP_AISCENE_CTOR_DTOR_DEFINED)
message(WARNING "Installed ASSIMP ${ASSIMP_VERSION} is missing symbols "
"for constructor or destructor of aiScene. DART will use own "
"implementation. Please use ASSIMP that fixed this issue.")
endif(NOT ASSIMP_AISCENE_CTOR_DTOR_DEFINED)
check_cxx_source_compiles(
"
#include <assimp/material.h>
int main()
{
aiMaterial* material = new aiMaterial;
delete material;
return 1;
}
"
ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)
if(NOT ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)
message(WARNING "Installed ASSIMP ${ASSIMP_VERSION} is missing symbols "
"for constructor or destructor of aiMaterial. DART will use own "
"implementation. Please use ASSIMP that fixed this issue.")
endif(NOT ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
else()
if(ASSIMP_VERSION)
message(SEND_ERROR "Looking for ASSIMP - ${ASSIMP_VERSION} found, ${PROJECT_NAME} requires 3.0.0 or greater.")
else()
message(SEND_ERROR "Looking for ASSIMP - NOT found, please install libassimp-dev")
endif()
endif()
# OpenGL
find_package(OpenGL QUIET)
if(OPENGL_FOUND)
message(STATUS "Looking for OpenGL - found")
else()
message(SEND_ERROR "Looking for OpenGL - NOT found, please install OpenGL")
endif()
# Boost
set(DART_MIN_BOOST_VERSION 1.46.0 CACHE INTERNAL "Boost min version requirement" FORCE)
if(MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
add_definitions(-DBOOST_TEST_DYN_LINK)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost ${DART_MIN_BOOST_VERSION} COMPONENTS regex system QUIET)
if(Boost_FOUND)
message(STATUS "Looking for Boost - ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} found")
else()
message(SEND_ERROR "Please install system boost version ${DART_MIN_BOOST_VERSION} or higher.")
endif()
if(NOT BUILD_CORE_ONLY)
# GLUT
if(WIN32 AND NOT CYGWIN)
set(GLUT_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
set(GLUT_LIBRARIES glut32)
else()
find_package(GLUT QUIET)
if(GLUT_FOUND)
message(STATUS "Looking for GLUT - found")
set(GLUT_LIBRARIES ${GLUT_glut_LIBRARY})
else()
message(SEND_ERROR "Looking for GLUT - NOT found, Please install freeglut3-dev")
endif()
endif()
# FLANN
find_package(FLANN 1.8.4 QUIET)
if(FLANN_FOUND)
message(STATUS "Looking for FLANN - ${FLANN_VERSION} found")
set(HAVE_FLANN TRUE)
else()
if(FLANN_VERSION)
message(SEND_ERROR "Looking for FLANN - ${FLANN_VERSION} found, ${PROJECT_NAME} requires 1.8.4 or greater.")
else()
message(SEND_ERROR "Looking for FLANN - NOT found, please install libflann-dev")
endif()
set(HAVE_FLANN FALSE)
endif()
# TINYXML
find_package(TINYXML 2.6.2 QUIET)
if(TINYXML_FOUND)
message(STATUS "Looking for TINYXML - ${TINYXML_VERSION} found")
else()
if(TINYXML_VERSION)
message(SEND_ERROR "Looking for TINYXML - ${TINYXML_VERSION} found, ${PROJECT_NAME} requires 2.6.2 or greater.")
else()
message(SEND_ERROR "Looking for TINYXML - NOT found, please install libtinyxml-dev")
endif()
endif()
# TINYXML2
find_package(TINYXML2 QUIET)
if(TINYXML2_FOUND)
message(STATUS "Looking for TINYXML2 - ${TINYXML2_VERSION} found")
else()
if(TINYXML2_VERSION)
message(SEND_ERROR "Looking for TINYXML2 - ${TINYXML2_VERSION} found, ${PROJECT_NAME} requires 1.0.1 or greater.")
else()
message(SEND_ERROR "Looking for TINYXML2 - NOT found, please install libtinyxml2-dev")
endif()
endif()
# urdfdom
find_package(urdfdom QUIET)
if(urdfdom_FOUND)
message(STATUS "Looking for urdfdom - ${urdfdom_headers_VERSION} found")
else()
message(SEND_ERROR "Looking for urdfdom - NOT found, please install liburdfdom-dev")
endif()
if(MSVC)
set(urdfdom_LIBRARIES optimized urdfdom_sensor debug urdfdom_sensord
optimized urdfdom_model_state debug urdfdom_model_stated
optimized urdfdom_model debug urdfdom_modeld
optimized urdfdom_world debug urdfdom_worldd
optimized console_bridge debug console_bridged)
endif()
endif()
#-----------------------
# Optional dependencies
#-----------------------
message(STATUS "")
message(STATUS "[ Optional dependencies ]")
# OpenMP
if(ENABLE_OPENMP)
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
message(STATUS "Looking for OpenMP - found")
else()
message(STATUS "Looking for OpenMP - NOT found")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# NLOPT
find_package(NLOPT 2.4.1 QUIET)
if(NLOPT_FOUND)
message(STATUS "Looking for NLOPT - ${NLOPT_VERSION} found")
set(HAVE_NLOPT TRUE)
else()
if(NLOPT_VERSION)
message(STATUS "Looking for NLOPT - ${NLOPT_VERSION} found, ${PROJECT_NAME} requires 2.4.1 or greater.")
else()
message(STATUS "Looking for NLOPT - NOT found, please install libnlopt-dev")
endif()
set(HAVE_NLOPT FALSE)
endif()
# IPOPT
find_package(IPOPT 3.11.9 QUIET)
if(IPOPT_FOUND)
message(STATUS "Looking for IPOPT - ${IPOPT_VERSION} found")
set(HAVE_IPOPT TRUE)
else()
if(IPOPT_VERSION)
message(STATUS "Looking for IPOPT - ${IPOPT_VERSION} found, ${PROJECT_NAME} requires 3.11.9 or greater.")
else()
message(STATUS "Looking for IPOPT - NOT found, please install coinor-libipopt-dev")
endif()
set(HAVE_IPOPT FALSE)
endif()
# Shark
find_package(SHARK QUIET)
if(SHARK_FOUND)
message(STATUS "Looking for SHARK - ${SHARK_VERSION} found")
set(HAVE_SHARK TRUE)
else()
message(STATUS "Looking for SHARK - NOT found, please install SHARK (http://image.diku.dk/shark)")
set(HAVE_SHARK FALSE)
endif()
# Bullet. Force MODULE mode to use the FindBullet.cmake file distributed with
# CMake. Otherwise, we may end up using the BulletConfig.cmake file distributed
# with Bullet, which uses relative paths and may break transitive dependencies.
find_package(Bullet COMPONENTS BulletMath BulletCollision MODULE QUIET)
if(BULLET_FOUND)
# Test whether Bullet was built with double precision. If so, we need to
# define the BT_USE_DOUBLE_PRECISION pre-processor directive before including
# any Bullet headers. This is a workaround for the fact that Bullet does not
# add the definition to BULLET_DEFINITIONS or generate a #cmakedefine header.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_DEFINITIONS "-DBT_USE_DOUBLE_PRECISION")
set(CMAKE_REQUIRED_INCLUDES "${BULLET_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${BULLET_LIBRARIES}")
check_cxx_source_compiles(
"
#include <btBulletCollisionCommon.h>
int main()
{
btVector3 v(0., 0., 1.);
btStaticPlaneShape planeShape(v, 0.);
return 0;
}
"
BT_USE_DOUBLE_PRECISION
)
if(BT_USE_DOUBLE_PRECISION)
message(STATUS "Looking for Bullet - found (double precision)")
else()
message(STATUS "Looking for Bullet - found (single precision)")
endif()
set(HAVE_BULLET_COLLISION TRUE)
else()
message(STATUS "Looking for Bullet - NOT found, please install libbullet-dev")
set(HAVE_BULLET_COLLISION FALSE)
endif()
# Perl modules
find_package(PerlModules COMPONENTS Regexp::Common Getopt::ArgvFile Getopt::Long Term::ANSIColor QUIET)
if("${PERLMODULES_FOUND}" STREQUAL "TRUE")
message(STATUS "Looking for PerlModules - found")
else()
message(STATUS "Looking for PerlModules - NOT found, please install Regexp::Common Getopt::ArgvFile Getopt::Long Term::ANSIColor (http://www.cpan.org/modules/INSTALL.html)")
endif()
# Doxygen
find_package(Doxygen QUIET)
if(DOXYGEN_FOUND)
message(STATUS "Looking for Doxygen - found")
else()
message(STATUS "Looking for Doxygen - NOT found, please install doxygen")
endif()
#===============================================================================
# DART dependency variable settings
#===============================================================================
set(DART_CORE_DEPENDENCIES ${CCD_LIBRARIES}
${FCL_LIBRARIES}
${ASSIMP_LIBRARIES}
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
${GLUT_LIBRARY}
)
if(HAVE_BULLET_COLLISION)
set(DART_CORE_DEPENDENCIES ${DART_CORE_DEPENDENCIES} ${BULLET_LIBRARIES})
endif()
if(NOT BUILD_CORE_ONLY)
set(DART_DEPENDENCIES ${urdfdom_LIBRARIES}
${FLANN_LIBRARIES}
${TINYXML_LIBRARIES}
${TINYXML2_LIBRARIES}
)
endif()
#===============================================================================
# Include directories
#===============================================================================
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS})
include_directories(SYSTEM ${CCD_INCLUDE_DIRS})
include_directories(SYSTEM ${FCL_INCLUDE_DIRS})
include_directories(SYSTEM ${ASSIMP_INCLUDE_DIRS})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM ${GLUT_INCLUDE_DIR})
if(HAVE_BULLET_COLLISION)
include_directories(SYSTEM ${BULLET_INCLUDE_DIRS})
endif()
if(NOT BUILD_CORE_ONLY)
include_directories(SYSTEM ${FLANN_INCLUDE_DIRS})
include_directories(SYSTEM ${urdfdom_INCLUDE_DIRS})
include_directories(SYSTEM ${TINYXML_INCLUDE_DIRS})
include_directories(SYSTEM ${TINYXML2_INCLUDE_DIRS})
if(HAVE_NLOPT)
include_directories(SYSTEM ${NLOPT_INCLUDE_DIRS})
endif()
if(HAVE_IPOPT)
include_directories(SYSTEM ${IPOPT_INCLUDE_DIRS})
endif()
if(HAVE_SHARK)
include_directories(SYSTEM ${SHARK_INCLUDE_DIRS})
endif()
endif()
include_directories("${CMAKE_BINARY_DIR}")
set(DART_INCLUDE_DIRS
"${CMAKE_INSTALL_PREFIX}/include"
"${EIGEN3_INCLUDE_DIRS}")
if(HAVE_BULLET_COLLISION)
list(APPEND DART_INCLUDE_DIRS "${BULLET_INCLUDE_DIRS}")
endif()
#===============================================================================
# Link directories
#===============================================================================
link_directories("${CMAKE_BINARY_DIR}/lib")
link_directories("${CMAKE_INSTALL_PREFIX}/lib")
link_directories(${Boost_LIBRARY_DIRS})
#===============================================================================
# Check for non-case-sensitive filesystems
#===============================================================================
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/case_sensitive_filesystem
RESULT_VARIABLE FILESYSTEM_CASE_SENSITIVE_RETURN)
if(${FILESYSTEM_CASE_SENSITIVE_RETURN} EQUAL 0)
set(FILESYSTEM_CASE_SENSITIVE TRUE)
else()
set(FILESYSTEM_CASE_SENSITIVE FALSE)
endif()
#===============================================================================
# Compiler flags
#===============================================================================
if(MSVC)
# Visual Studio enables c++11 support by default
if(MSVC_VERSION VERSION_LESS 1800)
message(FATAL_ERROR "${PROJECT_NAME} requires VS 2015 or greater.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP4")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO")
if(NOT DART_MSVC_DEFAULT_OPTIONS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc /arch:SSE2")
endif(NOT DART_MSVC_DEFAULT_OPTIONS)
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall -msse2 -fPIC")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
set(CXX_COMPILER_VERSION ${GCC_VERSION})
if(GCC_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "The installed g++ version is ${GCC_VERSION}. ${PROJECT_NAME} requires g++ 4.8 or greater.")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-omit-frame-pointer -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_DEBUG} -pg")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-msse2 -fPIC")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
set(CXX_COMPILER_VERSION ${CLANG_VERSION})
if(CLANG_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "The installed Clang version is ${CLANG_VERSION}. ${PROJECT_NAME} requires clang 3.3 or greater.")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-omit-frame-pointer -fno-inline-functions -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_DEBUG} -pg")
else()
message(SEND_ERROR "Compiler[${CMAKE_CXX_COMPILER_ID}] not supported.")
endif()
#===============================================================================
# Print build summary
#===============================================================================
message(STATUS "")
message(STATUS "[ Build summary ]")
message(STATUS "CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "Compiler version : ${CXX_COMPILER_VERSION}")
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
message(STATUS "ENABLE_OPENMP : ${ENABLE_OPENMP}")
message(STATUS "Build core only : ${BUILD_CORE_ONLY}")
message(STATUS "Build osgDart : ${DART_BUILD_OSGDART}")
message(STATUS "Build examples : ${DART_BUILD_EXAMPLES}")
message(STATUS "Build tutorials : ${DART_BUILD_TUTORIALS}")
message(STATUS "Build unit tests : ${DART_BUILD_UNITTESTS}")
message(STATUS "Install path : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CXX_FLAGS : ${CMAKE_CXX_FLAGS}")
if(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELEASE")
message(STATUS "CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "DEBUG")
message(STATUS "CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELWITHDEBINFO")
message(STATUS "CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "PROFILE")
message(STATUS "CXX_FLAGS_PROFILE: ${CMAKE_CXX_FLAGS_PROFILE}")
endif()
message(STATUS "CMAKE_SOURCE_DIR : ${CMAKE_SOURCE_DIR}")
message(STATUS "CMAKE_BINARY_DIR : ${CMAKE_BINARY_DIR}")
#===============================================================================
# Configure files
#===============================================================================
message(STATUS "")
message(STATUS "[ Configured files ]")
# Generate the dart config file
# Ref: http://www.vtk.org/Wiki/CMake:How_To_Write_Platform_Checks
set(DART_CONFIG_IN ${CMAKE_SOURCE_DIR}/dart/config.h.in)
set(DART_CONFIG_OUT ${CMAKE_BINARY_DIR}/dart/config.h)
message(STATUS ${DART_CONFIG_OUT})
configure_file(${DART_CONFIG_IN} ${DART_CONFIG_OUT} @ONLY)
install(FILES ${DART_CONFIG_OUT} DESTINATION include/dart)
# Generate the DART CMake Config and version files
include(WriteBasicConfigVersionFile)
set(DART_CORE_CONFIG_IN ${CMAKE_SOURCE_DIR}/cmake/DARTCoreConfig.cmake.in)
set(DART_CORE_CONFIG_OUT ${CMAKE_BINARY_DIR}/cmake/DARTCoreConfig.cmake)
message(STATUS ${DART_CORE_CONFIG_OUT})
message(STATUS ${CMAKE_BINARY_DIR}/cmake/DARTConfigVersion.cmake)
configure_file(${DART_CORE_CONFIG_IN} ${DART_CORE_CONFIG_OUT} @ONLY)
write_basic_config_version_file(cmake/DARTCoreConfigVersion.cmake VERSION ${DART_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${DART_CORE_CONFIG_OUT} ${CMAKE_BINARY_DIR}/cmake/DARTCoreConfigVersion.cmake DESTINATION share/dartcore)
if(NOT BUILD_CORE_ONLY)
set(DART_CONFIG_IN ${CMAKE_SOURCE_DIR}/cmake/DARTConfig.cmake.in)
set(DART_CONFIG_OUT ${CMAKE_BINARY_DIR}/cmake/DARTConfig.cmake)
message(STATUS ${DART_CONFIG_OUT})
message(STATUS ${CMAKE_BINARY_DIR}/cmake/DARTConfigVersion.cmake)
configure_file(${DART_CONFIG_IN} ${DART_CONFIG_OUT} @ONLY)
write_basic_config_version_file(cmake/DARTConfigVersion.cmake VERSION ${DART_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${DART_CONFIG_OUT} ${CMAKE_BINARY_DIR}/cmake/DARTConfigVersion.cmake DESTINATION share/dart)
endif()
# Generate the DART pkg-config
set(PC_CONFIG_IN ${CMAKE_SOURCE_DIR}/cmake/dart.pc.in)
set(PC_CONFIG_OUT ${CMAKE_BINARY_DIR}/cmake/dart.pc)
message(STATUS ${PC_CONFIG_OUT})
configure_file(${PC_CONFIG_IN} ${PC_CONFIG_OUT} @ONLY)
install(FILES ${PC_CONFIG_OUT} DESTINATION lib/pkgconfig)
# Install a Catkin 'package.xml' file. This is required by REP-136.
install(FILES package.xml DESTINATION share/${PROJECT_NAME})
#===============================================================================
# Add sub-directories
#===============================================================================
add_subdirectory(dart)
if(NOT BUILD_CORE_ONLY)
if(DART_BUILD_OSGDART)
add_subdirectory(osgDart)
endif(DART_BUILD_OSGDART)
# Unit tests
if(DART_BUILD_UNITTESTS)
enable_testing()
add_subdirectory(unittests)
endif(DART_BUILD_UNITTESTS)
# Examples
if(DART_BUILD_EXAMPLES)
add_subdirectory(apps)
endif(DART_BUILD_EXAMPLES)
if(DART_BUILD_TUTORIALS)
add_subdirectory(tutorials)
endif()
endif(NOT BUILD_CORE_ONLY)
#===============================================================================
# Export targets
#===============================================================================
install(EXPORT DARTCoreTargets DESTINATION share/dartcore)
if(NOT BUILD_CORE_ONLY)
install(EXPORT DARTTargets DESTINATION share/dart)
endif()
# Add an "uninstall" target
# Ref: http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
configure_file("${PROJECT_SOURCE_DIR}/cmake/uninstall_target.cmake.in" "${PROJECT_BINARY_DIR}/uninstall_target.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/uninstall_target.cmake")
#===============================================================================
# API Document using Doxygen
# References:
# http://mementocodex.wordpress.com/2013/01/19/how-to-generate-code-documentation-with-doxygen-and-cmake-a-slightly-improved-approach/
# http://www.cmake.org/pipermail/cmake/2007-February/012796.html
#===============================================================================
if(DOXYGEN_FOUND)
set(DOXYGEN_DOXYFILE_IN ${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in )
set(DOXYGEN_DOXYFILE ${PROJECT_BINARY_DIR}/doxygen/Doxyfile )
set(DOXYGEN_HTML_INDEX ${PROJECT_SOURCE_DIR}/doxygen/html/index.html)
set(DOXYGEN_OUTPUT_ROOT ${PROJECT_SOURCE_DIR}/doxygen/html ) # Pasted into Doxyfile.in
set(DOXYGEN_INPUT_ROOT ${PROJECT_SOURCE_DIR}/dart ) # Pasted into Doxyfile.in
set(DOXYGEN_EXTRA_INPUTS ${PROJECT_SOURCE_DIR}/doxygen/mainpage.dox ) # Pasted into Doxyfile.in
configure_file(${DOXYGEN_DOXYFILE_IN} ${DOXYGEN_DOXYFILE} @ONLY)
file(COPY "${PROJECT_SOURCE_DIR}/doxygen/DART logo.png" DESTINATION ${DOXYGEN_OUTPUT_ROOT})
add_custom_command(OUTPUT ${DOXYGEN_HTML_INDEX}
COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
COMMAND ${DOXYGEN_EXECUTABLE} -u ${DOXYGEN_DOXYFILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DOXYFILE}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doxygen
DEPENDS ${DOXYGEN_DOXYFILE}
)
# add_custom_target(docs ALL DEPENDS ${DOXYGEN_HTML_INDEX})
add_custom_target(docs DEPENDS ${DOXYGEN_HTML_INDEX})
add_custom_target(docs_forced
COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
COMMAND ${DOXYGEN_EXECUTABLE} -u ${DOXYGEN_DOXYFILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DOXYFILE}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doxygen
)
endif()
#===============================================================================
# Coloring build outputs using gccfilter if appliciable
# Ref: http://stackoverflow.com/questions/14399984/make-cmake-use-gccfilter
#===============================================================================
if("${PERLMODULES_FOUND}" STREQUAL "TRUE")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCPP)
option(COLOR_GCC "Use GCCFilter to color compiler output messages" ON)
set(COLOR_GCC_OPTIONS "-c -r -w" CACHE STRING "Arguments that are passed to gccfilter when output coloring is switchend on. Defaults to -c -r -w.")
if(COLOR_GCC)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${PROJECT_SOURCE_DIR}/tools/gccfilter ${COLOR_GCC_OPTIONS}")
endif()
endif()
endif()
#===============================================================================
# END
#===============================================================================
message(STATUS "")