1 cmake_minimum_required(VERSION 2.8)
3 set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp threadctx.hpp pragmas.h dynmem.hpp)
5 find_package(PkgConfig)
7 SET(FFT "OpenCV" CACHE STRING "Select FFT implementation")
8 SET_PROPERTY(CACHE FFT PROPERTY STRINGS OpenCV fftw cuFFTW cuFFT)
9 MESSAGE(STATUS "FFT implementation: ${FFT}")
11 option(OPENMP "Use OpenMP library. Works with FFTW and OpenCV implementation." OFF)
12 option(ASYNC "Works only if OPENCV_CUFFT is not ON. Will enable C++ async directive." OFF)
13 option(CUDA_DEBUG "Enables error cheking for cuda and cufft. " OFF)
14 option(BIG_BATCH "Enable transforming all features from all scales together." OFF)
17 add_definitions(-DPROFILING )
18 MESSAGE(STATUS "Profiling mode")
22 add_definitions(-DBIG_BATCH )
23 MESSAGE(STATUS "Big_batch mode")
28 IF(FFT STREQUAL "OpenCV")
29 list(APPEND KCF_LIB_SRC fft_opencv.cpp complexmat.hpp)
30 ELSEIF(FFT STREQUAL "fftw")
31 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
32 add_definitions(-DFFTW)
33 pkg_check_modules(FFTW REQUIRED fftw3f)
34 ELSEIF(FFT STREQUAL "cuFFTW")
35 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
36 add_definitions(-DFFTW -DCUFFTW)
38 ELSEIF(FFT STREQUAL "cuFFT")
39 list(APPEND KCF_LIB_SRC fft_cufft.cpp complexmat.cuh cuda_functions.cuh)
40 add_definitions(-DCUFFT)
43 add_definitions(-DCUDA_DEBUG)
44 MESSAGE(STATUS "CUDA debug mode")
47 MESSAGE(FATAL_ERROR "Invalid FFT implementation selected")
50 IF((FFT STREQUAL "OpenCV") AND BIG_BATCH)
51 message(SEND_ERROR "OpenCV version does not support big batch mode.")
54 IF((FFT STREQUAL "cuFFT") AND (ASYNC))
55 message(SEND_ERROR "cuFFT version does not support ASYNC and OpenMP only if used with big batch mode.")
59 add_definitions(-DASYNC)
60 MESSAGE(STATUS "ASYNC")
62 add_definitions(-DOPENMP)
63 MESSAGE(STATUS "OPENMP")
66 FIND_PACKAGE( OpenCV REQUIRED )
69 find_package(CUDA REQUIRED)
71 include_directories ( ${CUDA_INCLUDE_DIRS} )
72 set(CUDA_SEPARABLE_COMPILATION ON)
73 set(CUDA_PROPAGATE_HOST_FLAGS OFF)
74 list( APPEND CUDA_NVCC_FLAGS -O3 --gpu-architecture sm_62 -std=c++11)
75 find_cuda_helper_libs(cufftw)
76 IF(FFT STREQUAL "cuFFT")
77 add_subdirectory(cuda)
78 cuda_add_library(complexmat complexmat.cu)
79 cuda_add_library(cuda_func cuda_functions.cu)
84 add_subdirectory(piotr_fhog)
87 add_library(kcf STATIC ${KCF_LIB_SRC})
88 target_link_libraries(kcf fhog cndata ${OpenCV_LIBS})
89 set_target_properties(kcf PROPERTIES VERSION 1.0.0 SOVERSION 1)
91 IF(FFT STREQUAL "fftw")
92 target_link_libraries(kcf ${FFTW_LDFLAGS})
94 target_link_libraries(kcf fftw3_omp)
96 target_link_libraries(kcf fftw3_threads)
100 IF(FFT STREQUAL "cuFFTW")
101 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_cufftw_LIBRARY})
104 IF(FFT STREQUAL "cuFFT")
105 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_LIBRARIES} complexmat cuda_func)
109 target_link_libraries(kcf pfm)