-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
1756 lines (1522 loc) · 73.3 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
# ----------------------------------------------------------------------------
# Root CMake file for OpenCV
#
# From the off-tree build directory, invoke:
# $ cmake <PATH_TO_OPENCV_ROOT>
#
#
# - OCT-2008: Initial version <joseluisblancoc@gmail.com>
#
# ----------------------------------------------------------------------------
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Following block can broke build in case of cross-compilng
# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
# so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
if(NOT CMAKE_TOOLCHAIN_FILE)
# Add these standard paths to the search paths for FIND_LIBRARY
# to find libraries from these locations first
if(UNIX)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib /usr/lib)
endif()
# it _must_ go before PROJECT(OpenCV) in order to work
if(WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
else()
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
endif()
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
endif(NOT CMAKE_TOOLCHAIN_FILE)
# --------------------------------------------------------------
# Top level OpenCV project
# --------------------------------------------------------------
cmake_minimum_required(VERSION 2.4)
project(OpenCV)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if(DEFINED CMAKE_BUILD_TYPE)
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
endif()
set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
set(CMAKE_VERBOSE OFF CACHE BOOL "Verbose mode")
if(CMAKE_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE 1)
endif()
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
# and absolute paths in linker lib lists.
# Run "cmake --help-policy CMP0003" for more information.
# --------------------------------------------------------------
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif()
# ----------------------------------------------------------------------------
# Build static or dynamic libs?
# Default: dynamic libraries
# ----------------------------------------------------------------------------
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
# ----------------------------------------------------------------------------
# Include debug info into debug libs?
# Default: yes
# ----------------------------------------------------------------------------
set(BUILD_WITH_DEBUG_INFO ON CACHE BOOL "Include debug info into debug libs")
# ----------------------------------------------------------------------------
# Get actual OpenCV version number from sources
# ----------------------------------------------------------------------------
SET(OPENCV_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/modules/core/include/opencv2/core/version.hpp")
FILE(STRINGS "${OPENCV_VERSION_FILE}" OPENCV_VERSION_PARTS REGEX "#define CV_.+OR_VERSION[ ]+[0-9]+" )
string(REGEX REPLACE ".+CV_MAJOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJOR "${OPENCV_VERSION_PARTS}")
string(REGEX REPLACE ".+CV_MINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
string(REGEX REPLACE ".+CV_SUBMINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
# create a dependency on version file
# we will never use output of the following command but cmake will rerun if version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
#if(WIN32)
# # Postfix of DLLs:
# set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
# set(OPENCV_DEBUG_POSTFIX d)
#else()
# # Postfix of so's:
set(OPENCV_DLLVERSION "")
set(OPENCV_DEBUG_POSTFIX)
#endif()
#name mangling
set(OPENCV_INCLUDE_PREFIX include)
if(UNIX AND NOT ANDROID AND BUILD_SHARED_LIBS)
option(OPENCV_MANGLED_INSTALL_PATHS "Enables mangled install paths, that help with side by side installs." False)
if(OPENCV_MANGLED_INSTALL_PATHS)
set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
endif()
endif()
# SUBDIRECTORIES:
# Save libs and executables in the same place
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Output directory for libraries" )
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
if(ANDROID OR WIN32)
set(OPENCV_DOC_INSTALL_PATH doc)
elseif(OPENCV_MANGLED_INSTALL_PATHS)
set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
else()
set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
endif()
if(ANDROID)
set(OPENCV_LIB_INSTALL_PATH libs/${ARMEABI_NDK_NAME})
else()
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# ----------------------------------------------------------------------------
# Use statically or dynamically linked CRT?
# Default: dynamic
# ----------------------------------------------------------------------------
if(WIN32 AND NOT BUILD_SHARED_LIBS)
option (BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT" ON)
endif()
if(MSVC)
if(BUILD_WITH_STATIC_CRT)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
if(${flag_var} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
else(BUILD_WITH_STATIC_CRT)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
endif()
if(${flag_var} MATCHES "/MTd")
string(REGEX REPLACE "/MTd" "/MDd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
endif(BUILD_WITH_STATIC_CRT)
if(NOT BUILD_WITH_DEBUG_INFO)
string(REPLACE "/debug" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/debug" "" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/debug" "" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/Zi" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
endif()
endif(MSVC)
# ----------------------------------------------------------------------------
# Variables for cvconfig.h.cmake
# ----------------------------------------------------------------------------
set(PACKAGE "opencv")
set(PACKAGE_BUGREPORT "opencvlibrary-devel@lists.sourceforge.net")
set(PACKAGE_NAME "opencv")
set(PACKAGE_STRING "${PACKAGE} ${OPENCV_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE}")
set(PACKAGE_VERSION "${OPENCV_VERSION}")
# ----------------------------------------------------------------------------
# Autodetect if we are in a SVN repository
# ----------------------------------------------------------------------------
find_host_program(SVNVERSION_PATH svnversion)
mark_as_advanced(force SVNVERSION_PATH)
if(SVNVERSION_PATH)
message(STATUS "Extracting svn version, please wait...")
execute_process(COMMAND ${SVNVERSION_PATH} -n ${OpenCV_SOURCE_DIR} OUTPUT_VARIABLE SVNVERSION_RESULT)
if(SVNVERSION_RESULT MATCHES "exported")
# This is NOT a svn repository:
set(OPENCV_SVNVERSION "")
message(STATUS "SVNVERSION: exported")
else()
set(OPENCV_SVNVERSION " svn:${SVNVERSION_RESULT}")
message(STATUS "SVNVERSION: ${OPENCV_SVNVERSION}")
endif()
else()
# We don't have svnversion:
set(OPENCV_SVNVERSION "")
endif()
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if(CMAKE_CL_64)
set(MSVC64 1)
endif()
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
# Look for the version number
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
# Split the three parts:
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
if(WIN32)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
set(MINGW64 1)
endif()
endif()
endif()
# ----------------------------------------------------------------------------
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
# see include/opencv/cxtypes.h file for related ICC & CV_ICC defines.
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
# for the 3rdparty static libs being compiled. The CMakeLists.txt files
# in 3rdparty use the CV_ICC definition being set here to determine if
# the -fPIC flag should be used.
# ----------------------------------------------------------------------------
if(UNIX)
if (__ICL)
set(CV_ICC __ICL)
elseif(__ICC)
set(CV_ICC __ICC)
elseif(__ECL)
set(CV_ICC __ECL)
elseif(__ECC)
set(CV_ICC __ECC)
elseif(__INTEL_COMPILER)
set(CV_ICC __INTEL_COMPILER)
elseif(CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC icc_matches_c_compiler)
endif()
endif()
# ----------------------------------------------------------------------------
# CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
# ----------------------------------------------------------------------------
# Build/install (or not) some apps:
# ===================================================
set(BUILD_EXAMPLES OFF CACHE BOOL "Build all examples")
set(INSTALL_C_EXAMPLES OFF CACHE BOOL "Install C examples")
set(INSTALL_PYTHON_EXAMPLES OFF CACHE BOOL "Install Python examples")
if(ANDROID)
set(INSTALL_ANDROID_EXAMPLES OFF CACHE BOOL "Install Android examples")
endif()
# Build tests:
# ===================================================
set(BUILD_TESTS ON CACHE BOOL "Build tests")
# Build 3rdparty libraries under unix
# ===================================================
if(WIN32)
set(OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE BOOL "Build 3rd party libraries")
else()
set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries")
endif()
include(OpenCVPCHSupport.cmake REQUIRED)
include(OpenCVModule.cmake REQUIRED)
if(ANDROID)
include(OpenCVAndroidProject.cmake REQUIRED)
endif()
if(PCHSupport_FOUND)
SET(USE_PRECOMPILED_HEADERS ON CACHE BOOL "Use precompiled headers")
else()
SET(USE_PRECOMPILED_HEADERS OFF CACHE BOOL "Use precompiled headers" FORCE)
endif()
if(UNIX)
include(OpenCVFindPkgConfig.cmake OPTIONAL)
include(CheckFunctionExists)
include(CheckIncludeFile)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(ENABLE_PROFILING OFF CACHE BOOL "Enable profiling in the GCC compiler (Add flags: -g -pg)")
set(USE_OMIT_FRAME_POINTER ON CACHE BOOL "Enable -fomit-frame-pointer for GCC")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64.*|x86_64.*)
set(X86_64 1)
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686.*|i386.*|x86.*)
set(X86 1)
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES powerpc.*)
set(ENABLE_POWERPC ON CACHE BOOL "Enable PowerPC for GCC")
endif ()
if(X86 OR X86_64)
# enable everything, since the available set of instructions is checked at runtime
#IF ("${CMAKE_GCC_REGEX_VERSION}" VERSION_GREATER 4.5)
SET(_USE_FAST_MATH OFF)
#ELSE()
# SET(_USE_FAST_MATH ON)
#ENDIF()
set(USE_FAST_MATH ${_USE_FAST_MATH} CACHE BOOL "Enable -ffast-math (not recommended for GCC 4.6.x)")
set(ENABLE_SSE ON CACHE BOOL "Enable SSE instructions")
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 instructions")
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 instructions")
set(ENABLE_SSSE3 OFF CACHE BOOL "Enable SSSE3 instructions")
set(ENABLE_SSE41 OFF CACHE BOOL "Enable SSE4.1 instructions")
set(ENABLE_SSE42 OFF CACHE BOOL "Enable SSE4.2 instructions")
endif()
endif()
if(MSVC)
set(ENABLE_SSE ON CACHE BOOL "Enable SSE instructions for MSVC")
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 instructions for MSVC")
if(CMAKE_C_COMPILER MATCHES "icc")
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 instructions for ICC")
set(ENABLE_SSE4_1 OFF CACHE BOOL "Enable SSE4.1 instructions for ICC")
endif()
endif()
# allow fine grained control over which libraries not to link, even if
# they are available on the system
# ====================================================================
set(WITH_PNG ON CACHE BOOL "Include PNG support")
set(WITH_JPEG ON CACHE BOOL "Include JPEG support")
set(WITH_JASPER ON CACHE BOOL "Include JPEG2K support")
set(WITH_TIFF ON CACHE BOOL "Include TIFF support")
set(WITH_OPENEXR ON CACHE BOOL "Include ILM support via OpenEXR")
if(UNIX)
set(WITH_FFMPEG ON CACHE BOOL "Include FFMPEG support")
if(NOT APPLE)
set(WITH_UNICAP OFF CACHE BOOL "Include Unicap support (GPL)")
set(WITH_GTK ON CACHE BOOL "Include GTK support")
set(WITH_GSTREAMER ON CACHE BOOL "Include Gstreamer support")
set(WITH_V4L ON CACHE BOOL "Include Video 4 Linux support")
set(WITH_XINE OFF CACHE BOOL "Include Xine support (GPL)")
endif()
set(WITH_PVAPI ON CACHE BOOL "Include Prosilica GigE support")
set(WITH_1394 ON CACHE BOOL "Include IEEE1394 support")
endif()
if(APPLE)
set(WITH_CARBON OFF CACHE BOOL "Use Carbon for UI instead of Cocoa")
set(WITH_QUICKTIME OFF CACHE BOOL "Use QuickTime for Video I/O insted of QTKit")
endif()
set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support")
set(WITH_IPP OFF CACHE BOOL "Include Intel IPP support")
set(WITH_EIGEN ON CACHE BOOL "Include Eigen2/Eigen3 support")
set(WITH_CUDA ON CACHE BOOL "Include NVidia Cuda Runtime support")
set(WITH_OPENNI OFF CACHE BOOL "Include OpenNI support")
set(WITH_XIMEA OFF CACHE BOOL "Include XIMEA cameras support")
# ===================================================
# Macros that checks if module have been installed.
# After it adds module to build and define
# constants passed as second arg
# ===================================================
macro(CHECK_MODULE module_name define)
set(${define} 0)
if(PKG_CONFIG_FOUND)
set(ALIAS ALIASOF_${module_name})
set(ALIAS_FOUND ${ALIAS}_FOUND)
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
PKG_CHECK_MODULES(${ALIAS} ${module_name})
if (${ALIAS_FOUND})
set(${define} 1)
foreach(P "${ALIAS_INCLUDE_DIRS}")
if (${P})
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
endif()
endforeach()
foreach(P "${ALIAS_LIBRARY_DIRS}")
if (${P})
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
endif()
endforeach()
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
endif()
endif()
endmacro()
if(UNIX)
if(NOT APPLE)
if(WITH_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
else()
set(HAVE_GTK FALSE)
set(HAVE_GTHREAD FALSE)
endif()
if(WITH_GSTREAMER)
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
else()
set(HAVE_GSTREAMER FALSE)
endif()
endif()
if(WITH_UNICAP)
CHECK_MODULE(libunicap HAVE_UNICAP_)
CHECK_MODULE(libucil HAVE_UNICAP_UCIL)
if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
set(HAVE_UNICAP 1)
endif()
else()
set(HAVE_UNICAP FALSE)
endif()
if(WITH_PVAPI)
find_path(PVAPI_INCLUDE_PATH "PvApi.h"
PATHS "/usr/local/include" "/usr/include"
DOC "The path to PvAPI header")
if(PVAPI_INCLUDE_PATH)
set(HAVE_PVAPI 1)
endif()
endif()
set(HAVE_FFMPEG 0)
if(WITH_FFMPEG)
CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE)
set(HAVE_GENTOO_FFMPEG 1)
endif()
endif()
if(HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL)
if(HAVE_FFMPEG_SWSCALE OR NOT HAVE_GENTOO_FFMPEG)
set(HAVE_FFMPEG 1)
endif()
endif()
# Find the bzip2 library because it is required on some systems
FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
if(NOT BZIP2_LIBRARIES)
# Do an other trial
FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
endif()
endif()
if(WITH_1394)
CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
if(NOT HAVE_DC1394_2)
CHECK_MODULE(libdc1394 HAVE_DC1394)
endif()
else()
set(HAVE_DC1394_2 FALSE)
set(HAVE_DC1394 FALSE)
endif()
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
include(FindZLIB)
if(WITH_PNG)
include(FindPNG)
if(PNG_FOUND)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/png.h HAVE_PNG_H)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/libpng/png.h HAVE_LIBPNG_PNG_H)
endif()
else()
set(PNG_FOUND FALSE)
endif()
if(WITH_TIFF)
include(FindTIFF)
else()
set(TIFF_FOUND FALSE)
endif()
if(WITH_JASPER)
include(FindJasper)
else()
set(JASPER_FOUND FALSE)
endif()
if(WITH_JPEG)
include(FindJPEG)
else()
set(JPEG_FOUND FALSE)
endif()
endif()
if(NOT APPLE)
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
if(WITH_XINE)
CHECK_MODULE(libxine HAVE_XINE)
else()
set(HAVE_XINE FALSE)
endif()
if(WITH_V4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L)
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
else()
set(HAVE_LIBV4L FALSE)
set(HAVE_CAMV4L FALSE)
set(HAVE_CAMV4L2 FALSE)
endif()
if(ANDROID)
set(OPENCV_LINKER_LIBS dl m log)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
set(OPENCV_LINKER_LIBS m pthread)
else()
set(OPENCV_LINKER_LIBS dl m pthread rt)
endif()
else()
add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H)
endif()
endif()
if(WITH_PNG AND NOT PNG_FOUND)
set(PNG_LIBRARIES libpng)
endif()
if(WITH_JPEG AND NOT JPEG_FOUND)
set(JPEG_LIBRARIES libjpeg)
endif()
if(WITH_TIFF AND NOT TIFF_FOUND)
set(TIFF_LIBRARIES libtiff)
endif()
if(WITH_JASPER AND NOT JASPER_FOUND)
set(JASPER_LIBRARIES libjasper)
endif()
if(NOT ZLIB_FOUND)
set(ZLIB_LIBRARY zlib)
endif()
#message(STATUS "Graphic libraries: ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES}")
if(WITH_OPENEXR)
include(OpenCVFindOpenEXR.cmake)
endif()
set(BUILD_DOCS ON CACHE BOOL "Build OpenCV Documentation")
if(BUILD_DOCS)
include(OpenCVFindLATEX.cmake REQUIRED)
endif()
set(BUILD_NEW_PYTHON_SUPPORT ON CACHE BOOL "Build with Python support")
if (WIN32)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
endif()
if(ANDROID)
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
# Always try to find python
# ===================================================
find_host_package(PythonInterp)
find_host_package(PythonLibs)
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
set(PYTHONLIBS_FOUND ON)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages")
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.")
else() #debian based assumed, install to the dist-packages.
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
endif()
if(CMAKE_HOST_WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
IF ("${PYTHON_VERSION_MAJOR_MINOR}" VERSION_GREATER 2.4)
SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} -B)
ENDIF()
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]"
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
set(PYTHON_USE_NUMPY 1)
add_definitions(-D PYTHON_USE_NUMPY=1)
include_directories(AFTER ${PYTHON_NUMPY_INCLUDE_DIRS})
message(STATUS " Use NumPy headers from: ${PYTHON_NUMPY_INCLUDE_DIRS}")
else()
set(PYTHON_USE_NUMPY 0)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
RESULT_VARIABLE SPHINX_PROCESS
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HAVE_SPHINX 0)
if(SPHINX_PROCESS EQUAL 0)
find_host_program(SPHINX_BUILD sphinx-build)
if(SPHINX_BUILD)
set(HAVE_SPHINX 1)
message(STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}")
endif()
endif()
# Java support
# ===================================================
if (PYTHON_EXECUTABLE AND ANDROID AND ANDROID_API_LEVEL GREATER 7)
option(BUILD_JAVA_SUPPORT "Build with Java support" TRUE)
endif()
if (BUILD_JAVA_SUPPORT)
file(TO_CMAKE_PATH "$ENV{ANT_DIR}" ANT_DIR_ENV_PATH)
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
if(ANDROID)
file(TO_CMAKE_PATH "$ENV{ANDROID_SDK}" ANDROID_SDK_ENV_PATH)
#find android SDK
find_host_program(ANDROID_EXECUTABLE
NAMES android.bat android
PATHS "${ANDROID_SDK_ENV_PATH}/tools/"
"${ProgramFiles_ENV_PATH}/Android/android-sdk/tools/"
"/opt/android-sdk/tools/"
"/opt/android-sdk-linux_x86/tools/"
"/opt/android-sdk-mac_x86/tools/"
"/opt/android-sdk-linux_86/tools/"
"/opt/android-sdk-mac_86/tools/"
)
if(ANDROID_EXECUTABLE)
message(STATUS " Found android tool: ${ANDROID_EXECUTABLE}")
get_filename_component(ANDROID_SDK_TOOLS_PATH "${ANDROID_EXECUTABLE}" PATH)
#read source.properties
if (EXISTS "${ANDROID_SDK_TOOLS_PATH}/source.properties")
file(STRINGS "${ANDROID_SDK_TOOLS_PATH}/source.properties" ANDROID_SDK_TOOLS_SOURCE_PROPERTIES_LINES REGEX "^[ ]*[^#].*$")
foreach(line ${ANDROID_SDK_TOOLS_SOURCE_PROPERTIES_LINES})
string(REPLACE "\\:" ":" line ${line})
string(REPLACE "=" ";" line ${line})
list(GET line 0 line_name)
list(GET line 1 line_value)
string(REPLACE "." "_" line_name ${line_name})
SET(ANDROID_TOOLS_${line_name} "${line_value}")
MARK_AS_ADVANCED(ANDROID_TOOLS_${line_name})
endforeach()
endif()
if (NOT ANDROID_TOOLS_Pkg_Revision)
SET(ANDROID_TOOLS_Pkg_Revision "Unknown")
MARK_AS_ADVANCED(ANDROID_TOOLS_Pkg_Revision)
endif()
if (NOT ANDROID_TOOLS_Pkg_Desc)
SET(ANDROID_TOOLS_Pkg_Desc "Android SDK Tools, revision ${ANDROID_TOOLS_Pkg_Revision}.")
if (NOT ANDROID_TOOLS_Pkg_Revision GREATER 11)
SET(ANDROID_TOOLS_Pkg_Desc "${ANDROID_TOOLS_Pkg_Desc} It is recommended to update your SDK tools to revision 12 or newer.")
endif()
MARK_AS_ADVANCED(ANDROID_TOOLS_Pkg_Desc)
endif()
#get installed targets
execute_process(COMMAND ${ANDROID_EXECUTABLE} list target
RESULT_VARIABLE ANDROID_PROCESS
OUTPUT_VARIABLE ANDROID_SDK_TARGETS_FULL
ERROR_VARIABLE ANDROID_PROCESS_ERRORS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCHALL "(^|\n)id: [0-9]+ or \"([^\n]+[0-9+])\"(\n|$)" ANDROID_SDK_TARGETS_FULL "${ANDROID_SDK_TARGETS_FULL}")
SET(ANDROID_SDK_TARGETS)
if (ANDROID_PROCESS EQUAL 0)
foreach(line ${ANDROID_SDK_TARGETS_FULL})
string(REGEX REPLACE "(^|\n)id: [0-9]+ or \"([^\n]+[0-9+])\"(\n|$)" "\\2" line "${line}")
list(APPEND ANDROID_SDK_TARGETS "${line}")
endforeach()
endif()
# detect ANDROID_SDK_TARGET if no target is provided by user
if (NOT ANDROID_SDK_TARGET)
set(desired_android_target_level ${ANDROID_API_LEVEL})
if (desired_android_target_level LESS 8)
set(desired_android_target_level 8)
endif()
if (ANDROID_PROCESS EQUAL 0)
math(EXPR desired_android_target_level_1 "${desired_android_target_level}-1")
foreach(target ${ANDROID_SDK_TARGETS})
string(REGEX MATCH "[0-9]+$" target_level "${target}")
if (target_level GREATER desired_android_target_level_1)
set(ANDROID_SDK_TARGET "${target}")
break()
endif()
endforeach()
else()
set(ANDROID_SDK_TARGET android-${desired_android_target_level})
message(WARNING "Could not retrieve list of installed Android targets. Will try to use \"${ANDROID_SDK_TARGET}\" target")
endif()
endif()
SET(ANDROID_SDK_TARGET ${ANDROID_SDK_TARGET} CACHE STRING "SDK target for Android tests and samples")
if (ANDROID_PROCESS EQUAL 0)
set_property( CACHE ANDROID_SDK_TARGET PROPERTY STRINGS ${ANDROID_SDK_TARGETS} )
endif()
string(REGEX MATCH "[0-9]+$" ANDROID_SDK_TARGET_LEVEL "${ANDROID_SDK_TARGET}")
endif()
endif()
#find apache ant
find_host_program(ANT_EXECUTABLE NAMES ant.bat ant
PATHS "${ANT_DIR_ENV_PATH}/bin"
"${ProgramFiles_ENV_PATH}/apache-ant/bin"
)
if(ANT_EXECUTABLE)
execute_process(COMMAND ${ANT_EXECUTABLE} -version
OUTPUT_VARIABLE ANT_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" ANT_VERSION "${ANT_VERSION_FULL}")
message(STATUS " Found apache ant ${ANT_VERSION}: ${ANT_EXECUTABLE}")
endif()
if (ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_SDK_TARGET_LEVEL GREATER 7))
SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
else()
SET(CAN_BUILD_ANDROID_PROJECTS FALSE)
endif()
endif()
if(CAN_BUILD_ANDROID_PROJECTS)
SET(BUILD_ANDROID_EXAMPLES TRUE CACHE BOOL "Build examples for Android platform")
endif()
#YV
############################### QT ################################
set(WITH_QT OFF CACHE BOOL "Build with Qt Backend support")
set(WITH_QT_OPENGL OFF CACHE BOOL "Add OpenGL extension to Qt")
set(HAVE_QT 0)
set(HAVE_QT_OPENGL 0)
if (WITH_QT)
find_package(Qt4)
if (QT4_FOUND)
set(HAVE_QT 1)
add_definitions(-DHAVE_QT)#We need to define te macro this way, using cvconfig.h.cmake does not work
find_package (OpenGL QUIET)
#if (NOT WIN32)
if (WITH_QT_OPENGL)
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
#link_directories("${OPENGL_LIBRARIES}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
endif()
endif()
#endif()
endif()
endif()
############################### TBB ################################
if (WITH_TBB)
if (UNIX AND NOT APPLE AND NOT ANDROID)
PKG_CHECK_MODULES(TBB tbb)
if (TBB_FOUND)
set(HAVE_TBB 1)
if(NOT ${TBB_INCLUDE_DIRS} STREQUAL "")
include_directories(${TBB_INCLUDE_DIRS})
endif()
link_directories(${TBB_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${TBB_LIBRARIES})
endif()
endif()
if (NOT HAVE_TBB)
set(TBB_DEFAULT_INCLUDE_DIRS "/opt/intel/tbb" "/usr/local/include" "/usr/include" "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB" "C:/Program Files (x86)/TBB" "${CMAKE_INSTALL_PREFIX}/include")
find_path(TBB_INCLUDE_DIR "tbb/tbb.h" PATHS ${TBB_DEFAULT_INCLUDE_DIRS} DOC "The path to TBB headers")
if (TBB_INCLUDE_DIR)
if (UNIX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
if (APPLE)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libtbb.dylib)
elseif (ANDROID)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbbmalloc tbb)
add_definitions(-DTBB_USE_GCC_BUILTINS)
elseif (UNIX)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
elseif (WIN32)
if (CMAKE_COMPILER_IS_GNUCXX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
else()
get_filename_component(_TBB_LIB_PATH "${TBB_INCLUDE_DIR}/../lib" ABSOLUTE)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*|x86_64* OR MSVC64)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/intel64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86*|i386*|i686*)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/ia32")
endif()
if (MSVC80)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc8")
elseif(MSVC90)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc9")
elseif(MSVC10)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
endif()
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
endif()
set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIR}" STREQUAL "")
include_directories("${TBB_INCLUDE_DIR}")
endif()
endif()
endif()
endif(WITH_TBB)
#Threading Framework -- temporary decision for ARM-s instead of TBB
if (NOT HAVE_TBB)
file(GLOB THREADING_FRAMEWORK_HEADER "${OpenCV_SOURCE_DIR}/modules/core/include/opencv2/core/threading_framework.hpp")
file(GLOB THREADING_FRAMEWORK_SOURCE "${OpenCV_SOURCE_DIR}/modules/core/src/threading_framework.cpp")
if(THREADING_FRAMEWORK_HEADER AND THREADING_FRAMEWORK_SOURCE)
set(HAVE_THREADING_FRAMEWORK 1)
endif()
endif()
############################ Intel IPP #############################
set(IPP_FOUND)
if(WITH_IPP)
include(OpenCVFindIPP.cmake)
endif()
if(IPP_FOUND)
add_definitions(-DHAVE_IPP)
include_directories(${IPP_INCLUDE_DIRS})
link_directories(${IPP_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_LIBRARIES})
endif()
############################### CUDA ################################
if(WITH_CUDA)
find_package(CUDA 4.0)
if(CUDA_FOUND)
set(HAVE_CUDA 1)
message(STATUS "CUDA detected: " ${CUDA_VERSION})
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0)" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
set(CUDA_ARCH_PTX "2.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")
# Ckeck if user specified 1.0 compute capability: we don't support it
string(REGEX MATCH "1.0" HAS_ARCH_10 "${CUDA_ARCH_BIN} ${CUDA_ARCH_PTX}")
set(CUDA_ARCH_BIN_OR_PTX_10 0)
if(NOT ${HAS_ARCH_10} STREQUAL "")
set(CUDA_ARCH_BIN_OR_PTX_10 1)
endif()
# NVCC flags to be set
set(NVCC_FLAGS_EXTRA "")
# These vars will be passed into the templates
set(OPENCV_CUDA_ARCH_BIN "")
set(OPENCV_CUDA_ARCH_PTX "")
set(OPENCV_CUDA_ARCH_FEATURES "")
# Tell NVCC to add binaries for the specified GPUs
string(REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_NO_POINTS}")
foreach(ARCH IN LISTS ARCH_LIST)
if (ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)")
# User explicitly specified PTX for the concrete BIN
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1})
set(OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${CMAKE_MATCH_1}")
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${CMAKE_MATCH_2}")
else()
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${ARCH},code=sm_${ARCH})
set(OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${ARCH}")
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}")
endif()
endforeach()