-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
1565 lines (1513 loc) · 93.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
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.16)
if(${CMAKE_VERSION} VERSION_LESS "3.12")
message(WARNING "CMake < 3.12 is not fully supported...")
endif()
#if(POLICY CMP0053)
#cmake_policy(SET CMP0053 OLD)
#endif()
set(ProgramFilesx86 "ProgramFiles(x86)")
#if(POLICY CMP0076)
#cmake_policy(SET CMP0076 OLD)
#endif()
project(UxVCtrl)
if(NOT(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR))
message(WARNING "Please set the CMake build folder to the same as the source folder if possible...")
message(WARNING "Ensure also the working directory at runtime is UxVCtrl folder...")
endif()
option(OPENCV2413 "OPENCV2413" OFF)
option(OPENCV320 "OPENCV320" OFF)
option(OPENCV342 "OPENCV342" OFF)
option(OPENCV420 "OPENCV420" OFF)
option(OPENCV454 "OPENCV454" ON)
option(RPLIDARSDK1120 "RPLIDARSDK1120" OFF)
option(RPLIDARSDK200 "RPLIDARSDK200" ON)
if(WIN32)
if(NOT DEFINED ARCH)
# First attempt to guess...
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "x64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH "x86")
else()
message(WARNING "Unknown architecture, please try to set manually ARCH and RUNTIME variables...")
endif()
if(MSVC)
# Get cl target bitness
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
set(ARCH "x64")
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win64")
set(ARCH "x64")
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x86")
set(ARCH "x86")
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
set(ARCH "x86")
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
set(ARCH "ARM64")
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM")
set(ARCH "ARM")
endif()
endif()
endif()
if(NOT DEFINED RUNTIME)
if(MSVC)
if(MSVC_TOOLSET_VERSION EQUAL 80)
set(RUNTIME "vc8")
elseif(MSVC_TOOLSET_VERSION EQUAL 90)
set(RUNTIME "vc9")
elseif(MSVC_TOOLSET_VERSION EQUAL 100)
set(RUNTIME "vc10")
elseif(MSVC_TOOLSET_VERSION EQUAL 110)
set(RUNTIME "vc11")
elseif(MSVC_TOOLSET_VERSION EQUAL 120)
set(RUNTIME "vc12")
elseif(MSVC_TOOLSET_VERSION EQUAL 140)
set(RUNTIME "vc14")
elseif(MSVC_TOOLSET_VERSION EQUAL 141)
set(RUNTIME "vc15")
elseif(MSVC_TOOLSET_VERSION EQUAL 142)
set(RUNTIME "vc16")
elseif(MSVC_TOOLSET_VERSION EQUAL 143)
set(RUNTIME "vc17")
elseif(MSVC_TOOLSET_VERSION EQUAL 144)
set(RUNTIME "vc18")
else()
message(WARNING "Unknown Visual Studio compiler, please try to set manually ARCH and RUNTIME variables...")
set(RUNTIME "vc10") # MSVC_TOOLSET_VERSION not set probably because an old version of CMake on XP with hopefully the latest Visual Studio for XP...
endif()
elseif(MINGW)
set(RUNTIME "mingw")
else()
message(WARNING "Unknown compiler, please try to set manually ARCH and RUNTIME variables...")
endif()
endif()
else()
if(NOT DEFINED ARCH)
# CMAKE_SYSTEM_PROCESSOR...?
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "x86_64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH "i386")
else()
message(WARNING "Unknown architecture, please try to set manually ARCH and USR_LIB_ARCH_DIR variables...")
endif()
endif()
if(NOT DEFINED USR_LIB_ARCH_DIR)
if(APPLE)
set(USR_LIB_ARCH_DIR "/usr/local/lib")
else()
if("${ARCH}" STREQUAL "x86_64")
set(USR_LIB_ARCH_DIR "/usr/lib/${ARCH}-linux-gnu")
elseif("${ARCH}" STREQUAL "i386")
set(USR_LIB_ARCH_DIR "/usr/lib/${ARCH}-linux-gnu")
else()
message(WARNING "Unknown architecture, please try to set manually ARCH and USR_LIB_ARCH_DIR variables...")
set(USR_LIB_ARCH_DIR "/usr/lib")
endif()
endif()
endif()
endif()
if(WIN32 AND ((NOT DEFINED LIBPREFIXRUNTIME) OR (NOT DEFINED LIBEXTRUNTIME)))
if(MSVC)
set(LIBPREFIXRUNTIME "")
set(LIBEXTRUNTIME ".lib")
elseif(MINGW)
set(LIBPREFIXRUNTIME "lib")
set(LIBEXTRUNTIME ".dll.a")
else()
message(WARNING "Please try to set manually LIBPREFIXRUNTIME and LIBEXTRUNTIME variables...")
endif()
endif()
option(ENABLE_AUTO_DOWNLOAD "ENABLE_AUTO_DOWNLOAD" ON)
if(WIN32)
#set(SUDO_COMMAND "elevate" CACHE STRING "SUDO_COMMAND")
set(INSTALL_PKG_COMMAND "choco install -y -r --no-progress" CACHE STRING "INSTALL_PKG_COMMAND")
set(OPENCV_PKG_NAME "opencv --package-parameters '/Environment:C:\\tools\\opencv\\build'" CACHE STRING "OPENCV_PKG_NAME")
#set(OPENCV_PKG_NAME "libopencv-dev" CACHE STRING "OPENCV_PKG_NAME")
#set(LIBMODBUS_PKG_NAME "libmodbus" CACHE STRING "LIBMODBUS_PKG_NAME")
set(LIBMODBUS_PKG_PREFIX "$ENV{ProgramFiles}" CACHE STRING "LIBMODBUS_PKG_PREFIX")
set(FFMPEG_PKG_PREFIX "$ENV{ProgramFiles}" CACHE STRING "FFMPEG_PKG_PREFIX")
set(MAVLINK_PKG_PREFIX "$ENV{ProgramFiles}" CACHE STRING "MAVLINK_PKG_PREFIX")
set(SBG_SDK_PKG_PREFIX "$ENV{ProgramFiles}" CACHE STRING "SBG_SDK_PKG_PREFIX")
set(RPLIDAR_SDK_PKG_PREFIX "$ENV{ProgramFiles}" CACHE STRING "RPLIDAR_SDK_PKG_PREFIX")
option(ENABLE_FIND_PACKAGE_OPENCV "ENABLE_FIND_PACKAGE_OPENCV" OFF)
option(ENABLE_FIND_PACKAGE_LIBFREENECT2 "ENABLE_FIND_PACKAGE_LIBFREENECT2" OFF)
elseif(APPLE)
set(SUDO_COMMAND "sudo" CACHE STRING "SUDO_COMMAND")
set(INSTALL_PKG_COMMAND "brew install" CACHE STRING "INSTALL_PKG_COMMAND")
set(OPENCV_PKG_NAME "opencv" CACHE STRING "OPENCV_PKG_NAME")
set(LIBMODBUS_PKG_NAME "libmodbus" CACHE STRING "LIBMODBUS_PKG_NAME")
set(LIBMODBUS_PKG_PREFIX "/usr/local" CACHE STRING "LIBMODBUS_PKG_PREFIX")
set(FFMPEG_PKG_NAME "ffmpeg" CACHE STRING "FFMPEG_PKG_NAME")
set(FFMPEG_PKG_PREFIX "/usr/local" CACHE STRING "FFMPEG_PKG_PREFIX")
set(MAVLINK_PKG_PREFIX "/usr/local" CACHE STRING "MAVLINK_PKG_PREFIX")
set(SBG_SDK_PKG_PREFIX "/usr/local" CACHE STRING "SBG_SDK_PKG_PREFIX")
set(RPLIDAR_SDK_PKG_PREFIX "/usr/local" CACHE STRING "RPLIDAR_SDK_PKG_PREFIX")
option(ENABLE_FIND_PACKAGE_OPENCV "ENABLE_FIND_PACKAGE_OPENCV" ON)
option(ENABLE_FIND_PACKAGE_LIBFREENECT2 "ENABLE_FIND_PACKAGE_LIBFREENECT2" ON)
else()
set(SUDO_COMMAND "sudo" CACHE STRING "SUDO_COMMAND")
set(INSTALL_PKG_COMMAND "sudo apt-get -y install" CACHE STRING "INSTALL_PKG_COMMAND")
set(OPENCV_PKG_NAME "libopencv-dev" CACHE STRING "OPENCV_PKG_NAME")
set(LIBMODBUS_PKG_NAME "libmodbus-dev" CACHE STRING "LIBMODBUS_PKG_NAME")
set(LIBMODBUS_PKG_PREFIX "/usr/local" CACHE STRING "LIBMODBUS_PKG_PREFIX")
set(FFMPEG_PKG_NAME "libavcodec-dev" CACHE STRING "FFMPEG_PKG_NAME")
set(FFMPEG_PKG_PREFIX "/usr/local" CACHE STRING "FFMPEG_PKG_PREFIX")
set(MAVLINK_PKG_PREFIX "/usr/local" CACHE STRING "MAVLINK_PKG_PREFIX")
set(SBG_SDK_PKG_PREFIX "/usr/local" CACHE STRING "SBG_SDK_PKG_PREFIX")
set(RPLIDAR_SDK_PKG_PREFIX "/usr/local" CACHE STRING "RPLIDAR_SDK_PKG_PREFIX")
set(LIBFREENECT2_PREREQ_PKG_NAME "libusb-1.0-0-dev libturbojpeg0-dev libglfw3-dev" CACHE STRING "LIBFREENECT2_PREREQ_PKG_NAME")
option(ENABLE_FIND_PACKAGE_OPENCV "ENABLE_FIND_PACKAGE_OPENCV" ON)
option(ENABLE_FIND_PACKAGE_LIBFREENECT2 "ENABLE_FIND_PACKAGE_LIBFREENECT2" ON)
endif()
option(ENABLE_STATIC "ENABLE_STATIC" OFF)
if(ENABLE_STATIC)
set(STATIC_PREFIX "static" CACHE STRING "STATIC_PREFIX")
endif()
if(ENABLE_AUTO_DOWNLOAD)
if(WIN32)
message(STATUS "If behind a proxy, you might need to type e.g. \"set https_proxy=192.168.1.17:8080\" in the same terminal before running cmake-gui/cmake to configure the proxy settings...")
else()
message(STATUS "If behind a proxy, you might need to type e.g. \"export https_proxy=192.168.1.17:8080\" in the same terminal before running cmake-gui/cmake to configure the proxy settings...")
endif()
message(STATUS "If some prerequisites cannot be downloaded and installed automatically, try to install them manually and change ENABLE_AUTO_DOWNLOAD option in cmake-gui/cmake...")
endif()
if(ENABLE_AUTO_DOWNLOAD)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/../OSUtils")
message(STATUS "Downloading OSUtils...")
file(DOWNLOAD "https://github.com/ENSTABretagneRobotics/OSUtils/archive/master.zip" "${PROJECT_SOURCE_DIR}/../OSUtils.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/../OSUtils.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${PROJECT_SOURCE_DIR}/OSUtils-master" "${PROJECT_SOURCE_DIR}/../OSUtils")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/../OSUtils.zip")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/../Extensions")
message(STATUS "Downloading Extensions...")
file(DOWNLOAD "https://github.com/ENSTABretagneRobotics/Extensions/archive/master.zip" "${PROJECT_SOURCE_DIR}/../Extensions.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/../Extensions.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${PROJECT_SOURCE_DIR}/Extensions-master" "${PROJECT_SOURCE_DIR}/../Extensions")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/../Extensions.zip")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/../interval")
message(STATUS "Downloading interval...")
file(DOWNLOAD "https://github.com/ENSTABretagneRobotics/interval/archive/master.zip" "${PROJECT_SOURCE_DIR}/../interval.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/../interval.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${PROJECT_SOURCE_DIR}/interval-master" "${PROJECT_SOURCE_DIR}/../interval")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/../interval.zip")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/../matrix_lib")
message(STATUS "Downloading matrix_lib...")
file(DOWNLOAD "https://github.com/ENSTABretagneRobotics/matrix_lib/archive/master.zip" "${PROJECT_SOURCE_DIR}/../matrix_lib.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/../matrix_lib.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${PROJECT_SOURCE_DIR}/matrix_lib-master" "${PROJECT_SOURCE_DIR}/../matrix_lib")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/../matrix_lib.zip")
endif()
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES Observer.cpp NMEAInterface.cpp Main.cpp Globals.cpp Controller.cpp Config.cpp Computations.cpp Commands.cpp Hardware/ublox.cpp Hardware/RS232Port.cpp Hardware/RazorAHRS.cpp Hardware/Pololu.cpp Hardware/NMEADevice.cpp Hardware/I2CBus.cpp Hardware/gpControl.cpp ../interval/imatrix.cpp ../interval/rmatrix.cpp ../interval/box.cpp ../interval/interval.cpp ../interval/iboolean.cpp ../OSUtils/OSTimer.c ../OSUtils/OSTime.c ../OSUtils/OSThread.c ../OSUtils/OSSem.c ../OSUtils/OSNet.c ../OSUtils/OSMisc.c ../OSUtils/OSEv.c ../OSUtils/OSCriticalSection.c ../OSUtils/OSCore.c ../OSUtils/OSComputerRS232Port.c ../OSUtils/OSComputerI2CBus.c)
else()
add_executable(UxVCtrl Observer.cpp NMEAInterface.cpp Main.cpp Globals.cpp Controller.cpp Config.cpp Computations.cpp Commands.cpp Hardware/ublox.cpp Hardware/RS232Port.cpp Hardware/RazorAHRS.cpp Hardware/Pololu.cpp Hardware/NMEADevice.cpp Hardware/I2CBus.cpp Hardware/gpControl.cpp ../interval/imatrix.cpp ../interval/rmatrix.cpp ../interval/box.cpp ../interval/interval.cpp ../interval/iboolean.cpp ../OSUtils/OSTimer.c ../OSUtils/OSTime.c ../OSUtils/OSThread.c ../OSUtils/OSSem.c ../OSUtils/OSNet.c ../OSUtils/OSMisc.c ../OSUtils/OSEv.c ../OSUtils/OSCriticalSection.c ../OSUtils/OSCore.c ../OSUtils/OSComputerRS232Port.c ../OSUtils/OSComputerI2CBus.c)
endif()
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/../OSUtils")
include_directories("${PROJECT_SOURCE_DIR}/../Extensions/Img")
include_directories("${PROJECT_SOURCE_DIR}/../Extensions/Misc")
include_directories("${PROJECT_SOURCE_DIR}/../Extensions/Net")
include_directories("${PROJECT_SOURCE_DIR}/../interval")
include_directories("${PROJECT_SOURCE_DIR}/../matrix_lib")
include_directories("${PROJECT_SOURCE_DIR}/Hardware")
include_directories("${PROJECT_SOURCE_DIR}/..")
option(_DEBUG "_DEBUG" OFF)
option(_DEBUG_DISPLAY "_DEBUG_DISPLAY" OFF)
option(_DEBUG_MESSAGES "_DEBUG_MESSAGES" OFF)
option(_DEBUG_WARNINGS "_DEBUG_WARNINGS" OFF)
if(NOT MSVC)
option(ENABLE_VALGRIND_DEBUG "ENABLE_VALGRIND_DEBUG" OFF)
endif()
option(ENABLE_CVKINECT2SDKHOOK "ENABLE_CVKINECT2SDKHOOK" OFF)
if(WIN32)
option(USE_LIBFREENECT2 "USE_LIBFREENECT2" OFF)
option(ENABLE_CVCLEYESDKHOOK "ENABLE_CVCLEYESDKHOOK" OFF)
else()
option(USE_LIBFREENECT2 "USE_LIBFREENECT2" ON)
endif()
option(ENABLE_BLUEVIEW_SUPPORT "ENABLE_BLUEVIEW_SUPPORT" OFF)
option(ENABLE_MAVLINK_SUPPORT "ENABLE_MAVLINK_SUPPORT" OFF)
option(ENABLE_LABJACK_SUPPORT "ENABLE_LABJACK_SUPPORT" OFF)
option(ENABLE_LIBMODBUS_SUPPORT "ENABLE_LIBMODBUS_SUPPORT" OFF)
option(ENABLE_SBG_SDK_SUPPORT "ENABLE_SBG_SDK_SUPPORT" OFF)
option(DISABLE_SBG_TCP "DISABLE_SBG_TCP" OFF)
option(ENABLE_RPLIDAR_SDK_SUPPORT "ENABLE_RPLIDAR_SDK_SUPPORT" OFF)
if(RPLIDARSDK1120)
option(FORCE_RPLIDAR_SDK_V1 "FORCE_RPLIDAR_SDK_V1" ON)
else()
option(FORCE_RPLIDAR_SDK_V1 "FORCE_RPLIDAR_SDK_V1" OFF)
endif()
option(DISABLE_OPENCV_SUPPORT "DISABLE_OPENCV_SUPPORT" ON)
option(ENABLE_BUILD_OPTIMIZATION_SAILBOAT "ENABLE_BUILD_OPTIMIZATION_SAILBOAT" OFF)
option(USE_OPENCV_HIGHGUI_CPP_API "USE_OPENCV_HIGHGUI_CPP_API" OFF)
option(DISABLE_OPENCV_C_API_CTORS "DISABLE_OPENCV_C_API_CTORS" OFF)
if(WIN32)
option(ENABLE_OPENCV_HIGHGUI_THREADS_WORKAROUND "ENABLE_OPENCV_HIGHGUI_THREADS_WORKAROUND" OFF)
option(FORCE_SINGLE_THREAD_OPENCVGUI "FORCE_SINGLE_THREAD_OPENCVGUI" OFF)
else()
option(ENABLE_OPENCV_HIGHGUI_THREADS_WORKAROUND "ENABLE_OPENCV_HIGHGUI_THREADS_WORKAROUND" ON)
option(FORCE_SINGLE_THREAD_OPENCVGUI "FORCE_SINGLE_THREAD_OPENCVGUI" ON)
endif()
option(ENABLE_OPENCV_HIGHGUI_STARTWINDOWTHREAD "ENABLE_OPENCV_HIGHGUI_STARTWINDOWTHREAD" OFF)
option(ENABLE_SHARED_WAITKEY_OPENCVGUI "ENABLE_SHARED_WAITKEY_OPENCVGUI" OFF)
option(USE_FFMPEG_VIDEO "USE_FFMPEG_VIDEO" OFF)
option(DISABLE_AIS_SUPPORT "DISABLE_AIS_SUPPORT" OFF)
if(APPLE)
option(USE_OLD_CHRONO "USE_OLD_CHRONO" ON)
option(USE_OLD_TIMER "USE_OLD_TIMER" ON)
option(ENABLE_COMPUTERI2CBUS_SUPPORT "ENABLE_COMPUTERI2CBUS_SUPPORT" OFF)
else()
option(USE_OLD_CHRONO "USE_OLD_CHRONO" OFF)
option(USE_OLD_TIMER "USE_OLD_TIMER" OFF)
option(ENABLE_COMPUTERI2CBUS_SUPPORT "ENABLE_COMPUTERI2CBUS_SUPPORT" ON)
endif()
if(MINGW)
option(ENABLE_MINGW64_STDCALL_FIX "ENABLE_MINGW64_STDCALL_FIX" OFF)
endif()
mark_as_advanced(SUDO_COMMAND INSTALL_PKG_COMMAND OPENCV_PKG_NAME LIBMODBUS_PKG_NAME LIBMODBUS_PKG_PREFIX FFMPEG_PKG_NAME FFMPEG_PKG_PREFIX MAVLINK_PKG_PREFIX SBG_SDK_PKG_PREFIX RPLIDAR_SDK_PKG_PREFIX LIBFREENECT2_PREREQ_PKG_NAME _DEBUG _DEBUG_DISPLAY _DEBUG_MESSAGES _DEBUG_WARNINGS ENABLE_VALGRIND_DEBUG USE_LIBFREENECT2 ENABLE_CVCLEYESDKHOOK ENABLE_BUILD_OPTIMIZATION_SAILBOAT USE_OPENCV_HIGHGUI_CPP_API DISABLE_OPENCV_C_API_CTORS ENABLE_OPENCV_HIGHGUI_THREADS_WORKAROUND ENABLE_OPENCV_HIGHGUI_STARTWINDOWTHREAD ENABLE_SHARED_WAITKEY_OPENCVGUI USE_FFMPEG_VIDEO DISABLE_AIS_SUPPORT ENABLE_COMPUTERI2CBUS_SUPPORT)
if(ENABLE_BUILD_OPTIMIZATION_SAILBOAT)
add_definitions(-D ENABLE_BUILD_OPTIMIZATION_SAILBOAT)
endif()
if(ENABLE_BLUEVIEW_SUPPORT)
add_definitions(-D ENABLE_BLUEVIEW_SUPPORT)
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES Hardware/BlueView.cpp)
else()
target_sources(UxVCtrl PUBLIC Hardware/BlueView.cpp)
endif()
if(WIN32)
add_definitions(-D BVTSDK_VERSION=4)
set(BVTSDK_DIR "$ENV{ProgramFiles}/BlueView/bvtsdk")
if(ENABLE_AUTO_DOWNLOAD)
if(NOT EXISTS "${BVTSDK_DIR}/include/bvt_sdk.h")
message(STATUS "Downloading BlueView...")
file(DOWNLOAD "http://download.microsoft.com/download/C/6/D/C6D0FD4E-9E53-4897-9B91-836EBA2AACD3/vcredist_x86.exe" "${PROJECT_SOURCE_DIR}/vcredist_x86.exe")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND cmd /c vcredist_x86.exe /Q)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/vcredist_x86.exe")
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
file(DOWNLOAD "http://download.microsoft.com/download/A/8/0/A80747C3-41BD-45DF-B505-E9710D2744E0/vcredist_x64.exe" "${PROJECT_SOURCE_DIR}/vcredist_x64.exe")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND cmd /c vcredist_x64.exe /Q)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/vcredist_x64.exe")
endif()
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/bv.zip" "${PROJECT_SOURCE_DIR}/bv.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/bv.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{ProgramFiles}/BlueView")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/bv/bv_4.2.0.9526_win32/bvtsdk" "${BVTSDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/bv")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/bv.zip")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/cmake_extra_tools.zip" "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_extra_tools" COMMAND cmd /c pathman /as "$ENV{ProgramFiles}\\BlueView\\bvtsdk\\x86\\vc15\\bin")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_extra_tools" COMMAND cmd /c "sleep 5")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/cmake_extra_tools")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
endif()
endif()
include_directories("${BVTSDK_DIR}/include")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${BVTSDK_DIR}/x86/vc15/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"${BVTSDK_DIR}/x86/vc15/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES bvtsdk4)
else()
target_link_libraries(UxVCtrl bvtsdk4)
endif()
else()
if(ENABLE_AUTO_DOWNLOAD)
if((NOT EXISTS "/usr/local/include/bvt_sdk.h") AND (NOT EXISTS "/usr/include/bvt_sdk.h"))
message(STATUS "Downloading BlueView...")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/bv.zip" "${PROJECT_SOURCE_DIR}/bv.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/bv.zip")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p /usr/local/include")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p /usr/local/lib")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p /usr/include")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p /usr/lib")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -R \"${PROJECT_SOURCE_DIR}/bv/bv_3.5.0.5861_Ubuntu32_16.04.2/bvtsdk/include/\"* /usr/local/include/")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -R \"${PROJECT_SOURCE_DIR}/bv/bv_3.5.0.5861_Ubuntu32_16.04.2/bvtsdk/lib/\"* /usr/local/lib/")
else()
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -R \"${PROJECT_SOURCE_DIR}/bv/bv_3.5.0.6257_Ubuntu64_16.04.2/bvtsdk/include/\"* /usr/local/include/")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -R \"${PROJECT_SOURCE_DIR}/bv/bv_3.5.0.6257_Ubuntu64_16.04.2/bvtsdk/lib/\"* /usr/local/lib/")
endif()
execute_process(COMMAND sh -c "${SUDO_COMMAND} rm -f /usr/local/lib/libbvtsdk.so /usr/local/lib/libbvtsdk.so.3 /usr/local/lib/libbvtsdk.so.3.5")
execute_process(COMMAND sh -c "${SUDO_COMMAND} ln -s -f /usr/local/lib/libbvtsdk.so.3.5.0 /usr/local/lib/libbvtsdk.so")
execute_process(COMMAND sh -c "${SUDO_COMMAND} ln -s -f /usr/local/lib/libbvtsdk.so.3.5.0 /usr/local/lib/libbvtsdk.so.3")
execute_process(COMMAND sh -c "${SUDO_COMMAND} ln -s -f /usr/local/lib/libbvtsdk.so.3.5.0 /usr/local/lib/libbvtsdk.so.3.5")
execute_process(COMMAND sh -c "${SUDO_COMMAND} ln -s -f /usr/local/lib/libbv* /usr/lib/")
execute_process(COMMAND sh -c "${SUDO_COMMAND} chmod -R 777 /usr/local/include/bv*")
execute_process(COMMAND sh -c "${SUDO_COMMAND} chmod -R 777 /usr/local/lib/libbv*")
execute_process(COMMAND sh -c "${SUDO_COMMAND} chmod -R 777 /usr/lib/libbv*")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/bv")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/bv.zip")
endif()
endif()
include_directories("/usr/local/include")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES bvtsdk)
else()
target_link_libraries(UxVCtrl bvtsdk)
endif()
endif()
else()
if(WIN32)
if(EXISTS "$ENV{ProgramFiles}/BlueView/bvtsdk/include/bvt_sdk.h")
message(STATUS "BlueView has been detected, see ENABLE_BLUEVIEW_SUPPORT option to try to use it...")
endif()
else()
if((EXISTS "/usr/local/include/bvt_sdk.h") OR (EXISTS "/usr/include/bvt_sdk.h"))
message(STATUS "BlueView has been detected, see ENABLE_BLUEVIEW_SUPPORT option to try to use it...")
endif()
endif()
endif()
if(ENABLE_CVKINECT2SDKHOOK)
add_definitions(-D ENABLE_CVKINECT2SDKHOOK)
if(USE_LIBFREENECT2)
add_definitions(-D USE_LIBFREENECT2)
if(ENABLE_FIND_PACKAGE_LIBFREENECT2)
find_package(freenect2 QUIET)
find_package(GLFW3 QUIET)
find_package(OpenGL QUIET)
if(freenect2_VERSION VERSION_LESS "0.2")
if(ENABLE_AUTO_DOWNLOAD)
if(WIN32)
message(WARNING "libfreenect2 might need to be installed manually and the freenect2_DIR CMake variable might need to be set to e.g. $HOME/freenect2/lib/cmake/freenect2 (might need also to remove PKG_CONFIG_FOUND part in libfreenect2-master\cmake_modules\FindLibUSB.cmake and FindGLFW3.cmake)...")
elseif(APPLE)
message(WARNING "libfreenect2 might need to be installed manually and the freenect2_DIR CMake variable might need to be set to e.g. $HOME/freenect2/lib/cmake/freenect2...")
else()
message(STATUS "Trying to download libfreenect2, run \"${SUDO_COMMAND} apt-get update\" before if needed and check if the terminal is asking for a password...")
execute_process(COMMAND sh -c "${INSTALL_PKG_COMMAND} ${LIBFREENECT2_PREREQ_PKG_NAME}")
file(DOWNLOAD "https://github.com/OpenKinect/libfreenect2/archive/master.zip" "${PROJECT_SOURCE_DIR}/master.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/master.zip")
execute_process(COMMAND sh -c "cd \"${PROJECT_SOURCE_DIR}/libfreenect2-master\" && cmake . && make")
execute_process(COMMAND sh -c "cd \"${PROJECT_SOURCE_DIR}/libfreenect2-master\" && ${SUDO_COMMAND} make install")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/libfreenect2-master")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/master.zip")
find_package(freenect2 QUIET)
find_package(GLFW3 QUIET)
find_package(OpenGL QUIET)
endif()
endif()
endif()
include_directories(${freenect2_INCLUDE_DIR} ${GLFW3_INCLUDE_DIRS} ${flextGL_INCLUDE_DIRS})
# See https://github.com/glfw/glfw/issues/1030...
if(GLFW3_VERSION VERSION_GREATER "3.1.2")
if(NOT GLFW3_LIBRARIES)
set(GLFW3_LIBRARIES glfw)
endif()
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES ${freenect2_LIBRARIES} ${GLFW3_LIBRARIES} ${OPENGL_gl_LIBRARY})
else()
target_link_libraries(UxVCtrl ${freenect2_LIBRARIES} ${GLFW3_LIBRARIES} ${OPENGL_gl_LIBRARY})
endif()
else()
if((NOT EXISTS "$ENV{LIBFREENECT2_DIR}/include/libfreenect2/libfreenect2.hpp") AND (NOT EXISTS "/usr/local/include/libfreenect2/libfreenect2.hpp") AND (NOT EXISTS "/usr/include/libfreenect2/libfreenect2.hpp"))
message(WARNING "libfreenect2 might need to be installed manually and the LIBFREENECT2_DIR environment variable might need to be set (might need also to remove PKG_CONFIG_FOUND part in libfreenect2-master\cmake_modules\FindLibUSB.cmake and FindGLFW3.cmake)...")
endif()
include_directories("$ENV{LIBFREENECT2_DIR}/include")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{LIBFREENECT2_DIR}/lib/\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{LIBFREENECT2_DIR}/lib/\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES freenect2)
else()
target_link_libraries(UxVCtrl freenect2)
endif()
endif()
else()
if(ENABLE_AUTO_DOWNLOAD)
if(NOT EXISTS "$ENV{KINECTSDK20_DIR}/inc/Kinect.h")
message(WARNING "Kinect v2 SDK might need to be installed manually and the KINECTSDK20_DIR environment variable might need to be set to e.g. C:\\Program Files\\Microsoft SDKs\\Kinect\\v2.0_1409\\...")
message(STATUS "Downloading Kinect v2 SDK...")
file(DOWNLOAD "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe" "${PROJECT_SOURCE_DIR}/vcredist_x86.exe")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND cmd /c vcredist_x86.exe /Q)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/vcredist_x86.exe")
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
file(DOWNLOAD "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe" "${PROJECT_SOURCE_DIR}/vcredist_x64.exe")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND cmd /c vcredist_x64.exe /Q)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/vcredist_x64.exe")
endif()
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/KinectSDK-v2.0.zip" "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{ProgramFiles}/Microsoft SDKs/Kinect")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0/v2.0_1409.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/v2.0_1409" "$ENV{ProgramFiles}/Microsoft SDKs/Kinect/v2.0_1409")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND cmd /c setx KINECTSDK20_DIR "$ENV{ProgramFiles}\\Microsoft SDKs\\Kinect\\v2.0_1409\\\\" /m ) # The SDK installer adds a '\' at the end, and setx sometimes uses this character to escape commas...
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0/x64/Kinect20.dll" "$ENV{SystemRoot}/System32/Kinect20.dll")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0/x86/Kinect20.dll" "$ENV{SystemRoot}/SysWOW64/Kinect20.dll")
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0/x86/Kinect20.dll" "$ENV{SystemRoot}/System32/Kinect20.dll")
endif()
file(DOWNLOAD "https://download.microsoft.com/download/E/6/8/E688A436-5937-41CB-AF76-498E99E19191/KinectRuntime-v2.2_1905.zip" "${PROJECT_SOURCE_DIR}/KinectRuntime-v2.2_1905.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/KinectRuntime-v2.2_1905.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/drivers/x64" COMMAND cmd /c pnputil -i -a kinectsensor.inf)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/drivers" "${PROJECT_SOURCE_DIR}/v2.0_1409" "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/KinectRuntime-v2.2_1905.zip" "${PROJECT_SOURCE_DIR}/KinectSDK-v2.0.zip")
include_directories("$ENV{ProgramFiles}/Microsoft SDKs/Kinect/v2.0_1409/inc")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{ProgramFiles}/Microsoft SDKs/Kinect/v2.0_1409/Lib/${ARCH}\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{ProgramFiles}/Microsoft SDKs/Kinect/v2.0_1409/Lib/${ARCH}\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
else()
if(NOT EXISTS "$ENV{KINECTSDK20_DIR}/inc/Kinect.h")
message(WARNING "Kinect v2 SDK might need to be installed manually and the KINECTSDK20_DIR environment variable might need to be set to e.g. C:\\Program Files\\Microsoft SDKs\\Kinect\\v2.0_1409\\...")
endif()
endif()
include_directories("$ENV{KINECTSDK20_DIR}/inc")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{KINECTSDK20_DIR}/Lib/${ARCH}\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{KINECTSDK20_DIR}/Lib/${ARCH}\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES Kinect20)
else()
target_link_libraries(UxVCtrl Kinect20)
endif()
endif()
endif()
if(ENABLE_CVCLEYESDKHOOK)
add_definitions(-D ENABLE_CVCLEYESDKHOOK)
include_directories("$ENV{CLEYESDK_DIR}/Include")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{CLEYESDK_DIR}/Lib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{CLEYESDK_DIR}/Lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES CLEyeMulticam)
else()
target_link_libraries(UxVCtrl CLEyeMulticam)
endif()
endif()
if(ENABLE_MAVLINK_SUPPORT)
add_definitions(-D ENABLE_MAVLINK_SUPPORT)
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES VectorNavInterface.cpp MAVLinkInterface.cpp Hardware/MAVLinkDevice.cpp)
else()
target_sources(UxVCtrl PUBLIC VectorNavInterface.cpp MAVLinkInterface.cpp Hardware/MAVLinkDevice.cpp)
endif()
if(WIN32)
set(MAVLINK_SDK_DIR "${MAVLINK_PKG_PREFIX}/MAVLinkSDK")
if(ENABLE_AUTO_DOWNLOAD)
if(NOT EXISTS "${MAVLINK_PKG_PREFIX}/MAVLinkSDK/mavlink/common/mavlink.h")
message(STATUS "Downloading mavlink...")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/MAVLinkSDK.zip" "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/MAVLinkSDK" "${MAVLINK_SDK_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/MAVLinkSDK")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
endif()
endif()
include_directories("${MAVLINK_SDK_DIR}")
else()
if(ENABLE_AUTO_DOWNLOAD)
if((NOT EXISTS "${MAVLINK_PKG_PREFIX}/include/mavlink/common/mavlink.h") AND (NOT EXISTS "/usr/include/mavlink/common/mavlink.h"))
message(STATUS "Downloading mavlink...")
#file(DOWNLOAD "https://github.com/mavlink/c_library_v2/archive/master.zip" "${PROJECT_SOURCE_DIR}/master.zip")
#execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/master.zip")
#execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p ${MAVLINK_PKG_PREFIX}/include")
#execute_process(COMMAND sh -c "${SUDO_COMMAND} mv -f \"${PROJECT_SOURCE_DIR}/c_library_v2-master\" ${MAVLINK_PKG_PREFIX}/include/mavlink")
#execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/master.zip")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/MAVLinkSDK.zip" "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p ${MAVLINK_PKG_PREFIX}/include")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mv -f \"${PROJECT_SOURCE_DIR}/MAVLinkSDK/mavlink\" ${MAVLINK_PKG_PREFIX}/include/mavlink")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/MAVLinkSDK")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/MAVLinkSDK.zip")
endif()
endif()
include_directories("${MAVLINK_PKG_PREFIX}/include")
endif()
else()
if(WIN32)
if(EXISTS "${MAVLINK_PKG_PREFIX}/MAVLinkSDK/mavlink/common/mavlink.h")
message(STATUS "mavlink has been detected, see ENABLE_MAVLINK_SUPPORT option to try to use it...")
endif()
else()
if((EXISTS "${MAVLINK_PKG_PREFIX}/include/mavlink/common/mavlink.h") OR (EXISTS "/usr/include/mavlink/common/mavlink.h"))
message(STATUS "mavlink has been detected, see ENABLE_MAVLINK_SUPPORT option to try to use it...")
endif()
endif()
endif()
if(ENABLE_LABJACK_SUPPORT)
add_definitions(-D ENABLE_LABJACK_SUPPORT)
include_directories("${PROJECT_SOURCE_DIR}/../Extensions/Devices/LabjackUtils/UE9Utils")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES Hardware/UE9A.cpp ../Extensions/Devices/LabjackUtils/UE9Utils/UE9Cfg.c ../Extensions/Devices/LabjackUtils/UE9Utils/UE9Core.c)
else()
target_sources(UxVCtrl PUBLIC Hardware/UE9A.cpp ../Extensions/Devices/LabjackUtils/UE9Utils/UE9Cfg.c ../Extensions/Devices/LabjackUtils/UE9Utils/UE9Core.c)
endif()
if(WIN32)
set_source_files_properties(../Extensions/Devices/LabjackUtils/UE9Utils/UE9Cfg.c ../Extensions/Devices/LabjackUtils/UE9Utils/UE9Core.c PROPERTIES LANGUAGE CXX)
if(ENABLE_AUTO_DOWNLOAD)
if((NOT EXISTS "$ENV{ProgramFiles}/LabJack/Drivers/LabJackUD.h") AND (NOT EXISTS "$ENV{${ProgramFilesx86}}/LabJack/Drivers/LabJackUD.h"))
message(STATUS "Downloading LabJack...")
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/LabJack-2019-05-20.zip" "${PROJECT_SOURCE_DIR}/LabJack.zip")
else()
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/LabJack-2013.3.5.zip" "${PROJECT_SOURCE_DIR}/LabJack.zip")
endif()
#message(STATUS "LabJack downloaded!")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/LabJack.zip")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/cmake_extra_tools.zip" "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
#message(STATUS "LabJack extracted!")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/LabJack" COMMAND cmd /c "regedit /s Certificates.reg")
#message(STATUS "Certificates OK!")
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/LabJack" COMMAND cmd /c "start LabJack-2019-05-20.exe /S")
else()
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/LabJack" COMMAND cmd /c "start LabJack-2013.3.5.exe /S")
endif()
#message(STATUS "LabJack installing!")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_extra_tools" COMMAND cmd /c "sleep 60")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/LabJack" COMMAND cmd /c "TASKKILL /F /IM LVRunTimeEng.exe /T")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_extra_tools" COMMAND cmd /c "sleep 5")
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/LabJack-2019-05-20.exe")
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/LabJack-2013.3.5.exe")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/cmake_extra_tools")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/cmake_extra_tools.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/LabJack")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/LabJack.zip")
#message(STATUS "LabJack installed!")
endif()
endif()
if(NOT EXISTS "$ENV{ProgramFiles}/LabJack/Drivers/LabJackUD.h")
include_directories("$ENV{${ProgramFilesx86}}/LabJack/Drivers")
if(MSVC)
if(ARCH STREQUAL "x64")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{${ProgramFilesx86}}/LabJack/Drivers/64bit\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{${ProgramFilesx86}}/LabJack/Drivers\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
else()
if(ARCH STREQUAL "x64")
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{${ProgramFilesx86}}/LabJack/Drivers/64bit\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{${ProgramFilesx86}}/LabJack/Drivers\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
else()
include_directories("$ENV{ProgramFiles}/LabJack/Drivers")
if(MSVC)
if(ARCH STREQUAL "x64")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{ProgramFiles}/LabJack/Drivers/64bit\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"$ENV{ProgramFiles}/LabJack/Drivers\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
else()
if(ARCH STREQUAL "x64")
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{ProgramFiles}/LabJack/Drivers/64bit\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"$ENV{ProgramFiles}/LabJack/Drivers\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES labjackud)
else()
target_link_libraries(UxVCtrl labjackud)
endif()
else()
include_directories("${PROJECT_SOURCE_DIR}/../Extensions/Devices/LabjackUtils/liblabjackusb")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES ../Extensions/Devices/LabjackUtils/UE9Utils/ue9.c ../Extensions/Devices/LabjackUtils/liblabjackusb/labjackusb.c)
else()
target_sources(UxVCtrl PUBLIC ../Extensions/Devices/LabjackUtils/UE9Utils/ue9.c ../Extensions/Devices/LabjackUtils/liblabjackusb/labjackusb.c)
endif()
endif()
endif()
if(ENABLE_LIBMODBUS_SUPPORT)
add_definitions(-D ENABLE_LIBMODBUS_SUPPORT)
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_SOURCES Hardware/CISCREA.cpp)
else()
target_sources(UxVCtrl PUBLIC Hardware/CISCREA.cpp)
endif()
if(WIN32)
if(ENABLE_AUTO_DOWNLOAD)
if(NOT EXISTS "${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/include/modbus/modbus.h")
message(STATUS "Downloading libmodbus...")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/libmodbus-3.0.6-msvc.zip" "${PROJECT_SOURCE_DIR}/libmodbus-3.0.6-msvc.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/libmodbus-3.0.6-msvc.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/libmodbus-3.0.6-msvc" "${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/libmodbus-3.0.6-msvc")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/libmodbus-3.0.6-msvc.zip")
endif()
endif()
include_directories("${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/include")
if(MSVC)
if(ENABLE_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/${ARCH}/${RUNTIME}/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES debug libmodbus-3.0.6-msvcd)
list(APPEND UxVCtrl_LIBRARIES optimized libmodbus-3.0.6-msvc)
else()
target_link_libraries(UxVCtrl debug libmodbus-3.0.6-msvcd)
target_link_libraries(UxVCtrl optimized libmodbus-3.0.6-msvc)
endif()
else()
if(ENABLE_STATIC)
#set(CMAKE_EXE_LINKER_FLAGS "-L\"${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/${ARCH}/${RUNTIME}/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES modbus)
else()
target_link_libraries(UxVCtrl modbus)
endif()
endif()
else()
if(ENABLE_AUTO_DOWNLOAD)
if((NOT EXISTS "/usr/include/modbus/modbus.h") AND (NOT EXISTS "${LIBMODBUS_PKG_PREFIX}/include/modbus/modbus.h"))
if(APPLE)
message(STATUS "Trying to download libmodbus...")
execute_process(COMMAND sh -c "${INSTALL_PKG_COMMAND} ${LIBMODBUS_PKG_NAME}")
else()
message(STATUS "Trying to download libmodbus, run \"${SUDO_COMMAND} apt-get update\" before if needed and check if the terminal is asking for a password...")
execute_process(COMMAND sh -c "${INSTALL_PKG_COMMAND} ${LIBMODBUS_PKG_NAME}")
endif()
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS "-L\"${LIBMODBUS_PKG_PREFIX}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES modbus)
else()
target_link_libraries(UxVCtrl modbus)
endif()
endif()
else()
if(WIN32)
if(EXISTS "${LIBMODBUS_PKG_PREFIX}/libmodbus-3.0.6-msvc/include/modbus/modbus.h")
message(STATUS "modbus has been detected, see ENABLE_LIBMODBUS_SUPPORT option to try to use it...")
endif()
else()
if((EXISTS "/usr/include/modbus/modbus.h") OR (EXISTS "${LIBMODBUS_PKG_PREFIX}/include/modbus/modbus.h"))
message(STATUS "modbus has been detected, see ENABLE_LIBMODBUS_SUPPORT option to try to use it...")
endif()
endif()
endif()
if(ENABLE_SBG_SDK_SUPPORT)
add_definitions(-D ENABLE_SBG_SDK_SUPPORT)
add_definitions(-D SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES=0)
if(WIN32)
set(SBG_SDK_DIR "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/Software Development/sbgECom")
if(ENABLE_AUTO_DOWNLOAD)
if(((NOT EXISTS "${SBG_SDK_DIR}/common/sbgCommon.h") OR (NOT EXISTS "${SBG_SDK_DIR}/${ARCH}/vc15/lib/sbgECom.lib")) AND ((NOT EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/common/sbgCommon.h") OR (NOT EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/bin/sbgECom.lib")))
message(STATUS "Downloading SBG SDK...")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/SBG%20Systems.zip" "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/SBG Systems" "${SBG_SDK_PKG_PREFIX}/SBG Systems")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/SBG Systems")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
#if(NOT EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/common/sbgCommon.h")
#message(STATUS "Downloading SBG SDK...")
#file(DOWNLOAD "https://github.com/lebarsfa/sbgECom/archive/refs/heads/enstabre.zip" "${PROJECT_SOURCE_DIR}/enstabre.zip")
#execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/enstabre.zip")
#execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/sbgECom-enstabre" "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library")
#execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/sbgECom-enstabre")
#execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/enstabre.zip")
#endif()
#execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/build")
#if(MSVC)
#if(ENABLE_STATIC)
#execute_process(WORKING_DIRECTORY "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/build" COMMAND ${CMAKE_COMMAND} "-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug> ..\\cmake")
#else()
#execute_process(WORKING_DIRECTORY "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/build" COMMAND ${CMAKE_COMMAND} "..\\cmake")
#endif()
#endif()
#execute_process(WORKING_DIRECTORY "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/build" COMMAND ${CMAKE_COMMAND} "--build .")
endif()
endif()
include_directories("${SBG_SDK_DIR}/common")
include_directories("${SBG_SDK_DIR}/src")
include_directories("${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/common")
include_directories("${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/src")
include_directories("${SBG_SDK_PKG_PREFIX}/common")
include_directories("${SBG_SDK_PKG_PREFIX}/src")
if(MSVC)
if(ENABLE_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${SBG_SDK_DIR}/${ARCH}/${RUNTIME}/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${SBG_SDK_DIR}/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/bin\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${SBG_SDK_PKG_PREFIX}/bin\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${SBG_SDK_PKG_PREFIX}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES debug sbgEComd)
list(APPEND UxVCtrl_LIBRARIES optimized sbgECom)
else()
target_link_libraries(UxVCtrl debug sbgEComd)
target_link_libraries(UxVCtrl optimized sbgECom)
endif()
else()
if(ENABLE_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_DIR}/${ARCH}/vc15/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_DIR}/${ARCH}/vc15/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/sbgECom Library/bin\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_PKG_PREFIX}/bin\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_PKG_PREFIX}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES sbgECom)
else()
target_link_libraries(UxVCtrl sbgECom)
endif()
endif()
else()
if(ENABLE_AUTO_DOWNLOAD)
if(((NOT EXISTS "${SBG_SDK_PKG_PREFIX}/include/sbgECom/common/sbgCommon.h") OR (NOT EXISTS "${SBG_SDK_PKG_PREFIX}/lib/libsbgECom.a")) AND
((NOT EXISTS "/usr/include/sbgECom/common/sbgCommon.h") OR (NOT EXISTS "/usr/lib/libsbgECom.a")))
message(STATUS "Downloading SBG SDK...")
file(DOWNLOAD "http://www.ensta-bretagne.fr/lebars/Share/SBG%20Systems.zip" "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
execute_process(COMMAND sh -c "cd \"${PROJECT_SOURCE_DIR}/SBG Systems/Inertial SDK/Software Development/sbgECom/projects/unix\" && cmake . && cmake --build .")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p \"${SBG_SDK_PKG_PREFIX}/include/sbgECom\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p \"${SBG_SDK_PKG_PREFIX}/lib\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/SBG Systems/Inertial SDK/Software Development/sbgECom/src/\" \"${SBG_SDK_PKG_PREFIX}/include/sbgECom/src\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/SBG Systems/Inertial SDK/Software Development/sbgECom/common/\" \"${SBG_SDK_PKG_PREFIX}/include/sbgECom/common\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/SBG Systems/Inertial SDK/Software Development/sbgECom/bin/libsbgECom.a\" \"${SBG_SDK_PKG_PREFIX}/lib/libsbgECom.a\"")
#execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/SBG Systems") # To keep the possibility to use "./SBG Systems" as installation folder
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/SBG Systems.zip")
endif()
endif()
include_directories("${SBG_SDK_PKG_PREFIX}/include/sbgECom/common")
include_directories("${SBG_SDK_PKG_PREFIX}/include/sbgECom/src")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${SBG_SDK_PKG_PREFIX}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES sbgECom)
else()
target_link_libraries(UxVCtrl sbgECom)
endif()
endif()
if(DISABLE_SBG_TCP)
if(WIN32)
if(EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/Software Development/sbgECom/common/interfaces/sbgInterfaceTcp.h")
message(STATUS "TCP support in SBG SDK has been detected, see DISABLE_SBG_TCP option to try to use it...")
endif()
else()
if((EXISTS "${SBG_SDK_PKG_PREFIX}/include/sbgECom/common/sbgInterfaceTcp.h") OR (EXISTS "/usr/include/sbgECom/common/sbgInterfaceTcp.h"))
message(STATUS "TCP support in SBG SDK has been detected, see DISABLE_SBG_TCP option to try to use it...")
endif()
endif()
else()
if(WIN32)
if(NOT EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/Software Development/sbgECom/common/interfaces/sbgInterfaceTcp.h")
message(WARNING "TCP support in SBG SDK has not been detected, check DISABLE_SBG_TCP option...")
endif()
else()
if((NOT EXISTS "${SBG_SDK_PKG_PREFIX}/include/sbgECom/common/sbgInterfaceTcp.h") AND (NOT EXISTS "/usr/include/sbgECom/common/sbgInterfaceTcp.h"))
message(WARNING "TCP support in SBG SDK has not been detected, check DISABLE_SBG_TCP option...")
endif()
endif()
endif()
else()
if(WIN32)
if(EXISTS "${SBG_SDK_PKG_PREFIX}/SBG Systems/Inertial SDK/Software Development/sbgECom/common/sbgCommon.h")
message(STATUS "SBG SDK has been detected, see ENABLE_SBG_SDK_SUPPORT option to try to use it...")
endif()
else()
if((EXISTS "${SBG_SDK_PKG_PREFIX}/include/sbgECom/common/sbgCommon.h") OR (EXISTS "/usr/include/sbgECom/common/sbgCommon.h"))
message(STATUS "SBG SDK has been detected, see ENABLE_SBG_SDK_SUPPORT option to try to use it...")
endif()
endif()
endif()
if(ENABLE_RPLIDAR_SDK_SUPPORT)
add_definitions(-D ENABLE_RPLIDAR_SDK_SUPPORT)
if(RPLIDARSDK1120)
set(RPLIDAR_SDK_REL_DIR "rplidar_sdk/sdk")
set(RPLIDAR_SDK_DOWNLOAD_LINK "https://github.com/lebarsfa/rplidar_sdk/releases/download/release%2Fv1.12.0-enstabre/rplidar_sdk.zip")
set(RPLIDAR_SDK_HDR_NAME "sl_lidar.h")
if(WIN32)
set(RPLIDAR_SDK_LIB_NAME "rplidar_driver")
else()
set(RPLIDAR_SDK_LIB_NAME "rplidar_sdk")
endif()
else()
set(RPLIDAR_SDK_REL_DIR "rplidar_sdk")
set(RPLIDAR_SDK_DOWNLOAD_LINK "https://github.com/lebarsfa/rplidar_sdk/releases/download/release%2Fv2.0.0-enstabre/rplidar_sdk.zip")
set(RPLIDAR_SDK_HDR_NAME "rplidar.h")
if(WIN32)
set(RPLIDAR_SDK_LIB_NAME "rplidar_driver")
else()
set(RPLIDAR_SDK_LIB_NAME "sl_lidar_sdk")
endif()
endif()
if(WIN32)
if(ARCH STREQUAL "x64")
set(RPLIDAR_SDK_RUNTIME "win64")
else()
set(RPLIDAR_SDK_RUNTIME "win32")
endif()
elseif(APPLE)
set(RPLIDAR_SDK_RUNTIME "Darwin")
else()
set(RPLIDAR_SDK_RUNTIME "Linux")
endif()
if(WIN32)
set(RPLIDAR_SDK_DIR "${RPLIDAR_SDK_PKG_PREFIX}/${RPLIDAR_SDK_REL_DIR}")
if(ENABLE_AUTO_DOWNLOAD)
if((NOT EXISTS "${RPLIDAR_SDK_DIR}/sdk/include/${RPLIDAR_SDK_HDR_NAME}") OR (NOT EXISTS "${RPLIDAR_SDK_DIR}/output/win32/Release/${RPLIDAR_SDK_LIB_NAME}.lib"))
message(STATUS "Downloading RPLIDAR SDK...")
file(DOWNLOAD "${RPLIDAR_SDK_DOWNLOAD_LINK}" "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/rplidar_sdk" "${RPLIDAR_SDK_PKG_PREFIX}/rplidar_sdk")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/rplidar_sdk")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
endif()
endif()
include_directories("${RPLIDAR_SDK_DIR}/sdk/include")
include_directories("${RPLIDAR_SDK_DIR}/sdk/src")
if(MSVC)
if(ENABLE_STATIC)
#set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${RPLIDAR_SDK_DIR}/output/${ARCH}/${RUNTIME}/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${RPLIDAR_SDK_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
#set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${RPLIDAR_SDK_DIR}/output/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/LIBPATH:\"${RPLIDAR_SDK_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Debug\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
#list(APPEND UxVCtrl_LIBRARIES debug ${RPLIDAR_SDK_LIB_NAME}d)
#list(APPEND UxVCtrl_LIBRARIES optimized ${RPLIDAR_SDK_LIB_NAME})
list(APPEND UxVCtrl_LIBRARIES ${RPLIDAR_SDK_LIB_NAME})
else()
#target_link_libraries(UxVCtrl debug ${RPLIDAR_SDK_LIB_NAME}d)
#target_link_libraries(UxVCtrl optimized ${RPLIDAR_SDK_LIB_NAME})
target_link_libraries(UxVCtrl ${RPLIDAR_SDK_LIB_NAME})
endif()
else()
if(ENABLE_STATIC)
#set(CMAKE_EXE_LINKER_FLAGS "-L\"${RPLIDAR_SDK_DIR}/output/${ARCH}/${RUNTIME}/staticlib\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${RPLIDAR_SDK_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release\" ${CMAKE_EXE_LINKER_FLAGS}")
else()
#set(CMAKE_EXE_LINKER_FLAGS "-L\"${RPLIDAR_SDK_DIR}/output/${ARCH}/${RUNTIME}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${RPLIDAR_SDK_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release\" ${CMAKE_EXE_LINKER_FLAGS}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES ${RPLIDAR_SDK_LIB_NAME})
else()
target_link_libraries(UxVCtrl ${RPLIDAR_SDK_LIB_NAME})
endif()
endif()
else()
if(ENABLE_AUTO_DOWNLOAD)
if(((NOT EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/include/${RPLIDAR_SDK_HDR_NAME}") OR (NOT EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/lib/lib${RPLIDAR_SDK_LIB_NAME}.a")) AND
((NOT EXISTS "/usr/include/${RPLIDAR_SDK_REL_DIR}/include/${RPLIDAR_SDK_HDR_NAME}") OR (NOT EXISTS "/usr/lib/lib${RPLIDAR_SDK_LIB_NAME}.a")))
message(STATUS "Downloading RPLIDAR SDK...")
file(DOWNLOAD "${RPLIDAR_SDK_DOWNLOAD_LINK}" "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
execute_process(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
if(APPLE)
execute_process(COMMAND sh -c "cd \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}\" && rm -Rf output && SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk make")
else()
execute_process(COMMAND sh -c "cd \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}\" && rm -Rf output && make")
endif()
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p \"${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/sdk\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p \"${RPLIDAR_SDK_PKG_PREFIX}/lib\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} mkdir -p \"${RPLIDAR_SDK_PKG_PREFIX}/bin\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}/sdk/include/\" \"${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/sdk/include\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}/sdk/src/\" \"${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/sdk/src\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release/lib${RPLIDAR_SDK_LIB_NAME}.a\" \"${RPLIDAR_SDK_PKG_PREFIX}/lib/lib${RPLIDAR_SDK_LIB_NAME}.a\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release/ultra_simple\" \"${RPLIDAR_SDK_PKG_PREFIX}/bin/ultra_simple\"")
execute_process(COMMAND sh -c "${SUDO_COMMAND} cp -Rf \"${PROJECT_SOURCE_DIR}/${RPLIDAR_SDK_REL_DIR}/output/${RPLIDAR_SDK_RUNTIME}/Release/simple_grabber\" \"${RPLIDAR_SDK_PKG_PREFIX}/bin/simple_grabber\"")
#execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/rplidar_sdk") # To keep the possibility to use "./rplidar_sdk" as installation folder
execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${PROJECT_SOURCE_DIR}/rplidar_sdk.zip")
endif()
endif()
include_directories("${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/sdk/include")
include_directories("${RPLIDAR_SDK_PKG_PREFIX}/include/${RPLIDAR_SDK_REL_DIR}/sdk/src")
set(CMAKE_EXE_LINKER_FLAGS "-L\"${RPLIDAR_SDK_PKG_PREFIX}/lib\" ${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.1")
list(APPEND UxVCtrl_LIBRARIES ${RPLIDAR_SDK_LIB_NAME})
else()
target_link_libraries(UxVCtrl ${RPLIDAR_SDK_LIB_NAME})
endif()
endif()
else()
if(WIN32)
if(EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/rplidar_sdk/sdk/include/sl_lidar.h")
message(STATUS "RPLIDAR SDK v2 has been detected, see ENABLE_RPLIDAR_SDK_SUPPORT and RPLIDARSDK200 options to try to use it...")
elseif(EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/rplidar_sdk/sdk/sdk/include/rplidar.h")
message(STATUS "RPLIDAR SDK v1 has been detected, see ENABLE_RPLIDAR_SDK_SUPPORT and RPLIDARSDK1120 options to try to use it...")
endif()
else()
if((EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/include/rplidar_sdk/sdk/include/sl_lidar.h") OR (EXISTS "/usr/include/rplidar_sdk/sdk/include/sl_lidar.h"))
message(STATUS "RPLIDAR SDK v2 has been detected, see ENABLE_RPLIDAR_SDK_SUPPORT and RPLIDARSDK200 options to try to use it...")
elseif((EXISTS "${RPLIDAR_SDK_PKG_PREFIX}/include/rplidar_sdk/sdk/sdk/include/rplidar.h") OR (EXISTS "/usr/include/rplidar_sdk/sdk/sdk/include/rplidar.h"))
message(STATUS "RPLIDAR SDK v1 has been detected, see ENABLE_RPLIDAR_SDK_SUPPORT and RPLIDARSDK1120 options to try to use it...")
endif()
endif()
endif()
if(OPENCV2413)
set(OPENCV_VER_X_X_X "2.4.13")
set(OPENCV_VER_X_X "2.4")
set(OPENCV_VER_XXX "2413")
set(OPENCV_VER_XX "24")
set(OPENCV_VER_X "2")
elseif(OPENCV320)
set(OPENCV_VER_X_X_X "3.2.0")
set(OPENCV_VER_X_X "3.2")
set(OPENCV_VER_XXX "320")
set(OPENCV_VER_XX "32")