forked from rdiankov/openrave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1029 lines (908 loc) · 47.9 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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required (VERSION 2.6.3) # using import/export targets, 2.6.3 for open scene graph cmake files
project(OpenRAVE)
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
# Define here the needed parameters
set (OPENRAVE_VERSION_MAJOR 0)
set (OPENRAVE_VERSION_MINOR 54)
set (OPENRAVE_VERSION_PATCH 0)
set (OPENRAVE_VERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}.${OPENRAVE_VERSION_PATCH})
set (OPENRAVE_SOVERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR})
message(STATUS "Compiling OpenRAVE Version ${OPENRAVE_VERSION}, soversion=${OPENRAVE_SOVERSION}")
message(STATUS "Using cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" )
# http://www.cmake.org/cmake/help/cmake-2.6.html#policy:CMP0002
cmake_policy(SET CMP0002 NEW)
# http://www.cmake.org/cmake/help/cmake-2.6.html#policy:CMP0003
cmake_policy(SET CMP0003 NEW)
set(CMAKE_CXX_STANDARD 11)
# Use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# When building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(LIB_SUFFIX CACHE STRING "suffix for the library directory need for x86-64 systems that use lib64 ")
# Add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Custom CMake options
option(OPT_VIDEORECORDING "Enable video recording" ON)
option(OPT_PLUGINS "Build the pluings" ON)
option(OPT_DOUBLE_PRECISION "Use double precision" ON)
option(OPT_ACCURATEMATH "Use accurate and robust math to account for floating-point errors" ON)
option(OPT_PYTHON "Build python bindings" ON)
option(OPT_OCTAVE "Build octave bindings" ON)
option(OPT_MATLAB "Build matlab bindings" ON)
option(OPT_STATIC "Build static libraries" OFF)
option(OPT_COLLADA "Build with COLLADA support" ON)
option(OPT_BULLET "Use Bullet Collision/Physics if available" ON)
option(OPT_ODE_COLLISION "Use ODE collision checker if available" ON)
option(OPT_FCL_COLLISION "Use FCL collision checker if available" ON)
option(OPT_QTCOIN_VIEWER "Use QT/Coin Viewer if available" ON)
option(OPT_QTOSG_VIEWER "Use QT/OpenSceneGraph Viewer if available" ON)
option(OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
option(OPT_BUILD_PACKAGE_DEFAULT "Set to ON to generate a default openrave package that creates symlinks" ON)
option(OPT_IKFAST_FLOAT32 "Set to ON to allow loading of ikfast shared objects compiled with 32bit float (64bit double is always supported regardless of this option)" ON)
option(OPT_FLANN "Temporary switch to force building of flann" OFF)
option(OPT_CBINDINGS "Build the C-bindings libraries libopenrave_c and libopenrave-core_c" ON)
option(OPT_LOG4CXX "Use log4cxx for logging" ON)
option(OPT_MSGPACK "Support msgpack format" ON)
option(OPT_INSTALL_3DMODELDATA "If ON, then install the 3D model data." ON)
option(OPT_EXTRA_ROBOTS "If ON, then install extra robots as part of 3D model data" ON)
set(PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules-cmake")
set(CPACK_DEBIAN_PACKAGE_NAME openrave${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR})
if(OPT_DOUBLE_PRECISION)
set(OPENRAVE_PRECISION 1)
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-dp")
message(STATUS "Using double precision")
else()
set(OPENRAVE_PRECISION 0)
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-sp")
message(STATUS "Using single precision")
endif()
set(COMPONENT_PREFIX "${CPACK_DEBIAN_PACKAGE_NAME}-")
string(TOUPPER ${COMPONENT_PREFIX} COMPONENT_PREFIX_UPPER)
set(CPACK_COMPONENTS_ALL ${COMPONENT_PREFIX}base ${COMPONENT_PREFIX}dev ${COMPONENT_PREFIX}data)
message(STATUS "detected system processor: ${CMAKE_SYSTEM_PROCESSOR}")
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
include(CheckCXXCompilerFlag)
include(CheckTypeSize)
include(InstallSymlink)
#include(FindIntl)
find_package(PkgConfig) # pkg_check_modules
set(OPENRAVE_PYTHON_INSTALL_DIR)
if( OPT_PYTHON )
include(FindPythonInterp)
## check python
find_package(PythonLibs 2) # using PYTHON_INCLUDE_PATH instead of PYTHON_INCLUDE_DIRS?
if( NOT PYTHON_EXECUTABLE )
# look specifically for 2.6
find_program(PYTHON_EXECUTABLE NAMES python2.6 python PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath])
endif()
# back compat?
if( NOT PYTHON_INCLUDE_DIRS )
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH})
endif()
if( PYTHON_EXECUTABLE )
get_filename_component(PYTHON_EXECUTABLE_NAME ${PYTHON_EXECUTABLE} NAME)
# architecture independent
# execute_process(
# COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(0)"
# OUTPUT_VARIABLE _python_sitepackage OUTPUT_STRIP_TRAILING_WHITESPACE
# RESULT_VARIABLE _python_failed0)
# # architexture dependent
# execute_process(
# COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)"
# OUTPUT_VARIABLE _python_distpackage OUTPUT_STRIP_TRAILING_WHITESPACE
# RESULT_VARIABLE _python_failed1)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
OUTPUT_VARIABLE _python_numpy_include OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _python_failed0)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; from myrelpath import relpath; print relpath(get_python_lib(1,prefix='${CMAKE_INSTALL_PREFIX}'),'${CMAKE_INSTALL_PREFIX}')"
OUTPUT_VARIABLE OPENRAVE_PYTHON_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE _python_failed2)
if( ${_python_failed0} EQUAL 0 AND ${_python_failed2} EQUAL 0 )
if( NOT IS_DIRECTORY "${_python_numpy_include}" )
set(PYTHON_EXECUTABLE)
else()
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${_python_numpy_include})
endif()
# get the major.minor python version
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print('%d.%d'%sys.version_info[0:2])"
OUTPUT_VARIABLE _python_version OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _python_failed)
if( ${_python_failed} EQUAL 0 )
string(REGEX REPLACE "[\r\n]" "" PYTHON_MAJORMINOR_VERSION "${_python_version}")
else()
message(STATUS "failed to get python version")
endif()
else()
message(STATUS "failed to get python site-package directories via get_python_lib")
set(PYTHON_EXECUTABLE)
endif()
endif()
endif()
if( WIN32 )
# does not support symlinks
set(OPENRAVE_BIN_SUFFIX)
else()
set(OPENRAVE_BIN_SUFFIX ${OPENRAVE_SOVERSION} CACHE STRING "Add the MAJOR.MINOR openrave version suffixes to all executable installed files")
endif()
set(OPENRAVE_SHARE_DIR "share/openrave-${OPENRAVE_SOVERSION}" CACHE PATH "Relative path for shared OpenRAVE data")
set(OPENRAVE_DATA_INSTALL_DIR "${OPENRAVE_SHARE_DIR}" CACHE PATH "Scene and robot files installation directory")
set(OPENRAVE_PLUGINS_INSTALL_DIR "lib${LIB_SUFFIX}/openrave${OPENRAVE_SOVERSION}-plugins" CACHE PATH "OpenRAVE plugins installation directory")
set(OPENRAVEPY_INSTALL_DIR "${OPENRAVE_PYTHON_INSTALL_DIR}/openravepy" CACHE PATH "OpenRAVE Python bindings (openravepy) installation directory")
set(OPENRAVE_LOCALE_INSTALL_DIR "share/locale" CACHE PATH "Relative path for OpenRAVE translation files")
set(OPENRAVE_OCTAVE_INSTALL_DIR "${OPENRAVE_SHARE_DIR}/octave" CACHE PATH "OpenRAVE Octave bindings installation directory")
set(OPENRAVE_MATLAB_INSTALL_DIR "${OPENRAVE_SHARE_DIR}/matlab" CACHE PATH "OpenRAVE MATLAB bindings installation directory")
set(OPENRAVE_CMAKE_INSTALL_DIR "openrave-${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}" CACHE STRING "Directory to install the cmake config files.")
set(OPENRAVE_INCLUDE_INSTALL_DIR "openrave-${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}" CACHE STRING "Directory name for header files")
if( UNIX OR CYGWIN)
# cache has to be STRING instead of PATH for path to remain relative
set(BASH_COMPLETION_DIR CACHE STRING "Directory where bash completion files will be installed in, on linux it is /etc/bash_completion.d")# Additional CMake modules for 3rd party library checks reside here
endif()
set(OPENRAVE_PLUGINS_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_PLUGINS_INSTALL_DIR}" CACHE PATH "Absolute dir for plugins on target OS path, used to write to header file")
set(OPENRAVE_DATA_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_DATA_INSTALL_DIR}" CACHE PATH "Absolute dir for data on target OS path, used to write to header file")
set(OPENRAVE_PYTHON_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_PYTHON_INSTALL_DIR}" CACHE PATH "Absolute dir for python on target OS path, used to write to header file")
set(OPENRAVE_LOCALE_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_LOCALE_INSTALL_DIR}" CACHE PATH "Absolute dir for translation files on target OS path, used to write to header file")
# The RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" "${OPENRAVE_PLUGINS_INSTALL_ABSOLUTE_DIR}")
#define OPENRAVE_PLUGINS_INSTALL_DIR
#define OPENRAVE_DATA_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@/@OPENRAVE_DATA_INSTALL_DIR@"
#define OPENRAVE_PYTHON_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@/@OPENRAVE_PYTHON_INSTALL_DIR@"
set(CMAKE_TRY_COMPILE_CONFIGURATION Release CACHE STRING "very important to only test release since default is debug, and it usually reuquires special libraries")
set(OPENRAVE_INCLUDE_LOCAL_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(OPENRAVEPY_INCLUDE_LOCAL_DIRS ${CMAKE_CURRENT_BINARY_DIR}/python/bindings/include ${CMAKE_CURRENT_SOURCE_DIR}/python/bindings/include)
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
message(STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}")
message(STATUS "OPENRAVE_PYTHON_INSTALL_DIR = ${OPENRAVE_PYTHON_INSTALL_DIR}")
message(STATUS "OPENRAVE_BIN_SUFFIX = ${OPENRAVE_BIN_SUFFIX}")
message(STATUS "OPENRAVE_INCLUDE_LOCAL_DIRS = ${OPENRAVE_INCLUDE_LOCAL_DIRS}")
message(STATUS "OPENRAVEPY_INCLUDE_LOCAL_DIRS = ${OPENRAVEPY_INCLUDE_LOCAL_DIRS}")
# need this in the very first include, otherwise openrave plugins can accidentaly compile with a system-installed openrave headers.
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(${OPENRAVE_INCLUDE_LOCAL_DIRS}) # needed since plugins include openrave/openrave.h
set(REQUIRED_INCLUDES "" CACHE STRING "Includes to always force when compiling")
include_directories(${REQUIRED_INCLUDES})
set(COMPILER_IS_CLANG FALSE)
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(COMPILER_IS_CLANG TRUE)
endif()
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
add_definitions("-fno-strict-aliasing -Wall")
endif()
set(OPENRAVE_EXPORT_CXXFLAGS)
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
set(CMAKE_CXX_FLAGS_OPTIMIZED "-O3 -DNDEBUG -DBOOST_DISABLE_ASSERTS -D_SECURE_SCL=0") # this practically removes all checks making it a very dangerous options to play with
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g3 -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -D_DEBUG")
# the _GLIBCXX_DEBUG flag is very helpful in bounds checking for vector[] and iterators, however it requires all
# libraries linking with openrave to use it
# if( CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(OPENRAVE_EXPORT_CXXFLAGS "${OPENRAVE_EXPORT_CXXFLAGS} -D_GLIBCXX_DEBUG")
# endif()
endif()
if( MSVC )
set(LINKER_HAS_RDYNAMIC 0)
set(LINKER_HAS_BSYMBOLIC 0)
set(LINKER_HAS_BSYMBOLIC_FUNCTIONS 0)
set(LINKER_HAS_VISIBILITY 0)
set(LINKER_HAS_VISIBILITY_INLINES_HIDDEN 0)
else()
check_cxx_compiler_flag("-rdynamic" LINKER_HAS_RDYNAMIC)
check_cxx_compiler_flag("-Bsymbolic" LINKER_HAS_BSYMBOLIC)
check_cxx_compiler_flag("-Bsymbolic-functions" LINKER_HAS_BSYMBOLIC_FUNCTIONS)
check_cxx_compiler_flag("-fvisibility=hidden" LINKER_HAS_VISIBILITY)
check_cxx_compiler_flag("-fvisibility-inlines-hidden" LINKER_HAS_VISIBILITY_INLINES_HIDDEN)
endif()
if( UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
set(STDC_LIBRARY stdc++)
else()
set(STDC_LIBRARY)
endif()
if( APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# apple doesn't have 64bit versions of file opening functions, so add them
add_definitions(-Dfopen64=fopen -Dfseeko64=fseeko -Dfseek64=fseek -Dftell64=ftell -Dftello64=ftello)
endif()
set(OPENRAVE_CORE_INCLUDE_LOCAL_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/libopenrave-core)
set(OPENRAVE_LINK_DIRS "")
if( MSVC )
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE)
#gives linking problems
#string(REGEX REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
#string(REGEX REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
# /EHc- allow extern "C" functions to throw exceptions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHc- ")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHc- ")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHc- ")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /EHc- ")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /EHc- ")
# untar the source files
set(EXTRA_MSVC_DEPEND msvc_boost msvc_collada msvc_libxml2 msvc_ode msvc_soqt)
foreach(MSVC_LIBRARY ${EXTRA_MSVC_DEPEND})
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY}.tgz" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY}
COMMAND ${CMAKE_COMMAND} -E chdir
ARGS "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY}.tgz"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY}.tgz)
add_custom_target(${MSVC_LIBRARY} ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${MSVC_LIBRARY})
endforeach()
check_include_file(stdint.h HAVE_STDINT_H)
if( NOT HAVE_STDINT_H )
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/msvc_include/stdint.h DESTINATION include/openrave-${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR} COMPONENT ${COMPONENT_PREFIX}dev)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/msvc_include)
endif()
# have to install dlls manually
if( MSVC70 OR MSVC71 )
set(MSVC_PREFIX "vc70")
elseif( MSVC80 )
set(MSVC_PREFIX "vc80")
elseif( MSVC90 )
set(MSVC_PREFIX "vc90")
else()
set(MSVC_PREFIX "vc100")
endif()
set(OPENRAVE_LIBRARY_SUFFIX "${OPENRAVE_SOVERSION}-${MSVC_PREFIX}-mt" CACHE STRING "Suffix to append to library names")
# force multi-threaded DLL boost
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_CFLAGS "-DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
else()
set(OPENRAVE_LIBRARY_SUFFIX "${OPENRAVE_SOVERSION}" CACHE STRING "Suffix to append to library names")
endif()
# only look for installed boost if not an old version of msvc
if(NOT MSVC71 AND NOT MSVC80)
if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
set(Boost_INCLUDE_DIR $ENV{BOOST_INCLUDEDIR})
endif()
if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
set(Boost_LIBRARY_DIRS $ENV{BOOST_LIBRARYDIR})
endif()
set(Boost_ADDITIONAL_VERSIONS "1.46.1" "1.45" "1.44" "1.43" "1.42" "1.41" "1.40" "1.39" "1.38" "1.37.0" "1.37" "1.35.0" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33" ${Boost_ADDITIONAL_VERSIONS})
if(OPT_PYTHON AND NOT USE_PYBIND11_PYTHON_BINDINGS)
find_package(Boost COMPONENTS regex filesystem system python thread iostreams date_time)
else()
find_package(Boost COMPONENTS regex filesystem system thread iostreams date_time)
endif()
else()
# have to rely on local boost and a hack
add_definitions(-DTEMP_SPIRIT_HACK)
endif()
if( Boost_FOUND )
include_directories(${Boost_INCLUDE_DIRS})
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${Boost_LIBRARY_DIRS})
elseif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
include_directories(${Boost_INCLUDE_DIRS})
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${Boost_LIBRARY_DIRS})
elseif( MSVC )
# to facilitate compilation, visual studio libraries are included locally
message(STATUS "using local boost libraries for MSVC")
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/msvc_boost")
set(Boost_FOUND 1)
set(Boost_INCLUDE_DIRS "${BOOST_ROOT}")
set(Boost_INCLUDE_DIR "${BOOST_ROOT}")
set(Boost_LIBRARY_DIRS "${BOOST_ROOT}/lib")
set(Boost_REGEX_FOUND 0)
set(Boost_FILESYSTEM_FOUND 1)
set(Boost_IOSTREAMS_FOUND 1)
set(Boost_SYSTEM_FOUND 1)
set(Boost_PYTHON_FOUND 1)
set(Boost_THREAD_FOUND 1)
set(Boost_DATE_TIME_FOUND 1)
set(Boost_SIGNALS_FOUND 1)
set(Boost_VERSION "104400")
# have to add to required flags for applications that will test linking with boost
set(CMAKE_REQUIRED_FLAGS "-DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
set(Boost_DATE_TIME_LIBRARY "${Boost_LIBRARY_DIRS}/boost_date_time-${MSVC_PREFIX}-mt-1_44.lib")
set(Boost_THREAD_LIBRARY "${Boost_LIBRARY_DIRS}/boost_thread-${MSVC_PREFIX}-mt-1_44.lib")
set(Boost_SYSTEM_LIBRARY "${Boost_LIBRARY_DIRS}/boost_system-${MSVC_PREFIX}-mt-1_44.lib")
set(Boost_FILESYSTEM_LIBRARY "${Boost_LIBRARY_DIRS}/boost_filesystem-${MSVC_PREFIX}-mt-1_44.lib")
set(Boost_PYTHON_LIBRARY "${Boost_LIBRARY_DIRS}/boost_python-${MSVC_PREFIX}-mt-1_44.lib")
set(Boost_IOSTREAMS_LIBRARY "${Boost_LIBRARY_DIRS}/boost_iostreams-${MSVC_PREFIX}-mt-1_44.lib")
install(DIRECTORY "${Boost_LIBRARY_DIRS}/" DESTINATION bin COMPONENT ${COMPONENT_PREFIX}base FILES_MATCHING PATTERN "*-${MSVC_PREFIX}-*.dll")
install(DIRECTORY "${Boost_LIBRARY_DIRS}/" DESTINATION lib${LIB_SUFFIX} COMPONENT ${COMPONENT_PREFIX}dev FILES_MATCHING PATTERN "*-${MSVC_PREFIX}-*.lib")
install(DIRECTORY "${Boost_INCLUDE_DIR}/boost" DESTINATION include COMPONENT ${COMPONENT_PREFIX}dev)
include_directories(${Boost_INCLUDE_DIRS})
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${Boost_LIBRARY_DIRS})
else()
message(FATAL_ERROR "Could not find boost libraries!")
endif()
message(STATUS "found boost version: ${Boost_VERSION}")
if( NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY )
message(FATAL_ERROR "boost thread and date_time libraries are necessary")
endif()
if( OPT_PYTHON AND MSVC AND Boost_VERSION GREATER 104600 AND PYTHON_MAJORMINOR_VERSION STRGREATER "2.6")
message(STATUS "Boost python library ${Boost_PYTHON_LIBRARY} might not be compiled for Python ${PYTHON_MAJORMINOR_VERSION}")
endif()
set(OPENRAVE_BOOST_INCLUDE_DIRS)
foreach(idir ${Boost_INCLUDE_DIRS})
if( MSVC )
set(OPENRAVE_BOOST_INCLUDE_DIRS "${OPENRAVE_BOOST_INCLUDE_DIRS} /I\"${idir}\"")
else()
set(OPENRAVE_BOOST_INCLUDE_DIRS "${OPENRAVE_BOOST_INCLUDE_DIRS} -I${idir}")
endif()
endforeach()
set(OPENRAVE_BOOST_LIB_DIRS)
foreach(ldir ${Boost_LIBRARY_DIRS})
if( MSVC )
set(OPENRAVE_BOOST_LIB_DIRS "${OPENRAVE_BOOST_LIB_DIRS} /LIBPATH:\"${ldir}\"")
else()
set(OPENRAVE_BOOST_LIB_DIRS "${OPENRAVE_BOOST_LIB_DIRS} -L${ldir}")
endif()
endforeach()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG )
add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
set(EXTRA_COMPILE_FLAGS "-fPIC")
set(NATIVE_COMPILE_FLAGS "" CACHE STRING "compilation flags to pass to tools that are executed at build-time. For example '-march=native -mtune=native'. By default this is empty.")
else()
set(EXTRA_COMPILE_FLAGS "")
set(NATIVE_COMPILE_FLAGS "")
endif()
# generate the md5 sum for all OpenRAVE interfaces
add_subdirectory(cpp-gen-md5)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cpp-gen-md5")
if( MSVC )
if( EXTRA_MSVC_DEPEND )
add_dependencies(cpp-gen-md5-native ${EXTRA_MSVC_DEPEND})
endif()
set(CPPGENMD5 cpp-gen-md5-native)
else()
set(CPPGENMD5 "${CMAKE_CURRENT_BINARY_DIR}/cpp-gen-md5/cpp-gen-md5-native")
endif()
set(interfacehashes_h ${CMAKE_CURRENT_BINARY_DIR}/include/openrave/interfacehashes.h)
add_custom_command(
OUTPUT ${interfacehashes_h}
COMMAND ${CPPGENMD5}
ARGS "${OPENRAVE_PRECISION}" "${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/interface.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/collisionchecker.h" OPENRAVE_COLLISIONCHECKER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/robot.h" OPENRAVE_ROBOT_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/planner.h" OPENRAVE_PLANNER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/kinbody.h" OPENRAVE_KINBODY_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/sensorsystem.h" OPENRAVE_SENSORSYSTEM_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/controller.h" OPENRAVE_CONTROLLER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/module.h" OPENRAVE_MODULE_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/iksolver.h" OPENRAVE_IKSOLVER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/physicsengine.h" OPENRAVE_PHYSICSENGINE_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/sensor.h" OPENRAVE_SENSOR_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/trajectory.h" OPENRAVE_TRAJECTORY_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/viewer.h" OPENRAVE_VIEWER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/spacesampler.h" OPENRAVE_SPACESAMPLER_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/environment.h" OPENRAVE_ENVIRONMENT_HASH
"${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/plugininfo.h" OPENRAVE_PLUGININFO_HASH
> "${interfacehashes_h}"
DEPENDS cpp-gen-md5-native
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/interface.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/collisionchecker.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/robot.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/planner.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/kinbody.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/sensorsystem.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/controller.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/module.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/iksolver.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/physicsengine.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/sensor.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/trajectory.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/viewer.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/spacesampler.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/environment.h
${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/plugininfo.h)
add_custom_target(interfacehashes_target ALL DEPENDS ${interfacehashes_h} ${EXTRA_MSVC_DEPEND})
# math libraries
find_package(GMP)
find_package(GMPXX)
find_package(MPFR 2.4)
if( MPFR_FOUND )
check_library_exists(${MPFR_LIBRARIES} mpfr_div_d "${MPFR_LIBRARIES_DIR}" MPFR_DIV_D_FOUND)
if( NOT MPFR_DIV_D_FOUND )
message(WARNING "MPFR verison too old, does not support mpfr_div_d function")
set(MPFR_FOUND 0)
endif()
endif()
find_package(MPFI)
if( OPT_ACCURATEMATH AND NOT MSVC AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES aarch64 )
check_library_exists(crlibm crlibm_init "" CRLIBM_FOUND_LIB)
check_include_file(crlibm.h HAVE_CRLIBM_H)
if(NOT CRLIBM_FOUND_LIB OR NOT HAVE_CRLIBM_H)
message(STATUS "Using local crlibm")
add_subdirectory(3rdparty/crlibm-1.0beta4)
set(CRLIBM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/crlibm-1.0beta4")
set(NATIVE_CRLIBM_LIBRARY crlibm-native)
else()
set(NATIVE_CRLIBM_LIBRARY crlibm)
endif()
set(CRLIBM_FOUND 1)
set(CRLIBM_LIBRARY crlibm)
else()
set(CRLIBM_FOUND 0)
endif()
#if( MSVC )
# # MSVC has prepackaged assimp libraries
# set(ASSIMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/msvc_assimp)
#endif()
find_package(ASSIMP)
if( NOT ASSIMP_FOUND )
pkg_check_modules(ASSIMP assimp)
endif()
if( ASSIMP_FOUND )
message(STATUS "assimp version ${ASSIMP_VERSION}, ${ASSIMP_PACKAGE_VERSION}, ${ASSIMP_INCLUDE_DIRS}")
# For older versions of libassimp2,
# like the one in Ubuntu 12.04
set(CMAKE_REQUIRED_LIBRARIES assimp)
check_cxx_source_compiles("
#include <assimp/Logger.h>
int main()
{
Assimp::Logger::WARN;
return 0;
}"
IS_ASSIMP_PRE_R896
)
set(CMAKE_REQUIRED_LIBRARIES)
if( ${ASSIMP_VERSION} STRGREATER "2.0.0" )
set(IS_ASSIMP3 1)
endif()
endif()
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
check_cxx_source_runs("
int main()
{
int a = 0;
int*pa = &a;
asm(\".intel_syntax\\\\n\"
\"mov %%rax, %0\\\\n\"
\"mov %%eax, [%%rax]\\\\n\"
\".att_syntax\\\\n\"
: : \"r\"(pa) : \"%rax\");
return 0;
}"
IS_X86_64)
if( IS_X86_64 )
add_definitions("-D__x86_64__")
endif()
else()
set(IS_X86_64 0)
endif()
check_library_exists(rt clock_gettime "" CLOCK_GETTIME_FOUND)
if( CLOCK_GETTIME_FOUND )
add_definitions(-DCLOCK_GETTIME_FOUND)
endif()
find_package(RapidJSON)
if( RAPIDJSON_FOUND )
include_directories(${RAPIDJSON_INCLUDES})
else()
message(FATAL_ERROR "rapidjson library not found")
endif()
set(OPENRAVE_MSGPACK 0)
if( OPT_MSGPACK )
pkg_check_modules(msgpack msgpack)
if( msgpack_FOUND )
set(OPENRAVE_MSGPACK 1)
endif()
endif()
find_package(LibXml2)
if( LIBXML2_FOUND )
include_directories(${LIBXML2_INCLUDE_DIR})
add_definitions(${LIBXML2_DEFINITIONS})
message(STATUS "libxml2 found")
else()
if( MSVC )
set(LIBXML2_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/msvc_libxml2/lib/libxml2-${MSVC_PREFIX}-mt.lib)
set(LIBXML2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msvc_libxml2/include)
set(LIBXML2_DEFINITIONS)
set(LIBXML2_FOUND 1)
include_directories(${LIBXML2_INCLUDE_DIR})
# have to copy the DLLs, but not the other stuff in the lib dir
file(GLOB libxml_dlls "${CMAKE_CURRENT_SOURCE_DIR}/msvc_libxml2/lib/*-${MSVC_PREFIX}-*.dll")
install(FILES ${libxml_dlls} DESTINATION bin COMPONENT ${COMPONENT_PREFIX}base)
else()
message(FATAL_ERROR "Could not find libxml2")
endif()
endif()
# for qtcoin plugin.
# it is necessary to check here since we would like the qt version stored in the openrave-config file
if( WIN32 )
if( NOT ENV{QTDIR} )
# should fix this
message(STATUS "Setting QTDIR=C:/Qt/4.7.1, msvc qt installer by default installs to C:/Qt")
set(ENV{QTDIR} "C:/Qt/4.7.1")
endif()
endif()
find_package(Qt5 COMPONENTS Core Gui Widgets OpenGL)
if (NOT (Qt5Gui_FOUND AND Qt5Core_FOUND AND Qt5Widgets_FOUND AND Qt5OpenGL_FOUND))
message(STATUS "WARNING: Qt5 not found, is your QTDIR enviornment variable set?")
find_package(Qt5Core)
find_package(Qt5Gui)
if( Qt5Core_FOUND AND Qt5Gui_FOUND )
message(STATUS "Found Qt5")
else()
message(STATUS "Disabling QtCoin GUI plugin")
endif()
endif ()
link_directories(${OPENRAVE_LINK_DIRS})
# always include libpcrecpp since we need it for URL parsing
pkg_check_modules(libpcrecpp libpcrecpp)
if( libpcrecpp_FOUND )
set(CMAKE_REQUIRED_INCLUDES ${libpcrecpp_INCLUDE_DIRS} ${REQUIRED_INCLUDES})
check_include_file_cxx(pcrecpp.h HAVE_PCRECPP_H)
set(CMAKE_REQUIRED_INCLUDES)
if( NOT HAVE_PCRECPP_H )
set(libpcrecpp_FOUND 0)
endif()
endif()
if( NOT libpcrecpp_FOUND )
message(STATUS "System pcre not found, using local from sources")
# include the local pcre
add_subdirectory(3rdparty/pcre-8.02)
set(libpcrecpp_FOUND 1)
endif()
if( OPT_COLLADA )
if( MSVC )
# MSVC has prepackaged collada libraries
set(COLLADA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/msvc_collada)
endif()
#find_package(COLLADA_DOM 2.4 COMPONENTS 1.5 1.4 PATHS ${COLLADA_PATH})
find_package(COLLADA_DOM 2.3 COMPONENTS 1.5 PATHS ${COLLADA_PATH})
if( COLLADA_DOM_FOUND )
if( COLLADA_DOM_VERSION VERSION_LESS "2.5.0" )
message(STATUS "collada version ${COLLADA_DOM_VERSION} does not support write to memory")
set(COLLADA_SUPPORT_WRITE_MEMORY 0)
else()
message(STATUS "collada version ${COLLADA_DOM_VERSION} supports write to memory")
set(COLLADA_SUPPORT_WRITE_MEMORY 1)
endif()
endif()
find_package(ZLIB)
if( NOT ZLIB_FOUND )
message(STATUS "compiling zlib from souces")
# compile from sources
add_subdirectory(3rdparty/zlib)
endif()
pkg_check_modules(minizip minizip)
if(minizip_FOUND)
set(MINIZIP_INCLUDE_DIR ${minizip_INCLUDE_DIRS})
else()
add_subdirectory(3rdparty/minizip)
set(MINIZIP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/minizip ${ZLIB_INCLUDE_DIR})
endif()
if( COLLADA_DOM_FOUND )
if( MSVC )
# have to copy the DLLs, but not the other stuff in the lib dir
file(GLOB collada_dlls "${COLLADA_DOM_LIBRARY_DIRS}/*-${MSVC_PREFIX}-*.dll")
install(FILES ${collada_dlls} DESTINATION bin COMPONENT ${COMPONENT_PREFIX}base)
endif()
else()
if( ZLIB_FOUND AND Boost_FILESYSTEM_FOUND AND Boost_SYSTEM_FOUND )
add_subdirectory(3rdparty/collada-2.4.0)
else()
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
endif()
endif()
endif()
if( COLLADA_DOM_FOUND )
# because several programs rely on linking with openrave-core, need to expose the link library
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
else()
message(STATUS "no COLLADA support found")
endif()
link_directories(${OPENRAVE_LINK_DIRS})
# have to rely on the ivcon converter as a backup plan since assimp does not support iv/vrml
add_subdirectory(3rdparty/ivcon)
set(IVCON_FOUND 1)
set(IVCON_LIBRARY ivcon)
set(IVCON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ivcon")
## check qhull library
check_library_exists(qhull_r qh_new_qhull "" QHULL_REENTRANT_FOUND_LIB)
check_include_file(libqhull_r/libqhull_r.h HAVE_QHULL_REENTRANT_H)
if( QHULL_REENTRANT_FOUND_LIB AND HAVE_QHULL_REENTRANT_H )
set(QHULL_FOUND 1)
set(QHULL_USE_REENTRANT 1)
set(QHULL_INCLUDE_DIR)
message(STATUS "Use reentrant qhull")
else()
check_library_exists(qhull qh_new_qhull "" QHULL_FOUND_LIB)
check_include_file(qhull/qhull_a.h HAVE_QHULL_H)
if( QHULL_FOUND_LIB AND HAVE_QHULL_H )
set(QHULL_FOUND 1)
set(QHULL_INCLUDE_DIR)
else()
# have to compile from sources
message(STATUS "compiling local qhull library")
add_subdirectory(3rdparty/qhull)
set(QHULL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty")
set(QHULL_FOUND 1)
endif()
endif()
## check ANN library
check_include_file_cxx(ANN/ANN.h HAVE_ANN_H)
if( HAVE_ANN_H )
# _Z8annClosev is the gcc c++ mangled name of annClose
check_library_exists(ANN _Z8annClosev "" ANN_FOUND_CXX_LIB)
if( NOT ANN_FOUND_CXX_LIB )
check_library_exists(ANN annClose "" ANN_FOUND_C_LIB)
endif()
if(ANN_FOUND_C_LIB OR ANN_FOUND_CXX_LIB)
set(ANN_FOUND_LIB 1)
else()
set(ANN_FOUND_LIB 0)
endif()
if( NOT ANN_FOUND_LIB )
message(STATUS "Found ANN headers but not library!")
endif()
endif()
if( ANN_FOUND_LIB AND HAVE_ANN_H )
set(ANN_FOUND 1)
set(ANN_INCLUDE_DIR)
set(ANN_CFLAGS)
else()
# have to compile from sources
message(STATUS "compiling local ann library")
add_subdirectory(3rdparty/ann)
set(ANN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ann/include")
set(ANN_CFLAGS "-DANN_STATIC_LIBRARY")
set(ANN_FOUND 1)
endif()
#if( OPT_FLANN )
# find_package(FLANN)
# if( NOT FLANN_FOUND)
# ## check FLANN library
# set(BUILD_MATLAB_BINDINGS false)
# if( OPT_PYTHON AND PYTHON_EXECUTABLE )
# set(BUILD_PYTHON_BINDINGS true)
# else()
# set(BUILD_PYTHON_BINDINGS false)
# endif()
# set(BUILD_C_BINDINGS true)
# message(STATUS "compiling local flann library")
# add_subdirectory(3rdparty/flann-1.6.6)
# set(FLANN_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/flann-1.6.6/src/cpp")
# set(FLANN_FOUND 1) # use flann_cpp_s to link statically
# endif()
#endif()
# function expression parser library
find_package(fparser 4.5)
if( fparser_FOUND )
message(STATUS "Found fparser, version ${fparser_VERSION}")
set(FPARSER_INCLUDE_DIRS "${fparser_INCLUDE_DIR}")
set(FPARSER_LIBRARIES "${fparser_LIBRARY}")
set(FPARSER_CXX_FLAGS "${fparser_CXX_FLAGS} -DOPENRAVE_FPARSER_SETEPSILON")
set(FPARSER_LINK_FLAGS "${fparser_LINK_FLAGS}")
else()
if( PKG_CONFIG_FOUND )
pkg_search_module(FPARSER fparser)
endif()
if( NOT FPARSER_FOUND )
message(STATUS "compiling local fparser library")
add_subdirectory(3rdparty/fparser-4.5.2)
set(FPARSER_CXX_FLAGS "${FPARSER_CXX_FLAGS} -DOPENRAVE_FPARSER_SETEPSILON")
else()
set(FPARSER_CXX_FLAGS "${FPARSER_CFLAGS}")
set(FPARSER_LINK_FLAGS "${FPARSER_LDFLAGS}")
message(STATUS "using fparser from pkg-config, cflags: ${FPARSER_CFLAGS}, link flags: ${FPARSER_LINK_FLAGS}")
set(FPARSER_CXX_FLAGS "${FPARSER_CXX_FLAGS} -DOPENRAVE_FPARSER_SETEPSILON")
endif()
endif()
# log4cxx logging lib
set(OPENRAVE_LOG4CXX 0)
set(OPENRAVE_LOG4CXX_INCLUDE_DIRS)
set(OPENRAVE_LOG4CXX_LIB_DIRS)
set(OPENRAVE_LOG4CXX_LIBRARY)
if( OPT_LOG4CXX )
pkg_check_modules(LOG4CXX liblog4cxx)
if( LOG4CXX_FOUND )
if( MSVC )
set(OPENRAVE_LOG4CXX_INCLUDE_DIRS "/I\"${LOG4CXX_INCLUDEDIR}\"")
set(OPENRAVE_LOG4CXX_LIB_DIRS "/LIBPATH:\"${LOG4CXX_LIBDIR}\"")
else()
set(OPENRAVE_LOG4CXX_INCLUDE_DIRS "-I${LOG4CXX_INCLUDEDIR}")
set(OPENRAVE_LOG4CXX_LIB_DIRS "-L${LOG4CXX_LIBDIR}")
endif()
set(OPENRAVE_LOG4CXX_LIBRARY "-l${LOG4CXX_LIBRARIES}")
include_directories(${LOG4CXX_INCLUDEDIR})
set(OPENRAVE_LINK_DIRS ${OPENRAVE_LINK_DIRS} ${LOG4CXX_LIBDIR})
set(OPENRAVE_LOG4CXX 1)
endif()
endif()
link_directories(${OPENRAVE_LINK_DIRS})
message(STATUS "compiling local convexdecomposition library")
add_subdirectory(3rdparty/convexdecomposition)
set(CONVEXDECOMPOSITION_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/convexdecomposition")
if( UNIX )
set(CONVEXDECOMPOSITION_CFLAGS "-DLINUX")
else()
set(CONVEXDECOMPOSITION_CFLAGS "")
endif()
set(CONVEXDECOMPOSITION_FOUND 1)
if( Boost_FILESYSTEM_FOUND AND Boost_SYSTEM_FOUND )
add_definitions(-DHAVE_BOOST_FILESYSTEM)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/openrave/config.h IMMEDIATE @ONLY)
add_subdirectory(src)
add_subdirectory(octave_matlab)
add_subdirectory(locale)
if(OPT_PYTHON AND PYTHON_EXECUTABLE)
set(OPENRAVE_USE_LOCAL_SYMPY 1)
if( PYTHON_EXECUTABLE )
# get the sympy version
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sympy; print sympy.__version__"
OUTPUT_VARIABLE _sympy_version OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _sympy_version_failed)
if( ${_sympy_version_failed} EQUAL 0 )
string(REGEX REPLACE "[\r\n]" "" _sympy_version "${_sympy_version}")
message(STATUS "Found sympy version '${_sympy_version}'")
if( "${_sympy_version}" VERSION_GREATER "0.6.3" OR "${_sympy_version}" VERSION_EQUAL "0.6.3" )
set(OPENRAVE_USE_LOCAL_SYMPY 0)
if( "${_sympy_version}" VERSION_LESS "0.6.7" OR "${_sympy_version}" VERSION_EQUAL "0.6.7" )
message(STATUS "Found sympy version 0.6.x, will patch this instead of installing local version")
else()
message(STATUS "Assuming sympy version 0.7.x or greater")
endif()
endif()
else()
message(STATUS "failed to find python sympy system installation")
endif()
endif()
# check if sympy substitution is ok
# execute_process(
# COMMAND ${PYTHON_EXECUTABLE} -c "import sympy, sys; x=sympy.Symbol('x'); sys.exit((x**3).subs(x**2,sympy.Symbol('y')) != x**3)"
# OUTPUT_VARIABLE _sympy_check OUTPUT_STRIP_TRAILING_WHITESPACE
# RESULT_VARIABLE _sympy_check_failed)
# if( ${_sympy_check_failed} EQUAL 0 )
# set(OPENRAVE_USE_LOCAL_SYMPY 0)
# else()
if( OPENRAVE_USE_LOCAL_SYMPY )
message(STATUS "System sympy (v=${_sympy_version}) is not right version, using local sympy")
# extract sympy
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sympy/__init__.py" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sympy/solvers/tests")
message(STATUS "extracting sympy to ${CMAKE_CURRENT_SOURCE_DIR}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/sympy_0.7.1.tgz"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sympy" DESTINATION ${OPENRAVE_PYTHON_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE)
endif()
set( USE_OPENRAVEPY 1)
if( NOT WIN32 AND OPENRAVE_BIN_SUFFIX )
set(OPENRAVEPY_VER_NAME "_openravepy_${OPENRAVE_VERSION_MAJOR}_${OPENRAVE_VERSION_MINOR}")
else()
set(OPENRAVEPY_VER_NAME "_openravepy_")
endif()
set(OPENRAVEPY_VER_INSTALL_DIR "${OPENRAVEPY_INSTALL_DIR}/${OPENRAVEPY_VER_NAME}") # used by openrave-config.cmake
# build python bindings, either with pybind11 or Boost.Python
set(USE_PYBIND11_PYTHON_BINDINGS OFF CACHE BOOL "Build OpenRAVE's python bindings with pybind11 (ON) or Boost.Python (OFF)")
add_subdirectory(python)
endif()
# plugins have to be after python since they could use openravepy extensions
if(OPT_PLUGINS)
add_subdirectory(plugins)
endif()
if( WIN32 )
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave-config.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave-config.cpp" IMMEDIATE @ONLY)
add_executable(openrave-config "${CMAKE_CURRENT_BINARY_DIR}/openrave-config.cpp")
set_target_properties(openrave-config PROPERTIES OUTPUT_NAME openrave${OPENRAVE_BIN_SUFFIX}-config)
install(TARGETS openrave-config DESTINATION bin COMPONENT ${COMPONENT_PREFIX}base)
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave-config.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}-config" IMMEDIATE @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}-config DESTINATION bin COMPONENT ${COMPONENT_PREFIX}base)
endif()
if( OPT_BUILD_PACKAGE_DEFAULT AND OPENRAVE_BIN_SUFFIX )
# create all the directories ahead of time, or otherwise WORKING_DIRECTORY will not work
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory \${CMAKE_INSTALL_PREFIX}/bin COMMAND ${CMAKE_COMMAND} -E make_directory \${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig COMMAND ${CMAKE_COMMAND} -E make_directory \${CMAKE_INSTALL_PREFIX}/${BASH_COMPLETION_DIR})" COMPONENT openrave)
InstallSymlink(${CMAKE_INSTALL_PREFIX}/bin/openrave${OPENRAVE_BIN_SUFFIX}-config ${CMAKE_INSTALL_PREFIX}/bin/openrave-config)
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave-config.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave-config-version.cmake" IMMEDIATE @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openrave-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/openrave-config-version.cmake" DESTINATION "lib${LIB_SUFFIX}/cmake/${OPENRAVE_CMAKE_INSTALL_DIR}" COMPONENT ${COMPONENT_PREFIX}dev)
if( UNIX OR CYGWIN)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave_completion.bash.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave_completion.bash" @ONLY IMMEDIATE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openrave_completion.bash" DESTINATION ${OPENRAVE_SHARE_DIR} COMPONENT ${COMPONENT_PREFIX}base )
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}.pc" @ONLY IMMEDIATE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig COMPONENT ${COMPONENT_PREFIX}dev)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave-core.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}-core.pc" @ONLY IMMEDIATE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openrave${OPENRAVE_BIN_SUFFIX}-core.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig COMPONENT ${COMPONENT_PREFIX}dev)
if( OPT_BUILD_PACKAGE_DEFAULT AND OPENRAVE_BIN_SUFFIX )
InstallSymlink(${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/openrave${OPENRAVE_BIN_SUFFIX}.pc ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/openrave.pc)
InstallSymlink(${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/openrave${OPENRAVE_BIN_SUFFIX}-core.pc ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/openrave-core.pc)
if( BASH_COMPLETION_DIR )
get_filename_component(BASH_COMPLETION_ABSOLUTE_DIR ${CMAKE_INSTALL_PREFIX}/${BASH_COMPLETION_DIR} ABSOLUTE)
get_filename_component(BASH_COMPLETION_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/${OPENRAVE_SHARE_DIR} ABSOLUTE)
file(RELATIVE_PATH BASH_COMPLETION_RELATIVE_DIR ${BASH_COMPLETION_ABSOLUTE_DIR} ${BASH_COMPLETION_SHARE_DIR})
InstallSymlink(${BASH_COMPLETION_RELATIVE_DIR}/openrave_completion.bash ${BASH_COMPLETION_ABSOLUTE_DIR}/openrave_completion.bash)
endif()
endif()
# don't need symlinks
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/openrave.bash.in" "${CMAKE_CURRENT_BINARY_DIR}/openrave.bash" IMMEDIATE @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openrave.bash DESTINATION ${OPENRAVE_SHARE_DIR} COMPONENT ${COMPONENT_PREFIX}base)
endif()
file(GLOB rave_header_files ${CMAKE_CURRENT_SOURCE_DIR}/include/openrave/*.h)
install(FILES ${rave_header_files} ${interfacehashes_h} ${CMAKE_CURRENT_BINARY_DIR}/include/openrave/config.h DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/openrave COMPONENT ${COMPONENT_PREFIX}dev)
if( OPT_CBINDINGS )
file(GLOB rave_cheader_files ${CMAKE_CURRENT_SOURCE_DIR}/include/openrave_c/*.h)
install(FILES ${rave_cheader_files} DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/openrave_c COMPONENT ${COMPONENT_PREFIX}cbindings-dev)
endif()
install(FILES rave/rave.h rave/plugin.h DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/rave COMPONENT ${COMPONENT_PREFIX}dev) # deprecated
install(FILES COPYING LICENSE.lgpl LICENSE.apache DESTINATION ${OPENRAVE_SHARE_DIR} COMPONENT ${COMPONENT_PREFIX}base)
#install(EXPORT openrave-targets DESTINATION lib/cmake/openrave-${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR})
# add make uninstall capability
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/modules-cmake/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")
if(CMAKE_CPACK_COMMAND AND UNIX AND OPT_BUILD_PACKAGES)
# Packing information
set(CPACK_PACKAGE_NAME OpenRAVE)
set(CPACK_PACKAGE_CONTACT "OpenRAVE Testing (Testing and Releasing of OpenRAVE Packages) <openrave.testing@gmail.com>" CACHE STRING "Package maintainer and PGP signer.")
set(CPACK_PACKAGE_VENDOR "http://openrave.org")
set(CPACK_PACKAGE_DISPLAY_NAME "OpenRAVE ${OPENRAVE_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "- Open Robotics Automation Virtual Environment")
if( OPT_DOUBLE_PRECISION )
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} using double precision")
else()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} using single precision")
endif()
set(CPACK_PACKAGE_VERSION "${OPENRAVE_VERSION}.${PACKAGE_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENRAVE_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${OPENRAVE_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${OPENRAVE_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "openrave${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}" CACHE STRING "CPack install directory")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/docs/source/description.rst)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}BASE_REQUIRED 1)
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}BASE_DISPLAY_NAME "core libraries and tools")
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}DATA_DISPLAY_NAME "basic robots, models, and scene files used in the examples")
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}DEV_DISPLAY_NAME "development files and examples")
set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}DEV_DEPENDS ${COMPONENT_PREFIX}base libboost-thread-dev libboost-date-time-dev)
# necessary to add a circular dependency to ${CPACK_DEBIAN_PACKAGE_NAME}?
foreach(OPENRAVE_COMPONENT ${CPACK_COMPONENTS_ALL})
string(TOUPPER ${OPENRAVE_COMPONENT} UPPER_COMPONENT)
set( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS} openrave-minimal)
endforeach()
# base
set(CPACK_DEBIAN_BUILD_DEPENDS_UBUNTU debhelper cmake python-dev libxml2-dev libboost-dev ffmpeg zlib1g-dev python-numpy "python-sympy (>=0.6.3)" desktop-file-utils libboost-filesystem-dev libboost-system-dev libboost-python-dev libboost-thread-dev libboost-date-time-dev "octave3.2-headers|liboctave-dev" "collada-dom-dev (>=2.4.0)" pkg-config "fparser-dev (>=4.4.3)" libhdf5-serial-dev liblapack-dev gettext)
# add once infinite precision computations are enabled:
# libmpfr-dev libgmp3-dev libmpfi-dev libgmpxx4ldbl python-gmpy
# plugins:
set(CPACK_DEBIAN_BUILD_DEPENDS_UBUNTU ${CPACK_DEBIAN_BUILD_DEPENDS_UBUNTU} libboost-iostreams-dev libboost-regex-dev qtbase5-dev qtbase5-dev-tools libqhull-dev libavcodec-dev libavformat-dev libswscale-dev libsimage-dev libode-dev libsoqt4-dev "assimp-dev|libassimp-dev" libbullet-dev)# libopenscenegraph-dev)
# debian
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
set(CPACK_DEBIAN_PACKAGE_SECTION devel)