1 cmake_minimum_required(VERSION 2.8)
3 set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp)
5 SET(FFT "OpenCV" CACHE STRING "Select FFT implementation")
6 SET_PROPERTY(CACHE FFT PROPERTY STRINGS OpenCV OpenCV_cuFFT fftw cuFFTW cuFFT)
7 MESSAGE(STATUS "FFT implementation: ${FFT}")
9 option(OPENMP "Use OpenMP library. Works with FFTW and OpenCV implementation." OFF)
10 option(ASYNC "Works only if OPENCV_CUFFT is not ON. Will enable C++ async directive." OFF)
11 option(CUDA_DEBUG "Enables error cheking for cuda and cufft. " OFF)
12 option(BIG_BATCH "Enable transforming all features from all scales together." OFF)
13 option(TEMPLATE_COMPLEXMAT "Use ComplexMat as abstract class." ON)
16 add_definitions(-DPROFILING )
17 MESSAGE(STATUS "Profiling mode")
21 add_definitions(-DBIG_BATCH )
22 MESSAGE(STATUS "Big_batch mode")
25 IF(TEMPLATE_COMPLEXMAT)
26 add_definitions(-DTEMPLATE_COMPLEXMAT )
27 MESSAGE(STATUS "ComplexMat abstract class version.")
32 IF(FFT STREQUAL "OpenCV")
33 list(APPEND KCF_LIB_SRC fft_opencv.cpp complexmat.hpp)
34 ELSEIF(FFT STREQUAL "OpenCV_cuFFT")
35 list(APPEND KCF_LIB_SRC fft_opencv_cuda.cpp complexmat.hpp)
36 add_definitions(-DOPENCV_CUFFT)
38 ELSEIF(FFT STREQUAL "fftw")
39 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
40 add_definitions(-DFFTW)
41 ELSEIF(FFT STREQUAL "cuFFTW")
42 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
43 add_definitions(-DFFTW -DCUFFTW)
45 ELSEIF(FFT STREQUAL "cuFFT")
46 list(APPEND KCF_LIB_SRC fft_cufft.cpp complexmat.cuh cuda_functions.cuh)
47 add_definitions(-DCUFFT)
50 add_definitions(-DCUDA_DEBUG)
51 MESSAGE(STATUS "CUDA debug mode")
54 MESSAGE(FATAL_ERROR "Invalid FFT implementation selected")
57 IF((FFT STREQUAL "OpenCV") AND BIG_BATCH)
58 message(SEND_ERROR "OpenCV version does not support big batch mode.")
61 IF((FFT STREQUAL "cuFFT") AND (ASYNC OR (OPENMP AND NOT BIG_BATCH)))
62 message(SEND_ERROR "cuFFT version does not support ASYNC and OpenMP only if used with big batch mode.")
65 IF(ASYNC AND NOT OPENMP)
66 add_definitions(-DASYNC)
67 MESSAGE(STATUS "ASYNC")
70 FIND_PACKAGE( OpenCV REQUIRED )
73 find_package(CUDA REQUIRED)
75 if (NOT ${OpenCV_USE_CUFFT})
76 message(SEND_ERROR "OpenCV was not built with cuFFT")
79 include_directories ( ${CUDA_INCLUDE_DIRS} )
80 set(CUDA_SEPARABLE_COMPILATION ON)
81 set(CUDA_PROPAGATE_HOST_FLAGS OFF)
82 set(CUDA_HOST_COMPILER /usr/bin/g++)
83 list( APPEND CUDA_NVCC_FLAGS -O3 --gpu-architecture sm_62 -std=c++11 -default-stream per-thread)
84 find_cuda_helper_libs(cufftw)
85 IF(FFT STREQUAL "cuFFT")
86 add_subdirectory(cuda)
87 cuda_add_library(complexmat complexmat.cu)
88 cuda_add_library(cuda_func cuda_functions.cu)
93 add_subdirectory(piotr_fhog)
96 add_library(kcf STATIC ${KCF_LIB_SRC})
97 IF(NOT TEMPLATE_COMPLEXMAT)
98 add_library(complexmat complexmat.cpp)
99 target_link_libraries(kcf fhog cndata complexmat ${OpenCV_LIBS})
101 target_link_libraries(kcf fhog cndata ${OpenCV_LIBS})
103 set_target_properties(kcf PROPERTIES VERSION 1.0.0 SOVERSION 1)
105 IF(FFT STREQUAL "fftw")
106 target_link_libraries(kcf fftw3f)
108 target_link_libraries(kcf fftw3_omp)
110 target_link_libraries(kcf fftw3_threads)
114 IF(FFT STREQUAL "cuFFTW")
115 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_cufftw_LIBRARY})
118 IF(FFT STREQUAL "cuFFT")
119 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_LIBRARIES} complexmat cuda_func)
123 target_link_libraries(kcf pfm)