-
Notifications
You must be signed in to change notification settings - Fork 286
/
CMakeLists.txt
1931 lines (1747 loc) · 93.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
#############################################################################
#
# ViSP, open source Visual Servoing Platform software.
# Copyright (C) 2005 - 2024 by Inria. All rights reserved.
#
# This software is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# See the file LICENSE.txt at the root directory of this source
# distribution for additional information about the GNU GPL.
#
# For using ViSP with software that can not be combined with the GNU
# GPL, please contact Inria about acquiring a ViSP Professional
# Edition License.
#
# See https://visp.inria.fr for more information.
#
# This software was developed at:
# Inria Rennes - Bretagne Atlantique
# Campus Universitaire de Beaulieu
# 35042 Rennes Cedex
# France
#
# If you have questions regarding the use of this file, please contact
# Inria at visp@inria.fr
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:
# ViSP overall configuration file. Detect third party libraries (X11, GTK, ...)
#
#############################################################################
# Detect crosscompiling; need to be before project(VISP) to work
if(NOT CMAKE_TOOLCHAIN_FILE)
# Modify default install prefix
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
endif()
else(NOT CMAKE_TOOLCHAIN_FILE)
#Android: set output folder to ${CMAKE_BINARY_DIR}
set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" )
# Crosscompiling
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
endif()
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
if(WINRT)
add_definitions(-DWINRT)
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
set(WINRT_PHONE TRUE)
add_definitions(-DWINRT_PHONE)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT_STORE TRUE)
add_definitions(-DWINRT_STORE)
endif()
if(CMAKE_SYSTEM_VERSION MATCHES 10 OR CMAKE_SYSTEM_VERSION MATCHES 10.0)
set(WINRT_10 TRUE)
add_definitions(-DWINRT_10)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
set(WINRT_8_1 TRUE)
add_definitions(-DWINRT_8_1)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
set(WINRT_8_0 TRUE)
add_definitions(-DWINRT_8_0)
endif()
endif()
# By default set release configuration
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
cmake_minimum_required(VERSION 3.5) # needs to be before project() for policy CMP0025
# Detect if the toolchain is for Aldebaran naoqi
if(CMAKE_TOOLCHAIN_FILE AND I_AM_A_ROBOT)
include(platforms/naoqi/cmake/extra.cmake)
endif()
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW) # For UsTK: Qt5
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW) # Due to sensor ATIDAQ_LIBRARIES
endif()
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW) # To set compiler id for Apple Clang to AppleClang instead of Clang. Required to detect OpenMP support on MacOS
endif()
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW) # For UsTK: VTK and Qt5
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) # To turn off a warning in native FindOpenMP with cmake 3.9.2
endif()
if(POLICY CMP0068)
cmake_policy(SET CMP0068 NEW) # CMake 3.9+: `RPATH` settings on macOS do not affect `install_name`.
endif()
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW) # To use legacy GL library with FindOpenGL and cmake 3.12.0
endif()
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) # For PCL_ROOT usage and cmake 3.12.0 when PCL 1.9.1 all in one is used on Windows
endif()
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW) # For check_include_file and cmake 3.12.0
endif()
if(POLICY CMP0146)
cmake_policy(SET CMP0146 OLD) # The ``FindCUDA`` module deprecated since CMake 3.10
endif()
if(APPLE)
# Fix following errors for libpng and libjpeg detection:
# - Application built with libpng-1.4.12 but running with 1.6.37,
# - Wrong JPEG library version: library is 90, caller expects 80.
# The reason is that headers were found in /Library/Frameworks/Mono.framework/Headers
# while libraries in /usr/local/lib
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
project(VISP C CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(cmake/VISPUtils.cmake)
include(cmake/VISPDetectCXXStandard.cmake) # Set cxx standard to 17 by default
#-----------------------------------------------------------------------------
# VISP version number. An even minor number corresponds to releases.
set(VISP_VERSION_MAJOR "3")
set(VISP_VERSION_MINOR "6")
set(VISP_VERSION_PATCH "1")
set(VISP_VERSION "${VISP_VERSION_MAJOR}.${VISP_VERSION_MINOR}.${VISP_VERSION_PATCH}")
set(VISP_SOVERSION "${VISP_VERSION_MAJOR}.${VISP_VERSION_MINOR}")
# Package revision number
set(VISP_REVISION "1")
#-----------------------------------------------------------------------------
# TO BE CHECKED BEFORE NEXT RELEASE
#
# Remove following 3 next lines and check if pcl produces a CMP0144 complain around CMake variable FLANN_ROOT set to /opt/homebrew
if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
endif()
#-----------------------------------------------------------------------------
find_file(GNU_INSTALL_DIRS_FROM_CMAKE NAMES GNUInstallDirs.cmake PATHS ${CMAKE_ROOT}/Modules)
mark_as_advanced(GNU_INSTALL_DIRS_FROM_CMAKE)
if(GNU_INSTALL_DIRS_FROM_CMAKE)
include(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
else()
include(cmake/GNUInstallDirs.cmake)
endif()
#----------------------------------------------------------------------
# Tool specific
#----------------------------------------------------------------------
# PCL tools
include(cmake/PCLTools.cmake)
#----------------------------------------------------------------------
# Platform specific
#----------------------------------------------------------------------
include(cmake/VISPDetectPlatform.cmake)
# Where to install the library and headers
if(ANDROID)
# Where to build modules
set(LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
# Where to build internal 3rdparties
vp_update(VISP_3P_LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
vp_update(VISP_INSTALL_BINARIES_PREFIX "sdk/native/")
# set binary path
vp_update(VISP_BIN_INSTALL_PATH "sdk/native/bin/${ANDROID_NDK_ABI_NAME}")
# set samples path
vp_update(VISP_SAMPLES_BIN_INSTALL_PATH "sdk/native/samples/${ANDROID_NDK_ABI_NAME}")
vp_update(VISP_LIB_INSTALL_PATH "sdk/native/libs/${ANDROID_NDK_ABI_NAME}")
vp_update(VISP_LIB_ARCHIVE_INSTALL_PATH "sdk/native/staticlibs/${ANDROID_NDK_ABI_NAME}")
vp_update(VISP_3P_LIB_INSTALL_PATH "sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME}")
vp_update(VISP_CONFIG_INSTALL_PATH "sdk/native/jni")
vp_update(VISP_INC_INSTALL_PATH "sdk/native/jni/include")
vp_update(VISP_SAMPLES_SRC_INSTALL_PATH "samples/native")
vp_update(VISP_INSTALL_DATAROOTDIR "sdk/etc")
elseif(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
# Where to build modules
set(LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/lib")
# Where to build internal 3rdparties
vp_update(VISP_3P_LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
if(DEFINED VISP_RUNTIME AND DEFINED VISP_ARCH)
vp_update(VISP_INSTALL_BINARIES_PREFIX "${VISP_ARCH}/${VISP_RUNTIME}/")
else()
message(STATUS "Can't detect runtime and/or arch")
vp_update(VISP_INSTALL_BINARIES_PREFIX "")
endif()
if(VISP_STATIC)
vp_update(VISP_LIB_INSTALL_PATH "${VISP_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
else()
vp_update(VISP_LIB_INSTALL_PATH "${VISP_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
endif()
vp_update(VISP_3P_LIB_INSTALL_PATH "${VISP_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
vp_update(VISP_SAMPLES_SRC_INSTALL_PATH samples/native)
vp_update(VISP_JAR_INSTALL_PATH java)
vp_update(VISP_INC_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
vp_update(VISP_BIN_INSTALL_PATH "${VISP_INSTALL_BINARIES_PREFIX}bin")
vp_update(VISP_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_DATAROOTDIR}/visp-${VISP_VERSION}")
vp_update(VISP_CONFIG_INSTALL_PATH ".")
else() # UNIX
# Where to build modules
set(LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/lib")
# Where to build internal 3rdparties
vp_update(VISP_3P_LIBRARY_OUTPUT_PATH "${VISP_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
vp_update(VISP_INSTALL_BINARIES_PREFIX "")
#----------------------------------------------------------------------
# Multi-arch option that should be enable for debian packaging
#----------------------------------------------------------------------
VP_OPTION(ENABLE_MULTIARCH "" "" "Enable multi-arch support" "" OFF IF (NOT APPLE))
# The location where includes and libraries will be installed
if(ENABLE_MULTIARCH)
# The 2 following lines should be used to enable multi-arch support.
vp_update(VISP_INC_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
vp_update(VISP_LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
else()
# catkin doesn't support multi-arch; use rather the next 2 lines
vp_update(VISP_INC_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
vp_update(VISP_LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}")
endif()
vp_update(VISP_BIN_INSTALL_PATH "${CMAKE_INSTALL_BINDIR}")
vp_update(VISP_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_DATAROOTDIR}/visp-${VISP_VERSION}")
vp_update(VISP_3P_LIB_INSTALL_PATH "${VISP_LIB_INSTALL_PATH}/visp/3rdparty")
vp_update(VISP_SAMPLES_SRC_INSTALL_PATH "${VISP_INSTALL_DATAROOTDIR}/samples")
vp_update(VISP_JAR_INSTALL_PATH "${VISP_INSTALL_DATAROOTDIR}/java")
vp_update(VISP_CONFIG_INSTALL_PATH "${VISP_LIB_INSTALL_PATH}/cmake/visp")
endif()
# the include directory we depend on for the build
set(VISP_INCLUDE_DIR ${VISP_BINARY_DIR}/${VISP_INC_INSTALL_PATH})
set(VISP_DOC_DIR "${VISP_BINARY_DIR}/doc")
# The location where includes and libraries will be build
set(BINARY_OUTPUT_PATH ${VISP_BINARY_DIR}/${VISP_BIN_INSTALL_PATH})
if(WIN32)
# Postfix of .lib and .dll
set(VISP_DEBUG_POSTFIX "d")
set(VISP_DLLVERSION "${VISP_VERSION_MAJOR}${VISP_VERSION_MINOR}${VISP_VERSION_PATCH}")
else()
set(VISP_DEBUG_POSTFIX "")
set(VISP_DLLVERSION "")
endif()
# --- Python Support ---
if(NOT IOS)
# Make sure to refresh the python interpreter every time we rerun cmake
# If we don't do this, we may use an old or invalid python when installing the bindings
# that was cached by a previous attempt at building
if(CMAKE_VERSION VERSION_LESS "3.15.0")
set(PYTHON3_CACHE_LIST
PYTHON3INTERP_FOUND PYTHONINTERP_FOUND PYTHONLIBS_FOUND PYTHON_FOUND
PYTHON3_EXECUTABLE PYTHON_EXECUTABLE
)
foreach (_variableName ${PYTHON3_CACHE_LIST})
unset(${_variableName} CACHE)
endforeach()
include(cmake/VISPDetectPython.cmake)
else()
set(PYTHON3_CACHE_LIST
Python3_FOUND Python3_EXECUTABLE Python3_Interpreter_FOUND Python3_LIBRARIES
_Python3_EXECUTABLE _Python3_INCLUDE_DIR _Python3_INTERPRETER_PROPERTIES _Python3_LIBRARY_RELEASE
)
foreach (_variableName ${PYTHON3_CACHE_LIST})
unset(${_variableName} CACHE)
endforeach()
# Find strategy
set(Python3_FIND_REGISTRY LAST)
set(Python3_FIND_VIRTUALENV FIRST)
set(Python3_FIND_STRATEGY LOCATION)
find_package (Python3 COMPONENTS Interpreter Development)
# Alias variables to be consistent with previous detection method
set(PYTHON3_FOUND ${Python3_FOUND})
set(PYTHON3_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_DEFAULT_EXECUTABLE ${PYTHON3_EXECUTABLE})
set(PYTHON3INTERP_FOUND ${Python3_Interpreter_FOUND})
set(PYTHON3_VERSION_STRING ${Python3_VERSION})
endif()
endif()
# --- Python Bindings requirements ---
VP_OPTION(USE_PYBIND11 pybind11 QUIET "Include pybind11 to create Python bindings" "" ON)
# Minimum tool versions
set(CMAKE_MINIMUM_VERSION_PYTHON_BINDINGS "3.19.0")
set(PYTHON3_MINIMUM_VERSION_PYTHON_BINDINGS "3.7.0")
if(CMAKE_VERSION VERSION_LESS ${CMAKE_MINIMUM_VERSION_PYTHON_BINDINGS})
set(CMAKE_NOT_OK_FOR_BINDINGS TRUE)
message(STATUS "Required CMake version for Python bindings is ${CMAKE_MINIMUM_VERSION_PYTHON_BINDINGS},
but you have ${CMAKE_VERSION}.
Python bindings generation will be deactivated.
")
else()
set(CMAKE_NOT_OK_FOR_BINDINGS FALSE)
endif()
if(PYTHON3_VERSION_STRING VERSION_LESS ${PYTHON3_MINIMUM_VERSION_PYTHON_BINDINGS})
set(PYTHON3_NOT_OK_FOR_BINDINGS TRUE)
message(STATUS "Required Python version for Python bindings is ${PYTHON3_MINIMUM_VERSION_PYTHON_BINDINGS},
but you have ${PYTHON3_VERSION_STRING}.
Python bindings generation will be deactivated.
")
else()
set(PYTHON3_NOT_OK_FOR_BINDINGS FALSE)
endif()
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_17)
set(CXX_STANDARD_NOT_OK_FOR_BINDINGS TRUE)
message(STATUS "Required C++ standard is C++17, but you have ${VISP_CXX_STANDARD}")
else()
set(CXX_STANDARD_NOT_OK_FOR_BINDINGS FALSE)
endif()
# Forbid system Python
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX})
set(_pip_args)
set(VISP_PYTHON_IS_SYSTEM_WIDE FALSE)
else()
# First solution: raise an error when cmake will call pip install
# set(_pip_args "--require-virtualenv") # If this is a system python, throw an error
if(PYTHON3_FOUND)
message(STATUS "The python version that you are using (${PYTHON3_EXECUTABLE}) is the system interpreter.
pip packages should not be installed system-wide!
Python bindings targets will be deactivated!
To reenable them, install conda or virtualenv,
delete the CMakeCache file then rerun cmake when inside the virtual environment.
")
set(VISP_PYTHON_IS_SYSTEM_WIDE TRUE)
endif()
endif()
# ---
include_directories(${VISP_INCLUDE_DIR})
#----------------------------------------------------------------------
# x86 SIMD optimization
#----------------------------------------------------------------------
VP_OPTION(ENABLE_SSE2 "" "" "Enable SSE2 instructions" "" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
VP_OPTION(ENABLE_SSE3 "" "" "Enable SSE3 instructions" "" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
VP_OPTION(ENABLE_SSSE3 "" "" "Enable SSSE3 instructions" "" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86_64)) ) # X86 disabled since it produces an issue on Debian i386
if(X86_64)
VP_OPTION(ENABLE_AVX "" "" "Enable AVX instructions" "" OFF) # should be explicitly enabled, used in matrix transpose code
endif()
#----------------------------------------------------------------------
# BLAS / LAPACK
#----------------------------------------------------------------------
if(NOT WINRT AND NOT IOS)
include(cmake/ChooseBlas.cmake)
endif()
# ----------------------------------------------------------------------------
# Handle RPATH
# ----------------------------------------------------------------------------
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VISP_LIB_INSTALL_PATH}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(ANDROID)
vp_update(VISP_JNI_INSTALL_PATH "${VISP_LIB_INSTALL_PATH}")
elseif(INSTALL_CREATE_DISTRIB)
vp_update(VISP_JNI_INSTALL_PATH "${VISP_JAR_INSTALL_PATH}/${VISP_ARCH}")
else()
vp_update(VISP_JNI_INSTALL_PATH "${VISP_JAR_INSTALL_PATH}")
endif()
vp_update(VISP_JNI_BIN_INSTALL_PATH "${VISP_JNI_INSTALL_PATH}")
if(NOT VISP_LIB_ARCHIVE_INSTALL_PATH)
set(VISP_LIB_ARCHIVE_INSTALL_PATH ${VISP_LIB_INSTALL_PATH})
endif()
# ----------------------------------------------------------------------------
# Path for additional contrib modules
# ----------------------------------------------------------------------------
set(VISP_CONTRIB_MODULES_PATH "" CACHE PATH "Where to look for additional contrib ViSP modules")
# Get the OS
set(OS ${CMAKE_SYSTEM_NAME})
set(OGRE_DIR $ENV{OGRE_DIR})
if(NOT OGRE_DIR) # For compat with previous ViSP versions
set(OGRE_DIR $ENV{OGRE_HOME})
endif()
if(OGRE_DIR)
# replace \ with / especially for windows
STRING(REGEX REPLACE "\\\\" "/" OGRE_DIR ${OGRE_DIR})
endif()
# add the path to detect Ogre3D
if(WIN32)
list(APPEND CMAKE_MODULE_PATH "${OGRE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${OGRE_DIR}")
endif(WIN32)
if(UNIX)
list(APPEND CMAKE_MODULE_PATH "${OGRE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${OGRE_DIR}/CMake")
list(APPEND CMAKE_MODULE_PATH "${OGRE_DIR}")
list(APPEND CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/local/lib64/OGRE/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/lib64/OGRE/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/share/OGRE/cmake/modules")
endif(UNIX)
# ----------------------------------------------------------------------------
# Check for system libs
# ----------------------------------------------------------------------------
include(CheckLibraryExists)
if(UNIX)
# try to found -lm requested on some platforms to link with X11
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
list(APPEND VISP_LINKER_LIBS ${M_LIBRARY})
endif()
# try to found -lsocket -lnsl requested for vpNetwork and vpSickLDMRS
find_library(SOCKET_LIBRARY NAMES socket)
find_library(NSL_LIBRARY NAMES nsl)
mark_as_advanced(SOCKET_LIBRARY NSL_LIBRARY)
if (SOCKET_LIBRARY)
list(APPEND VISP_LINKER_LIBS ${SOCKET_LIBRARY})
endif()
if (NSL_LIBRARY)
list(APPEND VISP_LINKER_LIBS ${NSL_LIBRARY})
endif()
endif()
if(WIN32)
# winmm.lib for timeGetTime() under windows
check_library_exists("winmm.lib" getch "" HAVE_LIBWINMM) # for timeGetTime()
if(HAVE_LIBWINMM)
list(APPEND VISP_LINKER_LIBS "winmm.lib")
endif()
# rpcrt4.lib for timeGetTime() under windows
check_library_exists("rpcrt4.lib" getch "" HAVE_LIBRPCRT4) # for UuidToString()
if(HAVE_LIBRPCRT4)
list(APPEND VISP_LINKER_LIBS "rpcrt4.lib")
endif()
endif()
if(WIN32 AND NOT CYGWIN)
VP_CHECK_PACKAGE(WS2_32)
# Should be before include(cmake/VISPDetectCXXStandard.cmake)
VP_CHECK_FUNCTION_EXISTS(inet_ntop "${WS2_32_LIBRARY}")
else()
# Should be before include(cmake/VISPDetectCXXStandard.cmake)
VP_CHECK_FUNCTION_EXISTS(inet_ntop "")
endif()
#--------------------------------------------------------------------
# Option management
#--------------------------------------------------------------------
# Choose static or shared libraries.
VP_OPTION(BUILD_SHARED_LIBS "" "" "Build ViSP shared libraries (.dll/.so) instead of static ones (.lib/.a)" "" NOT (ANDROID OR APPLE_FRAMEWORK))
# Build apps as an option.
VP_OPTION(BUILD_APPS "" "" "Build utility applications (used for example for calibration)" "" (NOT ANDROID AND NOT WINRT AND NOT APPLE_FRAMEWORK) )
# Build examples as an option.
VP_OPTION(BUILD_EXAMPLES "" "" "Build ViSP examples" "" ON)
# Build examples as an option.
VP_OPTION(BUILD_TESTS "" "" "Build ViSP tests" "" ON)
VP_OPTION(BUILD_COVERAGE "" "" "Enables test coverage" "" OFF IF (BUILD_TESTS AND CMAKE_COMPILER_IS_GNUCXX))
# Build java as an option
VP_OPTION(BUILD_JAVA "" "" "Enable Java support" "" (ANDROID OR NOT CMAKE_CROSSCOMPILING) IF (ANDROID OR (NOT APPLE_FRAMEWORK AND NOT WINRT)) )
VP_OPTION(BUILD_FAT_JAVA_LIB "" "" "Create Java wrapper exporting all functions of ViSP library (requires static build of ViSP modules)" "" ANDROID IF NOT BUILD_SHARED_LIBS)
VP_OPTION(BUILD_ANDROID_SERVICE "" "" "Build ViSP Manager for Google Play" "" OFF IF ANDROID )
VP_OPTION(BUILD_ANDROID_PROJECTS "" "" "Build Android projects providing .apk files" "" ON IF ANDROID )
VP_OPTION(BUILD_ANDROID_EXAMPLES "" "" "Build examples for Android platform" "" ON IF ANDROID )
VP_OPTION(INSTALL_ANDROID_EXAMPLES "" "" "Install Android examples" "" OFF IF ANDROID )
# Build python bindings as an option
VP_OPTION(BUILD_PYTHON_BINDINGS "" "" "Build Python bindings" "" ON IF (PYTHON3INTERP_FOUND AND USE_PYBIND11 AND NOT CMAKE_NOT_OK_FOR_BINDINGS AND NOT VISP_PYTHON_IS_SYSTEM_WIDE AND NOT PYTHON3_NOT_OK_FOR_BINDINGS AND NOT CXX_STANDARD_NOT_OK_FOR_BINDINGS) )
VP_OPTION(BUILD_PYTHON_BINDINGS_DOC "" "" "Build the documentation for the Python bindings" "" ON IF BUILD_PYTHON_BINDINGS )
# Build demos as an option.
VP_OPTION(BUILD_DEMOS "" "" "Build ViSP demos" "" ON)
# Build tutorials as an option.
VP_OPTION(BUILD_TUTORIALS "" "" "Build ViSP tutorials" "" ON)
# Build apps as an option.
vp_check_subdirectories(VISP_CONTRIB_MODULES_PATH apps APPS_FOUND)
if(APPS_FOUND)
VP_OPTION(BUILD_APPS "" "" "Build ViSP apps" "" ON)
endif()
# Build deprecated functions as an option.
VP_OPTION(BUILD_DEPRECATED_FUNCTIONS "" "" "Build deprecated functionalities" "" ON)
VP_OPTION(ACTIVATE_WARNING_3PARTY_MUTE "" "" "Add flags to disable warning due to known 3rd parties" "" ON)
# Debug and trace cflags
set(ENABLE_DEBUG_LEVEL 0 CACHE STRING "Set a debug level value between 0 and 9")
if(ENABLE_DEBUG_LEVEL)
if(ENABLE_DEBUG_LEVEL MATCHES "^([0-9]+)?$")
set(VP_DEBUG_MODE ${CMAKE_MATCH_1})
set(VP_DEBUG TRUE)
set(VP_TRACE TRUE)
else()
set(VP_DEBUG_MODE 0)
endif()
else()
set(VP_DEBUG_MODE 0)
endif()
VP_OPTION(BUILD_WITH_STATIC_CRT "" "" "Enables use of staticaly linked CRT for staticaly linked ViSP" "" ON IF MSVC)
# ----------------------------------------------------------------------------
# Build options
# ----------------------------------------------------------------------------
VP_OPTION(ENABLE_SOLUTION_FOLDERS "" "" "Solution folder in Visual Studio or in other IDEs" "" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode))
# Note that it is better to set ENABLE_MOMENTS_COMBINE_MATRICES to OFF
VP_OPTION(ENABLE_MOMENTS_COMBINE_MATRICES "" "" "Use linear combination of matrices instead of linear combination of moments to compute interaction matrices." "" OFF)
VP_OPTION(ENABLE_TEST_WITHOUT_DISPLAY "" "" "Don't use display feature when testing" "" ON)
VP_OPTION(ENABLE_FULL_DOC "" "" "Build doc with internal classes that are by default not part of the doc" "" OFF)
# Allow introduction of "visp" namespace. By default disabled to keep compat with previous versions
VP_OPTION(ENABLE_VISP_NAMESPACE "" "" "Enable visp namespace" "" OFF)
# Allow introduction of "explicit" keyword. By default disabled to keep compat with previous versions
VP_OPTION(ENABLE_EXPLICIT_KEYWORD "" "" "Enable c++ explicit keyword" "" OFF)
if(ENABLE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
endif()
if(ENABLE_TEST_WITHOUT_DISPLAY)
set(OPTION_TO_DESACTIVE_DISPLAY "-d")
endif()
# Check for Inria's robot drivers
VP_CHECK_PACKAGE(RAW1394)
VP_CHECK_PACKAGE(RT)
VP_CHECK_PACKAGE(CALINUX)
VP_CHECK_PACKAGE(IRISA)
# check for linux/parport.h
VP_CHECK_PACKAGE(PARPORT)
# OpenGL
VP_CHECK_PACKAGE(OpenGL)
# for pioneer
VP_CHECK_PACKAGE(RT)
VP_CHECK_PACKAGE(DL)
# for Afma6 calibration data
VP_CHECK_PACKAGE(Afma6_data)
if(AFMA6_DATA_FOUND)
set(VISP_AFMA6_DATA_PATH ${AFMA6_DATA_PATH})
else()
set(VISP_AFMA6_DATA_PATH "")
endif()
# for Viper850 calibration data
VP_CHECK_PACKAGE(Viper850_data)
if(VIPER850_DATA_FOUND)
set(VISP_VIPER850_DATA_PATH ${VIPER850_DATA_PATH})
else()
set(VISP_VIPER850_DATA_PATH "")
endif()
# for Viper650 calibration data
VP_CHECK_PACKAGE(Viper650_data)
if(VIPER650_DATA_FOUND)
set(VISP_VIPER650_DATA_PATH ${VIPER650_DATA_PATH})
else()
set(VISP_VIPER650_DATA_PATH "")
endif()
find_host_program(XRANDR xrandr)
VP_CHECK_PACKAGE(C99)
VP_OPTION(USE_AFMA4 "" "" "Include Afma4 robot support" "" ON IF (RAW1394_FOUND AND RT_FOUND AND CALINUX_FOUND AND IRISA_FOUND AND NOT WINRT AND NOT IOS))
VP_OPTION(USE_AFMA6 "" "" "Include Afma6 robot support" "" ON IF (RAW1394_FOUND AND RT_FOUND AND CALINUX_FOUND AND IRISA_FOUND AND NOT WINRT AND NOT IOS))
VP_OPTION(USE_VIPER650 "" "" "Include Viper s650 robot support" "" ON IF (RAW1394_FOUND AND RT_FOUND AND CALINUX_FOUND AND IRISA_FOUND AND NOT WINRT AND NOT IOS))
VP_OPTION(USE_VIPER850 "" "" "Include Viper s850 robot support" "" ON IF (RAW1394_FOUND AND RT_FOUND AND CALINUX_FOUND AND IRISA_FOUND AND NOT WINRT AND NOT IOS))
VP_OPTION(USE_UR_RTDE ur_rtde QUIET "Include Universal Robot RTDE C++ interface support for UR robots" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_VIRTUOSE Virtuose "" "Include Virtuose SDK support for Haption devices" "" ON IF NOT WINRT)
VP_OPTION(USE_ARSDK ARSDK QUIET "Include Parrot ARSDK support" "" ON IF NOT WINRT AND NOT IOS)
if(USE_ARSDK)
VP_OPTION(USE_FFMPEG FFMPEG "" "Include ffmpeg support for Parrot Bebop2" "" ON)
endif()
VP_OPTION(USE_FRANKA Franka QUIET "Include libfranka SDK support for Franka Emika robots" "" ON IF NOT WINRT AND NOT IOS)
# Note: libfranka needs c++14 option to build, but to use the library c++11 is enough.
# That's why, setting USE_CXX_STANDARD=11 (which is the default) allows to use libfranka.
VP_OPTION(USE_JACOSDK JacoSDK "" "Include Kinova Jaco SDK support" "" ON IF NOT MINGW AND NOT APPLE AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_MAVSDK MAVSDK QUIET "Include mavsdk support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_DC1394 DC1394 "" "Include dc1394 support" "" ON IF UNIX AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_V4L2 V4L2 "" "Include v4l2 support" "" ON IF UNIX AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_FLYCAPTURE FlyCapture "" "Include FlyCapture SDK support for FLIR cameras" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_PYLON Pylon "" "Include Pylon SDK support for Basler cameras" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_UEYE Ueye "" "Include uEye SDK support for IDS cameras" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_COMEDI Comedi "" "Include comedi (linux control and measurement device interface) support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_FTIITSDK FTIITSDK "" "Include IIT force-torque SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_BICLOPS BICLOPS "" "Include biclops support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_PTU46 PTU46 "" "Include ptu-46 support" "" ON IF UNIX AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_FLIRPTUSDK FlirPtuSDK "" "Include Flir PTU SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_CMU1394 CMU1394 "" "Include cmu1494 support" "" ON IF WIN32 AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_QUALISYS Qualisys "" "Include Qualisys SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_VICON Vicon "" "Include Vicon SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_GDI GDI "" "Include gdi support" "" ON IF WIN32 AND NOT WINRT AND NOT IOS)
#VP_OPTION(USE_DIRECT3D DIRECT3D "" "Include d3d support" "" ON IF WIN32 AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_DIRECTSHOW DIRECTSHOW "" "Include dshow support" "" ON IF WIN32 AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_OPENMP OpenMP "" "Include openmp support" "" ON)
VP_OPTION(USE_EIGEN3 Eigen3 QUIET "Include eigen3 support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_COIN3D "Coin3D;MyCoin3D" "" "Include coin3d support" "" ON IF OPENGL_FOUND AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_PANDA3D "MyPanda3D" "" "Include Panda3D support" "" ON IF NOT IOS)
VP_OPTION(USE_YARP YARP QUIET "Include yarp support" "YARP_DIR" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_OGRE OGRE QUIET "Include Ogre support" "OGRE_DIR" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_OIS OIS QUIET "Include Ogre/ois support" "OIS_DIR" ON IF USE_OGRE AND NOT WINRT AND NOT IOS)
VP_OPTION(USE_LIBFREENECT LIBFREENECT "" "Include libfreenect support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_LIBUSB_1 LIBUSB_1 "" "Include libusb-1 support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_REALSENSE RealSense "" "Include RealSense SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_REALSENSE2 RealSense2 "" "Include RealSense2 SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_OCCIPITAL_STRUCTURE Occipital_Structure "" "Include Occipital Structure SDK support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_SOWIN SOWIN "" "Include Coin/SoWin support" "" OFF IF (WIN32 AND USE_COIN3D) AND NOT WINRT AND NOT IOS)
# Check for SoQt 1.6.0 linked to Qt5 or older version with SOQT
VP_OPTION(USE_SOQT "SoQt;SOQT" QUIET "Include Coin/SoQt support" "" OFF IF USE_COIN3D AND NOT WINRT AND NOT IOS)
if(SOQT_FOUND) # SoQt < 1.6.0 that depends on Qt4 was found. We need an explicit Qt4 search
VP_OPTION(USE_QT Qt "" "Include Coin/SoQt/Qt support" "" ON IF USE_SOQT AND NOT WINRT AND NOT IOS)
endif()
VP_OPTION(USE_SOXT SOXT "" "Include Coin/SoXt support" "" OFF IF USE_COIN3D AND NOT WINRT AND NOT IOS)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
VP_OPTION(USE_THREADS Threads "" "Include std::thread support" "" ON)
VP_OPTION(USE_XML2 XML2 "" "Include libxml2 support" "" ON IF NOT WINRT)
if(CMAKE_TOOLCHAIN_FILE)
# Find opencv2.framework for ios and naoqi
VP_OPTION(USE_OPENCV "MyOpenCV" QUIET "Include OpenCV support" "OpenCV_DIR;OpenCV_FOUND;OPENCV_FOUND" ON)
else()
VP_OPTION(USE_OPENCV "OpenCV;MyOpenCV" QUIET "Include OpenCV support" "OpenCV_DIR;OpenCV_FOUND;OPENCV_FOUND" ON)
endif()
VP_OPTION(USE_ZLIB "ZLIB;MyZLIB" "" "Include zlib support" "" ON IF NOT WINRT AND NOT IOS)
set(X11_ADVANCED "X11_xcb_util_LIB;X11_xcb_util_INCLUDE_PATH;X11_xcb_xfixes_INCLUDE_PATH;X11_xcb_xfixes_LIB")
VP_OPTION(USE_X11 X11 "" "Include X11 support" "${X11_ADVANCED}" ON IF NOT WINRT AND NOT IOS)
# The native FindGTK2.cmake doesn't consider libgobject-2.0 that is
# requested by ViSP. That's why we use our FindMyGTK2.cmake
VP_OPTION(USE_GTK2 MyGTK2 "" "Include gtk2 support" "" OFF IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_JPEG "JPEG;MyJPEG" "" "Include jpeg support" "" ON IF NOT IOS)
VP_OPTION(USE_PNG "PNG;MyPNG" "" "Include png support" "" ON IF NOT IOS)
# To control Pioneer mobile robots, under UNIX we need Aria and std::threads, rt and dl 3rd party libraries
VP_OPTION(USE_ARIA ARIA "" "Include aria support" "" ON IF NOT WINRT AND NOT IOS)
#VP_OPTION(USE_RT RT "" "Include rt support" "" ON)
#VP_OPTION(USE_DL DL "" "Include dl support" "" ON)
# bar codes
VP_OPTION(USE_ZBAR ZBAR "" "Include zbar support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_DMTX DMTX "" "Include dmtx support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_PCL PCL QUIET "Include Point Cloud Library support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_TENSORRT TensorRT "" "Include TensorRT support" "" ON IF NOT WINRT AND NOT IOS)
VP_OPTION(USE_NLOHMANN_JSON nlohmann_json QUIET "Include nlohmann json support" "" ON)
if(USE_PCL)
# PCL is used in modules gui, sensor and mbt.
# In these modules we cannot directly use PCL_INCLUDE_DIRS and PCL_LIBRARIES using:
# list(APPEND opt_incs ${PCL_INCLUDE_DIRS})
# list(APPEND opt_libs ${PCL_LIBRARIES})
# Using PCL_LIBRARIES works to build visp libraries, embedded examples, demos, tests and tutorials thanks to the
# components. But when examples, demos, tests and tutorials are build outside ViSP workspace as independent projects
# that are using ViSP as 3rd-party we lead to build issues due to VTK headers and libraries that are not found.
# That's why here, we are using vp_find_pcl() macro that will set PCL_DEPS_INCLUDE_DIRS and PCL_DEPS_LIBRARIES
# that contains also VTK material location.
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
set(PCL_REQUIRED_COMPONENTS "common;filters;io;visualization;segmentation")
# Create cmake vars corresponding to pcl components used by ViSP like VISP_HAVE_PCL_COMMON...
vp_detect_required_pcl_components(PCL_REQUIRED_COMPONENTS)
# USE_NLOHMANN_JSON is set to ON if nlohmann_json is installed and found thanks to nlohmann_jsonConfig.cmake.
# VTK that is a PCL 3rd party embbed also a built in version of nlohmann_json.
# Here we add a specific case to consider the nlohmann version coming from VTK when the system version is not found
if(NOT USE_NLOHMANN_JSON)
if(VISP_HAVE_NLOHMANN_JSON_FROM_VTK)
message(WARNING "json 3rd party is detected and used as a VTK 3rd party which is itself a PCL 3rd party. Thus we enable nlohmann json usage turning USE_NLOHMANN_JSON=ON.")
unset(USE_NLOHMANN_JSON)
set(USE_NLOHMANN_JSON ON CACHE BOOL "Include nlohmann json support thanks to VTK" FORCE)
endif()
endif()
endif()
# ----------------------------------------------------------------------------
# Handle OpenCV 2.4.8 as minimal version
# ----------------------------------------------------------------------------
if(USE_OPENCV)
if(OpenCV_VERSION)
if(OpenCV_VERSION VERSION_LESS "2.4.8")
message(WARNING "OpenCV 3rd party was detected but its version ${OpenCV_VERSION} is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
else()
message(WARNING "OpenCV 3rd party was detected but its version cannot be found or is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
endif()
# ----------------------------------------------------------------------------
# Handle cxx standard depending on specific 3rd parties. Should be before module parsing and VISP3rdParty.cmake include
# ----------------------------------------------------------------------------
# if c++ standard is not at leat c++17, force 3rd parties that require at least c++17 to OFF
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_17)
if(USE_MAVSDK)
message(WARNING "mavsdk 3rd party was detected and needs at least c++17 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable MAVSDK usage turning USE_MAVSDK=OFF.")
unset(USE_MAVSDK)
set(USE_MAVSDK OFF CACHE BOOL "Include mavsdk support for mavlink compatible devices" FORCE)
endif()
endif()
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_14)
if(USE_FTIITSDK)
message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_FTIITSDK=OFF.")
unset(USE_FTIITSDK)
set(USE_FTIITSDK OFF CACHE BOOL "Include IIT force-torque SDK support" FORCE)
endif()
if(USE_PCL AND (PCL_VERSION VERSION_GREATER 1.9.1))
# pcl > 1.9.1 requires c++14
message(WARNING "pcl 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable pcl usage turning USE_PCL=OFF.")
unset(USE_PCL)
set(USE_PCL OFF CACHE BOOL "Include pcl support" FORCE)
endif()
endif()
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_11)
if(USE_OPENCV)
message(WARNING "OpenCV 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
if(USE_NLOHMANN_JSON)
message(WARNING "nlohmann json 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable nlohmann json usage turning USE_NLOHMANN_JSON=OFF.")
unset(USE_NLOHMANN_JSON)
set(USE_NLOHMANN_JSON OFF CACHE BOOL "Include nlohmann json support" FORCE)
endif()
if(USE_REALSENSE2)
message(WARNING "librealsense2 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable realsense2 usage turning USE_REALSENSE2=OFF.")
unset(USE_REALSENSE2)
set(USE_REALSENSE2 OFF CACHE BOOL "Include librealsense2 support" FORCE)
endif()
if(USE_XML2)
message(WARNING "libxml2 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable libxml2 usage turning USE_XML2=OFF.")
unset(USE_XML2)
set(USE_XML2 OFF CACHE BOOL "Include libxml2 support" FORCE)
endif()
if(USE_QUALISYS)
message(WARNING "Qualisys SDK 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable qualisys usage turning USE_QUALISYS=OFF.")
unset(USE_QUALISYS)
set(USE_QUALISYS OFF CACHE BOOL "Include Qualisys SDK support" FORCE)
endif()
if(USE_BICLOPS)
message(WARNING "Biclops SDK 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable biclops usage turning USE_BICLOPS=OFF.")
unset(USE_BICLOPS)
set(USE_BICLOPS OFF CACHE BOOL "Include biclops support" FORCE)
endif()
if(USE_ARSDK)
message(WARNING "Parrot ARSDK 3rd party was detected and needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable ARSDK usage turning USE_ARSDK=OFF.")
unset(USE_ARSDK)
set(USE_ARSDK OFF CACHE BOOL "Include Parrot ARSDK support" FORCE)
endif()
if(USE_THREADS)
message(WARNING "std::thread was detected but needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable std::thread usage turning USE_THREADS=OFF.")
unset(USE_THREADS)
set(USE_THREADS OFF CACHE BOOL "Include std::thread support" FORCE)
endif()
if(USE_PANDA3D)
message(WARNING "Panda3D was detected but needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable Panda3D usage turning USE_PANDA3D=OFF.")
unset(USE_PANDA3D)
set(USE_PANDA3D OFF CACHE BOOL "Include Panda3D support" FORCE)
endif()
endif()
if(UNIX AND Threads_FOUND)
# Apriltag on unix needs native pthread. On windows we are using pthread built-in
set(USE_PTHREAD ON) # for AprilTag only
endif()
# ----------------------------------------------------------------------------
# Build-in 3rd parties. Should be after c++ standard potential modification
# ----------------------------------------------------------------------------
# Since C99 is not supported by MSVC 2010 or prior, we disable apriltag if MSVC < 2012
VP_OPTION(WITH_APRILTAG "" "" "Use AprilTag as built-in library" "" ON IF (USE_THREADS OR USE_PTHREAD) AND (NOT WINRT) AND (NOT MSVC_VERSION LESS 1700))
VP_OPTION(WITH_APRILTAG_BIG_FAMILY "" "" "Use AprilTag big family (41h12, 48h12, 49h12, 52h13)" "" OFF IF WITH_APRILTAG)
VP_OPTION(WITH_MINIZ "" "" "Use npz related I/O as built-in functions" "" ON)
VP_OPTION(WITH_ATIDAQ "" "" "Use atidaq-c as built-in library" "" ON IF USE_COMEDI AND NOT WINRT)
VP_OPTION(WITH_CLIPPER "" "" "Use clipper as built-in library" "" ON IF USE_OPENCV)
VP_OPTION(WITH_LAPACK "" "" "Use lapack as built-in library" "" ON IF NOT USE_LAPACK)
VP_OPTION(WITH_QBDEVICE "" "" "Use qbdevice-api as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS))
VP_OPTION(WITH_TAKKTILE2 "" "" "Use Right Hand takktile2 driver as built-in library" "" ON IF (NOT WIN32) AND (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_CATCH2 "" "" "Use catch2 built-in library" "" ON)
VP_OPTION(WITH_POLOLU "" "" "Use rapa pololu as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_PUGIXML "" "" "Use pugixml built-in third-party" "" ON)
VP_OPTION(WITH_SIMDLIB "" "" "Use simdlib built-in third-party" "" ON)
VP_OPTION(WITH_STBIMAGE "" "" "Use std_image built-in third-party" "" ON)
VP_OPTION(WITH_TINYEXR "" "" "Use tinyexr built-in third-party" "" ON)
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_11)
if(WITH_POLOLU)
message(WARNING "pololu 3rd party needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable pololu usage turning WITH_POLOLU=OFF.")
unset(WITH_POLOLU)
set(WITH_POLOLU OFF CACHE BOOL "Build rapa pololu as built-in library" FORCE)
endif()
if(WITH_QBDEVICE)
message(WARNING "qbdevice-api 3rd party needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable qbdevice usage turning WITH_QBDEVICE=OFF.")
unset(WITH_QBDEVICE)
set(WITH_QBDEVICE OFF CACHE BOOL "Build rapa pololu as built-in library" FORCE)
endif()
if(WITH_TAKKTILE2)
message(WARNING "Right Hand takktile2 3rd party needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable takktile2 usage turning WITH_TAKKTILE2=OFF.")
unset(WITH_TAKKTILE2)
set(WITH_TAKKTILE2 OFF CACHE BOOL "Build rapa pololu as built-in library" FORCE)
endif()
endif()
if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_14)
if(WITH_CATCH2)
message(WARNING "catch2 3rd party needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable catch2 usage turning WITH_CATCH2=OFF.")
unset(WITH_CATCH2)
set(WITH_CATCH2 OFF CACHE BOOL "Use catch2 built-in library" FORCE)
endif()
endif()
# ----------------------------------------------------------------------------
# Check for specific functions. Should be after cxx standard detection in VISPDetectCXXStandard.cmake and
# potential modification depending on pcl, realsense2, libfranka
# ----------------------------------------------------------------------------
VP_CHECK_PACKAGE(IsNaN)
VP_CHECK_PACKAGE(IsInf)
VP_CHECK_PACKAGE(Round)
VP_CHECK_PACKAGE(Erfc)
VP_CHECK_PACKAGE(Strtof)
VP_CHECK_PACKAGE(IsFinite)
VP_CHECK_PACKAGE(Log1p)
#----------------------------------------------------------------------
# For Dart server and tests
# We use CDash set through CTestConfig.cmake file
# Dashboards are sent to https://cdash-ci.inria.fr/index.php?project=ViSP
#----------------------------------------------------------------------
if(BUILD_TESTS OR BUILD_EXAMPLES OR BUILD_DEMOS)
enable_testing()
mark_as_advanced(DART_ROOT)
mark_as_advanced(BUILD_TESTING)
endif()
#----------------------------------------------------------------------
# Try to find doxygen for documentation generation
# Use "make visp_doc" target to generate the documentation
#----------------------------------------------------------------------
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(VISP_HAVE_DOXYGEN "yes") # for header vpConfig.h
## we need latex for doxygen because of the formulas
find_package(LATEX)
if(NOT LATEX_COMPILER)
message(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user interaction on doxy run.")
endif()
if(NOT MAKEINDEX_COMPILER)
message(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
endif()
if(NOT DVIPS_CONVERTER)
message(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
endif()
# set vars used in doxygen config file
# - DOXYGEN_STRIP_FROM_INC_PATH corresponding to STRIP_FROM_INC_PATH in the doxy file
set(DOXYGEN_STRIP_FROM_INC_PATH "")
foreach(m ${VISP_MODULES_BUILD} ${VISP_MODULES_DISABLED_USER} ${VISP_MODULES_DISABLED_AUTO} ${VISP_MODULES_DISABLED_FORCE})
if(m MATCHES "^visp_")
set(DOXYGEN_STRIP_FROM_INC_PATH "${DOXYGEN_STRIP_FROM_INC_PATH} \\ \n\t\t\t \"${VISP_MODULE_${m}_LOCATION}/include\"")
endif()
endforeach()
# - DOXYGEN_IMAGE_PATH corresponding to IMAGE_PATH in the doxy file
set(DOXYGEN_IMAGE_PATH "\"${VISP_SOURCE_DIR}/doc/image\"")
if(VISP_CONTRIB_MODULES_PATH)
foreach(contrib ${VISP_CONTRIB_MODULES_PATH})
set(image_path_ "${VISP_CONTRIB_MODULES_PATH}/doc/image")
if(EXISTS ${image_path_})
set(DOXYGEN_IMAGE_PATH "${DOXYGEN_IMAGE_PATH} \\ \n\t\t\t \"${image_path_}\"")
endif()
endforeach()
endif()
# - DOXYGEN_CITE_BIB_FILES corresponding to CITE_BIB_FILES in the doxy file
set(DOXYGEN_CITE_BIB_FILES "\"${VISP_SOURCE_DIR}/doc/biblio/references.bib\"")
if(VISP_CONTRIB_MODULES_PATH)
set(cite_bib_file_ "${VISP_CONTRIB_MODULES_PATH}/doc/biblio/references.bib")
if(EXISTS ${cite_bib_file_})
set(DOXYGEN_CITE_BIB_FILES "${DOXYGEN_CITE_BIB_FILES} \\ \n\t\t\t \"${cite_bib_file_}\"")
endif()
endif()
# - DOXYGEN_SHOULD_SKIP_THIS var
if (ENABLE_FULL_DOC)
set(DOXYGEN_SHOULD_SKIP_THIS "")
else()
set(DOXYGEN_SHOULD_SKIP_THIS "DOXYGEN_SHOULD_SKIP_THIS")
endif()
# - DOXYGEN_USE_MATHJAX corresponding to USE_MATHJAX in the doxy file
VP_OPTION(USE_MATHJAX "" "" "Use MathJax to generate latex formula" "" OFF)
if (USE_MATHJAX)
set(DOXYGEN_USE_MATHJAX "YES")
else()
set(DOXYGEN_USE_MATHJAX "NO")
endif()
# HTML version of the doc
set(DOXYGEN_GENERATE_HTML "YES")
set(DOXYGEN_GENERATE_XML "NO")
set(DOXYGEN_GENERATE_TEST_LIST "YES")
set(DOXYGEN_QUIET "NO")
set(DOXYGEN_INPUTS
"${VISP_SOURCE_DIR}/modules"
"${VISP_SOURCE_DIR}/example"
"${VISP_SOURCE_DIR}/tutorial"
"${VISP_SOURCE_DIR}/demo"
"${VISP_SOURCE_DIR}/doc"
"${VISP_BINARY_DIR}/doc"
"${VISP_CONTRIB_MODULES_PATH}"
)
string (REPLACE ";" " " DOXYGEN_INPUTS "${DOXYGEN_INPUTS}")
configure_file(${VISP_SOURCE_DIR}/doc/config-doxygen.in
${VISP_DOC_DIR}/config-doxygen
@ONLY )
# XML version of the doc
set(DOXYGEN_GENERATE_HTML "NO")
set(DOXYGEN_GENERATE_XML "YES")
set(DOXYGEN_GENERATE_TEST_LIST "NO")
set(DOXYGEN_QUIET "YES")
set(DOXYGEN_INPUTS
"${VISP_SOURCE_DIR}/modules"
)
string (REPLACE ";" " " DOXYGEN_INPUTS "${DOXYGEN_INPUTS}")
configure_file(${VISP_SOURCE_DIR}/doc/config-doxygen.in
${VISP_DOC_DIR}/config-doxygen-xml
@ONLY )
# set vars used in mainpage.dox.in
# - VISP_MAINPAGE_EXTENSION
set(VISP_MAINPAGE_EXTENSION "")
if(VISP_CONTRIB_MODULES_PATH)
foreach(contrib ${VISP_CONTRIB_MODULES_PATH})
set(mainpage_ext_file_ "${contrib}/doc/mainpage_extension.doc")
if(EXISTS ${mainpage_ext_file_})
file(READ ${mainpage_ext_file_} mainpage_ext_content_)
set(VISP_MAINPAGE_EXTENSION "${VISP_MAINPAGE_EXTENSION}\n${mainpage_ext_content_}")
endif()
endforeach()
endif()
configure_file(${VISP_SOURCE_DIR}/doc/mainpage.dox.in
${VISP_DOC_DIR}/mainpage.dox
@ONLY )
else()
set(VISP_HAVE_DOXYGEN "no") # for header vpConfig.h
endif()
# ----------------------------------------------------------------------------
# Extra ViSP targets: uninstall, etc.
# ----------------------------------------------------------------------------
include(cmake/VISPExtraTargets.cmake)
# Ogre plugins and resources
include(cmake/OgreTools.cmake)
if(USE_OGRE)
vp_set_ogre_media()
endif()
#----------------------------------------------------------------------
# Add definitions
#----------------------------------------------------------------------
# With Visual Studio 2005, Microsoft deprecates the standard C library, for
# example fopen() and sprintf(), to non-portable functions fopen_s() and
# sprintf_s(). These functions are considered by Microsoft more secure. This is
# a worthwhile exercise ! The use of these deprecated functions causes a lot of
# warnings. To suppress it, we add the _CRT_SECURE_NO_DEPRECATE preprocessor
# definition
if(WIN32 AND MSVC)
add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
add_definitions("-D_SCL_SECURE_NO_WARNINGS") # to avoid warning C4996; std::copy::_Unchecked_iterators::_Deprecate