-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1563 lines (1416 loc) · 43.1 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.8.3)
project(VRPN)
#-----------------------------------------------------------------------------
# XXX Things to make better.
#
# Repeat for all other configurable headers/libraries - see below for a list
# Move the shared-library code over to CMake's normal definition
# Improve this CPack installer.
###
# Local CMake Modules - keep this first
###
list(APPEND CMAKE_MODULE_PATH ${VRPN_SOURCE_DIR}/cmake)
include(UseBackportedModules)
include(MSVCMultipleProcessCompile)
include(CppcheckTargets)
include(SetDefaultBuildType)
include(OptionRequires)
include(CTest)
include(CheckIncludeFileCXX)
if((NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) OR VRPN_SUBPROJECT_BUILD)
# If you're using this as a subproject and want things installed, set VRPN_INSTALL TRUE.
set(SUBPROJECT TRUE)
set(DEFAULT_OFF_IF_SUBPROJECT OFF_BY_DEFAULT)
set(TRUE_UNLESS_SUBPROJECT FALSE)
set(QUIET_IF_SUBPROJECT QUIET) # silently search for optional deps as a subproject
set(BUILD_TESTING FALSE) # don't build testing or create dashboard scripts if a subproject
else()
set(VRPN_INSTALL TRUE)
set(SUBPROJECT FALSE)
set(DEFAULT_OFF_IF_SUBPROJECT)
set(TRUE_UNLESS_SUBPROJECT TRUE)
set(QUIET_IF_SUBPROJECT)
include(CreateDashboardScripts)
endif()
###
# On Windows 7, it does not work to install in the default location,
# which is the Program Files directory, because you have to not only have
# file permission to write there but also "run as administrator." This
# means that "make install" from a Visual Studio project fails. To get
# around that, we need to set CMAKE_INSTALL_PREFIX to something other
# than the default. However, it is a cache variable that has already been
# set. If we make a local variable, it uses this rather than the cache
# variable and never tells the poor user what happened (the GUI location
# looks standard but the files end up somewhere else). If we make it a
# non-forced cache variable, it already has a value so does not change.
# If we make it a forced cache variable, it gets overwritten every time
# and the user cannot change it on the GUI. So we have a workaround here.
# We make a cache variable that records whether we have ever forced the
# install prefix. If not, we force it. If so, we don't force it again.
# This has the effect of setting it the first time cmake is run, showing
# the change in the GUI, and also letting the user change the value in
# the GUI if they don't like what we did. If I knew how to do this only
# happen on Windows 7, I'd make the if(WIN32) more specific.
if(WIN32 AND NOT SUBPROJECT)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
AND
(NOT
ONCE_SET_CMAKE_INSTALL_PREFIX))
set(ONCE_SET_CMAKE_INSTALL_PREFIX
true
CACHE
INTERNAL
"Have we set the install prefix yet?"
FORCE)
set(CMAKE_INSTALL_PREFIX
C:/usr/local
CACHE
PATH
"Install path prefix, prepended onto install directories"
FORCE)
endif()
endif()
###
# Basic packaging options and versioning
if (VRPN_INSTALL)
include("${CMAKE_CURRENT_SOURCE_DIR}/ParseVersion.cmake")
message(STATUS
"Configuring the VRPN suite version ${CPACK_PACKAGE_VERSION} using the CMake-based build system\n")
set(CPACK_PACKAGE_VENDOR
"VRPN Community led by Sensics, Inc.")
set(CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-src")
set(CPACK_PACKAGE_CONTACT "Sensics VRPN Contact <[email protected]>")
endif()
if (NOT SUBPROJECT)
#-----------------------------------------------------------------------------
# Compiler flags we got from Hans for Windows and from Sheldon Andrews
# for other architectures.
if(MSVC) # MS-Windows Visual Studio, both 32 and 64 bits
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
if(MSVC_VERSION GREATER 1310) # This compiler flag needs newer than VS.NET 2003 (7.1)
# Choose fast, possibly less accurate floating point
# See http://msdn.microsoft.com/en-us/library/e7s85ffb(v=vs.80).aspx
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
endif()
# Do not assume fixed base address (probably for DLL integration?)
# http://msdn.microsoft.com/en-us/library/w368ysh2(v=vs.80).aspx
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FIXED:NO")
else()
# GCC compilers on 64-bit machines require -fPIC for shared libraries or libs
# linked into shared libraries.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS}")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
endif()
endif()
set(SERVER_EXTRA_LIBS)
set(SERVER_LINK_FLAGS)
# Set up correct defines for Windows header compilation:
# This theoretically sets the lower-bound on operating system compatibility
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
# NT4 0x0400
# Win2k 0x0500
# WinXP 0x0501
# WS2003SP1/WinXPSP2 0x0502
# Vista 0x0600
# Win7 0x0601
# Win8 0x0602
# Win8.1 0x0603 (though some docs say 0x0602 with NTDDI_VERSION 0x06030000)
if(WIN32)
set(WIN_MIN_VER 0x0500) # Default to Windows 2000
if(MSVC AND MSVC_VERSION GREATER 1699)
# VS2012: defaults to vista+, update 1 added XP support in additional toolset.
if("${CMAKE_VS_PLATFORM_TOOLSET}" MATCHES "_xp")
set(WIN_MIN_VER 0x0501) # WinXP
else()
set(WIN_MIN_VER 0x0600) # Vista
endif()
endif()
add_definitions("-D_WIN32_WINNT=${WIN_MIN_VER}" "-DNTDDI_VERSION=${WIN_MIN_VER}0000")
endif()
#-----------------------------------------------------------------------------
# Options that control what gets built and how.
if(NOT SUBPROJECT)
# We can build two configurations (passing defs to the compile lines) - which ones do we want?
# Note that we can build both now, if desired!
option(VRPN_BUILD_CLIENT_LIBRARY
"Build the vrpn library including only client code"
ON)
option(VRPN_BUILD_SERVER_LIBRARY
"Build the vrpnserver library including client and server code"
ON)
# Build various applications if we want them.
option(VRPN_BUILD_CLIENTS "Build VRPN client apps and tests" ON)
option(VRPN_BUILD_SERVERS "Build VRPN servers" ON)
# Development tools
if(MSVC_IDE AND MSVC_VERSION LESS 1600)
# VS 2012 Express and newer has folder support...
option(VRPN_BUILD_WITH_PROJECT_FOLDERS
"Use project folders in build system - not compatible with Visual C++ Express editions!"
OFF)
else()
set(VRPN_BUILD_WITH_PROJECT_FOLDERS ON)
endif()
set_property(GLOBAL
PROPERTY
USE_FOLDERS
${VRPN_BUILD_WITH_PROJECT_FOLDERS})
# Set a default build type
set_default_build_type("RelWithDebInfo")
endif()
# Force use of our CMake-processed configuration header before the stock one.
include_directories("${PROJECT_BINARY_DIR}")
# Include directory needed by all of the files
include_directories(${VRPN_SOURCE_DIR}
${VRPN_SOURCE_DIR}/atmellib
${VRPN_SOURCE_DIR}/quat)
#-----------------------------------------------------------------------------
# Libraries we need to do our thing.
#
# CMake variables:
# SERVER_EXTRA_LIBS - libraries to link against when building the server lib
# EXTRA_LIBS - libraries to link against when building any VRPN lib
#
# Note that library linking is, by default, transitive:
# Specify linking here (even though static libraries might not use it
# directly - think of shared libs and your fellow developer) rather than
# in the included apps.
###
# Quatlib
###
add_subdirectory(quat)
list(APPEND EXTRA_LIBS quat)
###
# Threading (not on win32)
###
if(NOT WIN32)
find_package(Threads REQUIRED ${QUIET_IF_SUBPROJECT})
list(APPEND EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif()
###
# Windows-specific (non-Cygwin) dependencies
###
if(WIN32 AND NOT UNIX)
# Winsock - needed for endianness conversion
list(APPEND EXTRA_LIBS ws2_32)
# Windows multimedia - needed for joywin32
list(APPEND EXTRA_LIBS winmm)
endif()
###
# Optional packages
###
if(NOT SUBPROJECT)
message(STATUS
"Now searching for auto-configurable optional packages...\n")
endif()
###
# Submodules - bundled libraries/sources
###
add_subdirectory(submodules)
###
# SWIG and Python Libs (for python wrappers)
###
find_package(SWIG ${QUIET_IF_SUBPROJECT})
set(CurrentPythonSettings
"${VRPN_BUILD_PYTHON}${VRPN_BUILD_PYTHON_HANDCODED_2X}${VRPN_BUILD_PYTHON_HANDCODED_3X}")
if(NOT CurrentPythonSettings STREQUAL _VRPN_PYTHON_SETTINGS)
set(vrpn_python_versionsearch)
set(vrpn_python_versionsearchargs)
if(VRPN_BUILD_PYTHON)
# Swig wants 2.x, I assume
set(vrpn_python_versionsearch 2)
set(Python_ADDITIONAL_VERSIONS "")
if(VRPN_BUILD_PYTHON_HANDCODED_3X)
message(FATAL_ERROR
"Can't build both SWIG (2.x) and hand-coded 3.x Python bindings. Disable either VRPN_BUILD_PYTHON or VRPN_BUILD_PYTHON_HANDCODED_3X.")
endif()
elseif(VRPN_BUILD_PYTHON_HANDCODED_3X
AND
VRPN_BUILD_PYTHON_HANDCODED_2X)
message(FATAL_ERROR
"Can't build handcoded Python bindings for both 2.x and 3.x versions. Pick one, please.")
elseif(VRPN_BUILD_PYTHON_HANDCODED_2X
AND
NOT
VRPN_BUILD_PYTHON_HANDCODED_3X)
set(vrpn_python_versionsearch 2)
set(Python_ADDITIONAL_VERSIONS "")
elseif(VRPN_BUILD_PYTHON_HANDCODED_3X
AND
NOT
VRPN_BUILD_PYTHON_HANDCODED_2X)
set(vrpn_python_versionsearch 3)
set(Python_ADDITIONAL_VERSIONS 3.4)
endif()
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_INCLUDE_DIR)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY)
set(_VRPN_PYTHON_VERSIONSEARCH
${vrpn_python_versionsearch}
CACHE
INTERNAL
""
FORCE)
set(_VRPN_PYTHON_SETTINGS
${CurrentPythonSettings}
CACHE
INTERNAL
""
FORCE)
endif()
# Passing just the major version works with as desired multi-python-capable find module such
# as in latest CMake (2.8.9)
find_package(PythonLibs ${_VRPN_PYTHON_VERSIONSEARCH} ${QUIET_IF_SUBPROJECT})
if(PYTHONLIBS_FOUND)
if(PYTHONLIBS_VERSION_STRING)
string(SUBSTRING
${PYTHONLIBS_VERSION_STRING}
0
1
vrpn_python_majorver)
set(PYTHON${vrpn_python_majorver}_FOUND ON)
elseif(PYTHON_LIBRARY MATCHES "python([23])")
set(PYTHON${CMAKE_MATCH_1}_FOUND ON)
elseif(_VRPN_PYTHON_VERSIONSEARCH)
set(PYTHON${_VRPN_PYTHON_VERSIONSEARCH}_FOUND ON)
else()
message(STATUS
"Warning: found python but couldn't determine which version. Please set either VRPN_PYTHON_IS_3 or VRPN_PYTHON_IS_2")
option(VRPN_PYTHON_IS_3 "Python found is version 3.x" OFF)
option(VRPN_PYTHON_IS_2 "Python found is version 2.x" OFF)
if(VRPN_PYTHON_IS_3 AND VRPN_PYTHON_IS_2)
unset(VRPN_PYTHON_IS_2 CACHE)
unset(VRPN_PYTHON_IS_3 CACHE)
message(FATAL_ERROR
"If needed, please set either VRPN_PYTHON_IS_3 or VRPN_PYTHON_IS_2, not both!")
elseif(VRPN_PYTHON_IS_3)
set(PYTHON3_FOUND ON)
elseif(VRPN_PYTHON_IS_2)
set(PYTHON2_FOUND ON)
endif()
endif()
endif()
# If MSVC, and we don't have a debug lib, default to off, or the default (debug runtime) build is broken.
if(MSVC AND NOT PYTHON_LIBRARY_DEBUG)
set(PYTHON_DEFAULT_OFF OFF_BY_DEFAULT)
else()
set(PYTHON_DEFAULT_OFF ${DEFAULT_OFF_IF_SUBPROJECT})
endif()
option_requires(VRPN_BUILD_PYTHON
"Build VRPN Python 2.x SWIG-based bindings"
${PYTHON_DEFAULT_OFF}
SWIG_FOUND
PYTHON2_FOUND)
option_requires(VRPN_BUILD_PYTHON_HANDCODED_2X
"Build VRPN Python handcoded bindings for Python 2.x"
${PYTHON_DEFAULT_OFF}
PYTHON2_FOUND)
option_requires(VRPN_BUILD_PYTHON_HANDCODED_3X
"Build VRPN Python handcoded bindings for Python 3.x"
${PYTHON_DEFAULT_OFF}
PYTHON3_FOUND)
###
# javac, jar, and javah (for java wrapper)
###
if(ANDROID AND DEFINED find_host_package)
find_host_package(Java COMPONENTS Development)
find_host_package(JNI)
find_host_program(JAVAH_EXECUTABLE NAMES javah)
else()
find_package(Java COMPONENTS Development ${QUIET_IF_SUBPROJECT})
find_package(JNI ${QUIET_IF_SUBPROJECT})
find_program(JAVAH_EXECUTABLE NAMES javah)
endif()
mark_as_advanced(JAVAH_EXECUTABLE)
option_requires(VRPN_BUILD_JAVA
"Build VRPN Java bindings"
${DEFAULT_OFF_IF_SUBPROJECT}
Java_JAVAC_EXECUTABLE
Java_JAR_EXECUTABLE
JNI_FOUND
JAVAH_EXECUTABLE)
###
# MPI
###
find_package(MPI ${QUIET_IF_SUBPROJECT})
# XXX Safe to enable by default if we find it?
option_requires(VRPN_USE_MPI
"Build with MPI support"
OFF_BY_DEFAULT
MPI_FOUND)
if(VRPN_USE_MPI)
# XXX what else needs to be done here?
add_definitions(${MPI_COMPILE_FLAGS})
include_directories(${MPI_INCLUDE_PATH})
list(APPEND EXTRA_LIBS ${MPI_LIBRARIES})
endif()
###
# Modbus library
###
find_package(Modbus ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_MODBUS
"Build with Modbus support"
OFF_BY_DEFAULT
MODBUS_FOUND)
if(VRPN_USE_MODBUS)
# XXX what else needs to be done here?
include_directories(${MODBUS_INCLUDE_DIR})
list(APPEND EXTRA_LIBS ${MODBUS_LIBRARY})
endif()
###
# Libusb1
###
find_package(Libusb1 ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_LIBUSB_1_0
"Attempt to use LibUSB-1.0 to talk directly to USB devices."
${DEFAULT_OFF_IF_SUBPROJECT}
LIBUSB1_FOUND)
if(VRPN_USE_LIBUSB_1_0)
include_directories(${LIBUSB1_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${LIBUSB1_LIBRARIES})
endif()
###
# HID and HIDAPI
###
# Setting up the local HIDAPI was handled above, in the submodules directory
if(NOT VRPN_USE_LOCAL_HIDAPI)
find_package(HIDAPI ${QUIET_IF_SUBPROJECT})
endif()
# HID requires either local or system-installed HIDAPI
# Both set HIDAPI_FOUND, HIDAPI_LIBRARIES, and HIDAPI_INCLUDE_DIRS
# If the user chose VRPN_USE_LOCAL_HIDAPI, the HIDAPI_SOURCES
# variable, as included in the source list below, will also be set.
option_requires(VRPN_USE_HID
"Build with support for HID devices using HIDAPI"
${DEFAULT_OFF_IF_SUBPROJECT}
HIDAPI_FOUND)
if(VRPN_USE_HID)
include_directories(${HIDAPI_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${HIDAPI_LIBRARIES})
option(VRPN_BUILD_HID_GUI
"Should we build a GUI for analyzing live HID streams?"
OFF)
option(VRPN_HID_DEBUGGING
"Should verbose debugging messages be displayed during HID interactions?"
off)
if(VRPN_HID_DEBUGGING)
add_definitions(-DVRPN_HID_DEBUGGING)
endif()
else()
# Clear this variable if they don't want HID after all.
if (VRPN_USE_LOCAL_HIDAPI)
message(STATUS
"NOTE: You have VRPN_USE_LOCAL_HIDAPI enabled, but "
"VRPN_USE_HID disabled: HIDAPI will only be built if you enable HID support for VRPN")
endif()
set(HIDAPI_SOURCES)
endif()
###
# Sensable "OpenHaptics" HDAPI/HLAPI
###
find_package(OpenHaptics ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_HDAPI
"Allow SensAble Phantom support through HDAPI/HLAPI - VRPN_USE_PHANTOM_SERVER must still be set"
${DEFAULT_OFF_IF_SUBPROJECT}
OPENHAPTICS_FOUND)
if(VRPN_USE_HDAPI)
set(PHANTOM_POSSIBLE ON)
endif()
###
# Sensable GHOST
###
if(NOT VRPN_USE_HDAPI)
find_package(GHOST ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_GHOST
"Allow SensAble Phantom support through GHOST - VRPN_USE_PHANTOM_SERVER must still be set"
${DEFAULT_OFF_IF_SUBPROJECT}
GHOST_FOUND)
if(VRPN_USE_GHOST)
if(NOT ${GHOST_LIBRARIES} MATCHES ".*40.*")
message(STATUS "GHOST pre-4.0 detected - calling it 3.1.")
set(VRPN_USE_GHOST_31 ON)
endif()
set(PHANTOM_POSSIBLE ON)
endif()
endif()
###
# Sensable PHANToM Support - Overall Option
###
option_requires(VRPN_USE_PHANTOM_SERVER
"Build with SensAble Phantom support"
${DEFAULT_OFF_IF_SUBPROJECT}
PHANTOM_POSSIBLE)
if(VRPN_USE_PHANTOM_SERVER)
if(VRPN_USE_HDAPI)
include_directories(${OPENHAPTICS_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${OPENHAPTICS_LIBRARIES})
else()
# VRPN_USE_GHOST
include_directories(${GHOST_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${GHOST_LIBRARIES})
endif()
endif()
###
# libi2c-dev
###
find_package(libi2c-dev ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_I2CDEV
"Build devices requiring libi2c-dev"
${DEFAULT_OFF_IF_SUBPROJECT}
I2CDEV_FOUND)
if(VRPN_USE_I2CDEV)
include_directories(AFTER ${I2CDEV_INCLUDE_DIRS})
endif()
###
# WiiUse
###
find_package(WiiUse ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_WIIUSE
"Build with WiiUse library support (makes servers GPL)"
${DEFAULT_OFF_IF_SUBPROJECT}
WIIUSE_FOUND)
if(VRPN_USE_WIIUSE)
include_directories(${WIIUSE_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${WIIUSE_LIBRARIES})
endif()
###
# JsonCpp
##
## Setting up the local JSONCPP was handled above, in the submodules directory
if(NOT VRPN_USE_LOCAL_JSONCPP)
find_package(JsonCpp ${QUIET_IF_SUBPROJECT})
endif()
option_requires(VRPN_USE_JSONNET
"Build with JSONCPP (for Android widgets and other UDP JSON-based APIs)"
${DEFAULT_OFF_IF_SUBPROJECT}
JSONCPP_FOUND)
if(VRPN_USE_JSONNET)
include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${JSONCPP_LIBRARY})
else()
set(JSONCPP_SOURCES)
endif()
###
# libnifalcon
###
find_package(LibNifalcon ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_LIBNIFALCON
"Build with libnifalcon support to access Novint Falcon devices"
${DEFAULT_OFF_IF_SUBPROJECT}
LIBNIFALCON_FOUND)
if(VRPN_USE_LIBNIFALCON)
include_directories(${LIBNIFALCON_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${LIBNIFALCON_LIBRARIES})
endif()
###
# DirectInput and XInput
###
if(WIN32)
find_package(DirectX ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_DIRECTINPUT
"Build with Microsoft DirectInput support"
${DEFAULT_OFF_IF_SUBPROJECT}
DIRECTX_DXGUID_LIBRARY
DIRECTX_DINPUT_LIBRARY
DIRECTX_DINPUT_INCLUDE_DIR
DIRECTX_SDK_SUPPORTS_COMPILER)
if(VRPN_USE_DIRECTINPUT)
include_directories(${DIRECTX_INCLUDE_DIRS})
list(APPEND
SERVER_EXTRA_LIBS
${DIRECTX_DXGUID_LIBRARY}
${DIRECTX_DINPUT_LIBRARY})
if(MSVC)
# Delay-load DirectInput DLL
# TODO is this always the right name
# TODO how to do this with MinGW? Can we? Do we need to?
list(APPEND SERVER_LINK_FLAGS "/DELAYLOAD:dinput8.dll")
list(APPEND SERVER_EXTRA_LIBS "delayimp.lib")
endif()
endif()
# XInput - enhanced API for XBOX 360 controllers and more.
find_directx_include(DIRECTX_XINPUT_INCLUDE_DIR
xinput.h)
option_requires(VRPN_USE_WINDOWS_XINPUT
"Build with Microsoft XInput support"
${DEFAULT_OFF_IF_SUBPROJECT}
DIRECTX_XINPUT_INCLUDE_DIR
DIRECTX_XINPUT_LIBRARY
DIRECTX_SDK_SUPPORTS_COMPILER) #TODO will this be a valid check here?
if(VRPN_USE_WINDOWS_XINPUT)
list(APPEND
SERVER_EXTRA_LIBS
${DIRECTX_XINPUT_LIBRARY})
mark_as_advanced(DIRECTX_XINPUT_INCLUDE_DIR)
# Get name of DLL to delay-load.
include(GetDefineString)
get_define_string(NAME XINPUT_DLL
INCLUDES windows.h xinput.h
DEFINES "-D_WIN32_WINNT=${WIN_MIN_VER}"
INCLUDE_DIRS ${DIRECTX_DINPUT_INCLUDE_DIR} ${DIRECTX_XINPUT_INCLUDE_DIR}
RESULT VRPN_XINPUT_DLL)
if(VRPN_XINPUT_DLL AND MSVC)
# Delay-load XInput DLL
# TODO how to do this with MinGW? Can we? Do we need to?
list(APPEND SERVER_LINK_FLAGS "/DELAYLOAD:${VRPN_XINPUT_DLL}")
list(APPEND SERVER_EXTRA_LIBS "delayimp.lib")
endif()
endif()
# ATL is used for the vrpn_Tracker_zSight (which is based on DirectInput)
# to provide a smart pointer, but ATL isn't always available.
include(CheckIncludeFileCXX)
check_include_file_cxx(atlbase.h VRPN_HAVE_ATLBASE)
endif()
###
# DirectShow
###
# Note that header removal makes this harder for VS10 and later - you need an earlier
# version of MSVC also installed or an older Windows/Platform SDK with qedit.h in it.
if(MSVC)
if(MSVC_VERSION GREATER 1500)
set(DIRECTSHOW_OFF_BY_DEFAULT OFF_BY_DEFAULT)
else()
set(DIRECTSHOW_OFF_BY_DEFAULT)
endif()
find_package(DirectShow ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_DIRECTSHOW
"Build with Microsoft DirectShow support"
${DIRECTSHOW_OFF_BY_DEFAULT}
DIRECTSHOW_FOUND)
option_requires(VRPN_BUILD_DIRECTSHOW_VIDEO_SERVER
"Enable to build DirectShow Video Server (Windows)"
${DEFAULT_OFF_IF_SUBPROJECT}
VRPN_BUILD_DIRECTSHOW_VIDEO_SERVER
DIRECTSHOW_FOUND)
endif()
###
# GPM
###
if(UNIX)
find_package(GPM ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_GPM_MOUSE
"Build with GPM Linux mouse interface support (makes servers GPL)"
${DEFAULT_OFF_IF_SUBPROJECT}
GPM_FOUND)
endif()
if(VRPN_USE_GPM_MOUSE)
list(APPEND SERVER_EXTRA_LIBS ${GPM_LIBRARIES})
endif()
###
# INTERSENSE
###
find_package(InterSense ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_INCLUDE_INTERSENSE
"Build with InterSense support"
${DEFAULT_OFF_IF_SUBPROJECT}
INTERSENSE_FOUND)
if(VRPN_INCLUDE_INTERSENSE)
include_directories(${INTERSENSE_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${INTERSENSE_LIBRARIES})
endif()
###
# THALMICLABSMYO
###
if(WIN32)
find_package(ThalmicLabsMyo ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_INCLUDE_THALMICLABSMYO
"Build with Thalmic Labs' Myo support"
${DEFAULT_OFF_IF_SUBPROJECT}
THALMICLABSMYO_FOUND)
if(VRPN_INCLUDE_THALMICLABSMYO)
include_directories(${THALMICLABSMYO_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${THALMICLABSMYO_LIBRARIES})
add_definitions(-DVRPN_INCLUDE_THALMICLABSMYO)
endif()
endif()
###
# NIDAQMX
###
find_package(NIDAQmx ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_NATIONAL_INSTRUMENTS_MX
"Build with National Instruments NIDAQMX support"
${DEFAULT_OFF_IF_SUBPROJECT}
NIDAQMX_FOUND)
if(VRPN_USE_NATIONAL_INSTRUMENTS_MX)
include_directories(${NIDAQMX_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${NIDAQMX_LIBRARIES})
endif()
###
# Arrington Research ViewPoint EyeTracker
###
find_package(ViewPoint ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_VIEWPOINT
"Build with support for ViewPoint EyeTracker"
${DEFAULT_OFF_IF_SUBPROJECT}
VIEWPOINT_FOUND)
if(VRPN_USE_VIEWPOINT)
include_directories(${VIEWPOINT_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${VIEWPOINT_LIBRARIES})
# Needed for the config file, apparently - it was added to the non-CMake one.
get_filename_component(VRPN_VIEWPOINT_LIB_PATH
"${VIEWPOINT_LIBRARY}"
PATH)
file(TO_CMAKE_PATH
"${VRPN_VIEWPOINT_LIB_PATH}"
VRPN_VIEWPOINT_LIB_PATH)
endif()
###
# Adrienne timecode boards
###
if(WIN32 OR CYGWIN)
find_package(Adrienne ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_INCLUDE_TIMECODE_SERVER
"Build with support for Adrienne timecode server"
${DEFAULT_OFF_IF_SUBPROJECT}
ADRIENNE_FOUND)
else()
set(VRPN_INCLUDEE_TIMECODE_SERVER OFF)
endif()
if(VRPN_INCLUDE_TIMECODE_SERVER)
set(VRPN_ADRIENNE_INCLUDE_FILENAME "${ADRIENNE_INCLUDE_FILENAME}")
set(VRPN_ADRIENNE_INCLUDE_HAS_EXTERN_C
${ADRIENNE_INCLUDE_HAS_EXTERN_C})
endif()
###
# Linux kernel joystick interface
###
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
check_include_file_cxx(linux/joystick.h HAVE_LINUX_JOYSTICK_H)
option_requires(VRPN_USE_JOYLIN
"Build with support for Linux kernel joystick interface (Uses kernel header - may make servers GPL)"
${DEFAULT_OFF_IF_SUBPROJECT}
HAVE_LINUX_JOYSTICK_H)
else()
set(VRPN_USE_JOYLIN OFF)
endif()
###
# /dev/input kernel joystick interface
###
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
check_include_file_cxx(linux/input.h HAVE_LINUX_INPUT_H)
option_requires(VRPN_USE_DEV_INPUT
"Build with flags to enable the use of DevInput. (Uses kernel header - may make servers GPL)"
${DEFAULT_OFF_IF_SUBPROJECT}
HAVE_LINUX_INPUT_H)
else()
set(VRPN_USE_DEV_INPUT OFF)
endif()
###
# Perl, for vrpn_rpc_gen
###
if(NOT WIN32)
# TODO - a bit of a compatibility hack
# MiKTeX 2.9's perl is broken - missing libgcc-s-sjlj-1.dll -
# and can't seem to work around it without popping up dialogs
# which is no fun for automated builds.
find_package(Perl ${QUIET_IF_SUBPROJECT})
find_package(PerlModules ${QUIET_IF_SUBPROJECT} COMPONENTS Parse::RecDescent)
endif()
option_requires(VRPN_BUILD_TEST_RPC_GENERATION
"Build VRPN RPC generation"
${DEFAULT_OFF_IF_SUBPROJECT}
PERL_FOUND
PERLMODULES_FOUND)
###
# Polhemus PDI library
###
# TODO Generalize this to use a FindPDI.cmake - someone with access
# to this library must do it.
# Make this also work with debug (use PDID)
option(VRPN_USE_PDI
"Build with flags to enable the use of Polhemus DVI library."
OFF)
if(VRPN_USE_PDI)
find_path(POLHEMUS_PDI_DIR NAMES "Inc" "Lib" PATH_SUFFIXES "PDI_140" "PDI_110" "PDI_90" PATHS "C:/Polhemus/PDI" "C:/Program Files (x86)/Polhemus/PDI" NO_DEFAULT_PATH)
include_directories(${POLHEMUS_PDI_DIR}/Inc)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND SERVER_EXTRA_LIBS "${POLHEMUS_PDI_DIR}/Lib/x64/PDI.lib")
else()
list(APPEND SERVER_EXTRA_LIBS "${POLHEMUS_PDI_DIR}/Lib/Win32/PDI.lib")
endif()
endif()
###
# PhaseSpace API
###
# TODO Actually do a proper search for the PhaseSpace API headers and libraries
# and not use link_directories.
option(VRPN_INCLUDE_PHASESPACE
"Build with PhaseSpace library support"
OFF)
set(PHASESPACE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/phasespace" CACHE PATH "location of PhaseSpace headers")
set(PHASESPACE_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/phasespace" CACHE PATH "location of PhaseSpace libraries (libowlsock.so, etc")
if(VRPN_INCLUDE_PHASESPACE)
include_directories(${PHASESPACE_INCLUDE_DIR})
link_directories(${PHASESPACE_LIBRARY_DIR})
if(WIN32)
list(APPEND SERVER_EXTRA_LIBS libowlsock)
else()
list(APPEND SERVER_EXTRA_LIBS owlsock)
endif()
endif()
###
# Hillcrest Labs' Freespace
###
find_package(LibFreespace ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_FREESPACE
"Build with Hillcrest Labs' Freespace devices support"
${DEFAULT_OFF_IF_SUBPROJECT}
LIBFREESPACE_FOUND)
if(VRPN_USE_FREESPACE)
include_directories(${LIBFREESPACE_INCLUDE_DIRS})
list(APPEND SERVER_EXTRA_LIBS ${LIBFREESPACE_LIBRARIES})
endif()
###
# MotionNode tracker support. Loads shared library dynamically if available
###
option(VRPN_USE_MOTIONNODE
"Build with MotionNode tracker support"
OFF)
if(VRPN_USE_MOTIONNODE)
list(APPEND SERVER_EXTRA_LIBS ${CMAKE_DL_LIBS})
endif()
###
# Trivisio ColibriAPI
###
find_package(ColibriApi ${QUIET_IF_SUBPROJECT})
option_requires(VRPN_USE_COLIBRIAPI
"Build with Trivisio ColibriAPI support"
OFF_BY_DEFAULT
COLIBRIAPI_FOUND)
if(VRPN_USE_COLIBRIAPI)
include_directories(${COLIBRIAPI_INCLUDE_DIR})
list(APPEND SERVER_EXTRA_LIBS ${COLIBRIAPI_LIBRARIES})
endif()
###
# XXX Other libraries needing detection and handling (TODO)
###
# National Instruments Nidaq traditional
# US Digital SEI/A2
# microscribe3D library
#
# All include paths should be moved out of at least vrpn_Configure.h.cmake_in
# as well as all #pragma comment (lib, "" ) lines, since cmake replaces
# them more flexibly (include_directories and target_link_libraries)
# Configuration options controlling what gets included in the build.
# These are the default options for libraries we can't yet detect -
# if a library can be detected above it will be pre-set to an appropriate
# value by default.
option(VRPN_USE_NATIONAL_INSTRUMENTS
"Build with National Instruments (old library) support"
OFF)
option(VRPN_USE_NIDAQ "Build with NIDAQ support ca. 1999" OFF)
option(VRPN_USE_USDIGITAL
"Build with US Digital SEI/A2 library support"
OFF)
option(VRPN_USE_MICROSCRIBE
"Build with MicroScribe3D library support"
OFF)
option(VRPN_USE_TRIVISIOCOLIBRI
"(OBSOLETE) Build with support for TrivisioColibri tracker"
OFF)
if(WIN32)
option(VRPN_USE_WINSOCK2
"Use Winsock2 library, rather than Winsock."
OFF)
option(VRPN_USE_SHARED_LIBRARY
"Enable to use DLLs on Windows (see vrpn_Configure.h for more info)"
OFF)
endif()
if(UNIX)
option(VRPN_BUILD_PROFILING_SUPPORT
"Build with flags to enable profiling."
OFF)
if(VRPN_BUILD_PROFILING_SUPPORT)
include(EnableProfiling)
globally_enable_profiling()
endif()
endif()
if(WIN32 AND NOT CYGWIN)
# Only intended for Windows, known not needed on Cygwin,
# but potentially hazardous on other Windows build environments.
option(VRPN_EXPORT_GETTIMEOFDAY "Use a #define to make gettimeofday a synonym for vrpn_gettimeofday." OFF)
else()
set(VRPN_EXPORT_GETTIMEOFDAY OFF)
endif()
# This will only work on compilers that support C++-11.
# We could check for this and turn it on by default.
set(VRPN_CHRONO_DEFAULT OFF)
if(MSVC AND MSVC_VERSION GREATER 1800)
# On MSVC 2015 and newer, std::chrono provides the best time implementation.
set(VRPN_CHRONO_DEFAULT ON)
endif()
option(VRPN_USE_STD_CHRONO "Use the std::chrono class for time" ${VRPN_CHRONO_DEFAULT})
option(VRPN_USE_STATIC_ASSERTIONS "Use some compile-time assertions" ON)
option(VRPN_BUILD_EXTRA_COMPILER_WARNINGS
"Build with flags to enable extra warnings."
OFF)
if(VRPN_BUILD_EXTRA_COMPILER_WARNINGS)
include(EnableExtraCompilerWarnings)
globally_enable_extra_compiler_warnings()
if(NOT MSVC)
# shadowing virtual functions is pretty much unavoidable with the
# multiple inheritance design and methods like "report_changes"
check_cxx_compiler_flag(-Wno-overloaded-virtual SUPPORTS_WNO_OVERLOADED_VIRTUAL_FLAG)
if(SUPPORTS_WNO_OVERLOADED_VIRTUAL_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
endif()
endif()
endif()
set(VRPN_CLIENT_ONLY)
if(VRPN_BUILD_CLIENT_LIBRARY AND NOT VRPN_BUILD_SERVER_LIBRARY)
# We can define VRPN_CLIENT_ONLY in the header in this case!
set(VRPN_CLIENT_ONLY ON)
endif()
#-----------------------------------------------------------------------------
# configure a header file to pass some of the CMake settings
# to the source code
configure_file("${PROJECT_SOURCE_DIR}/vrpn_Configure.h.cmake_in"
"${PROJECT_BINARY_DIR}/vrpn_Configure.h")
set(VRPN_PATH_TO_CMAKE_CONFIG "${PROJECT_BINARY_DIR}/vrpn_Configure.h")
add_definitions("-DVRPN_USING_CMAKE=\"${VRPN_PATH_TO_CMAKE_CONFIG}\"")
if(SUBPROJECT)
set(BUILD_TESTING FALSE)
endif()
if(APPLE)
# XXX Is this still needed?
if(NOT CMAKE_INSTALL_NAME_DIR)
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()
endif()
#-----------------------------------------------------------------------------
# Build the library itself and declare what bits need to be installed
set(VRPN_CLIENT_SOURCES
vrpn_Analog.C
vrpn_Analog_Output.C
vrpn_Assert.C
vrpn_Auxiliary_Logger.C
vrpn_BaseClass.C
vrpn_Button.C