1 cmake_minimum_required(VERSION 2.8)
3 set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp)
5 find_package(PkgConfig)
7 SET(FFT "OpenCV" CACHE STRING "Select FFT implementation")
8 SET_PROPERTY(CACHE FFT PROPERTY STRINGS OpenCV OpenCV_cuFFT 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)
15 option(TEMPLATE_COMPLEXMAT "Use ComplexMat as abstract class." ON)
18 add_definitions(-DPROFILING )
19 MESSAGE(STATUS "Profiling mode")
23 add_definitions(-DBIG_BATCH )
24 MESSAGE(STATUS "Big_batch mode")
27 IF(TEMPLATE_COMPLEXMAT)
28 add_definitions(-DTEMPLATE_COMPLEXMAT )
29 MESSAGE(STATUS "ComplexMat abstract class version.")
34 IF(FFT STREQUAL "OpenCV")
35 list(APPEND KCF_LIB_SRC fft_opencv.cpp complexmat.hpp)
36 ELSEIF(FFT STREQUAL "OpenCV_cuFFT")
37 list(APPEND KCF_LIB_SRC fft_opencv_cuda.cpp complexmat.hpp)
38 add_definitions(-DOPENCV_CUFFT)
40 ELSEIF(FFT STREQUAL "fftw")
41 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
42 add_definitions(-DFFTW)
43 pkg_check_modules(FFTW REQUIRED fftw3f)
44 ELSEIF(FFT STREQUAL "cuFFTW")
45 list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
46 add_definitions(-DFFTW -DCUFFTW)
48 ELSEIF(FFT STREQUAL "cuFFT")
49 list(APPEND KCF_LIB_SRC fft_cufft.cpp complexmat.cuh cuda_functions.cuh)
50 add_definitions(-DCUFFT)
53 add_definitions(-DCUDA_DEBUG)
54 MESSAGE(STATUS "CUDA debug mode")
57 MESSAGE(FATAL_ERROR "Invalid FFT implementation selected")
60 IF((FFT STREQUAL "OpenCV") AND BIG_BATCH)
61 message(SEND_ERROR "OpenCV version does not support big batch mode.")
64 IF((FFT STREQUAL "cuFFT") AND (ASYNC OR (OPENMP AND NOT BIG_BATCH)))
65 message(SEND_ERROR "cuFFT version does not support ASYNC and OpenMP only if used with big batch mode.")
68 IF(ASYNC AND NOT OPENMP)
69 add_definitions(-DASYNC)
70 MESSAGE(STATUS "ASYNC")
73 FIND_PACKAGE( OpenCV REQUIRED )
76 find_package(CUDA REQUIRED)
78 if (NOT ${OpenCV_USE_CUFFT})
79 message(SEND_ERROR "OpenCV was not built with cuFFT")
82 include_directories ( ${CUDA_INCLUDE_DIRS} )
83 set(CUDA_SEPARABLE_COMPILATION ON)
84 set(CUDA_PROPAGATE_HOST_FLAGS OFF)
85 set(CUDA_HOST_COMPILER /usr/bin/g++)
86 list( APPEND CUDA_NVCC_FLAGS -O3 --gpu-architecture sm_62 -std=c++11 -default-stream per-thread)
87 find_cuda_helper_libs(cufftw)
88 IF(FFT STREQUAL "cuFFT")
89 add_subdirectory(cuda)
90 cuda_add_library(complexmat complexmat.cu)
91 cuda_add_library(cuda_func cuda_functions.cu)
96 add_subdirectory(piotr_fhog)
99 add_library(kcf STATIC ${KCF_LIB_SRC})
100 IF(NOT TEMPLATE_COMPLEXMAT)
101 add_library(complexmat complexmat.cpp)
102 target_link_libraries(kcf fhog cndata complexmat ${OpenCV_LIBS})
104 target_link_libraries(kcf fhog cndata ${OpenCV_LIBS})
106 set_target_properties(kcf PROPERTIES VERSION 1.0.0 SOVERSION 1)
108 IF(FFT STREQUAL "fftw")
109 target_link_libraries(kcf ${FFTW_LDFLAGS})
111 target_link_libraries(kcf fftw3_omp)
113 target_link_libraries(kcf fftw3_threads)
117 IF(FFT STREQUAL "cuFFTW")
118 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_cufftw_LIBRARY})
121 IF(FFT STREQUAL "cuFFT")
122 target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_LIBRARIES} complexmat cuda_func)
126 target_link_libraries(kcf pfm)