]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - src/CMakeLists.txt
Removed zero copy for complexmat now it is using normal device memory. Added zero...
[hercules2020/kcf.git] / src / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2
3 set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp)
4
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}")
8
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(PROFILING "Enable profiling using perf_event_open together with libpfm4. " OFF)
12 option(BIG_BATCH "Enable transforming all features from all scales together." OFF)
13
14 IF(PROFILING)
15   add_definitions(-DPROFILING )
16   MESSAGE(STATUS "Profiling mode")
17 ENDIF()
18
19 IF(BIG_BATCH)
20   add_definitions(-DBIG_BATCH )
21   MESSAGE(STATUS "Big_batch mode")
22 ENDIF()
23
24 SET(use_cuda OFF)
25
26 IF(FFT STREQUAL "OpenCV")
27   list(APPEND KCF_LIB_SRC fft_opencv.cpp complexmat.hpp)
28 ELSEIF(FFT STREQUAL "OpenCV_cuFFT")
29   list(APPEND KCF_LIB_SRC fft_opencv_cuda.cpp complexmat.hpp)
30   add_definitions(-DOPENCV_CUFFT)
31   set(use_cuda ON)
32 ELSEIF(FFT STREQUAL "fftw")
33   list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
34   add_definitions(-DFFTW)
35 ELSEIF(FFT STREQUAL "cuFFTW")
36   list(APPEND KCF_LIB_SRC fft_fftw.cpp complexmat.hpp)
37   add_definitions(-DFFTW -DCUFFTW)
38   set(use_cuda ON)
39 ELSEIF(FFT STREQUAL "cuFFT")
40     list(APPEND KCF_LIB_SRC fft_cufft.cpp complexmat.cuh)
41     add_definitions(-DCUFFT)
42     set(use_cuda ON)
43 ELSE()
44   MESSAGE(FATAL_ERROR "Invalid FFT implementation selected")
45 ENDIF()
46
47 IF(ASYNC AND NOT OPENMP)
48   add_definitions(-DASYNC)
49   MESSAGE(STATUS "ASYNC")
50 ENDIF() #ASYNC
51
52 FIND_PACKAGE( OpenCV REQUIRED )
53
54 IF(use_cuda)
55   find_package(CUDA REQUIRED)
56
57   if (NOT ${OpenCV_USE_CUFFT})
58     message(SEND_ERROR "OpenCV was not built with cuFFT")
59   endif()
60
61   include_directories ( ${CUDA_INCLUDE_DIRS} )
62   set(CUDA_SEPARABLE_COMPILATION ON)
63   set(CUDA_PROPAGATE_HOST_FLAGS OFF)
64   set(CUDA_HOST_COMPILER /usr/bin/g++)
65   list( APPEND CUDA_NVCC_FLAGS -O3 --gpu-architecture sm_62 -std=c++11 -default-stream per-thread)
66   find_cuda_helper_libs(cufftw)
67   IF(FFT STREQUAL "cuFFT")
68   cuda_add_library(complexmat complexmat.cu)
69   ENDIF()
70   
71 ENDIF()
72
73 add_subdirectory(piotr_fhog)
74 add_subdirectory(cn)
75
76 add_library(kcf STATIC ${KCF_LIB_SRC})
77 target_link_libraries(kcf fhog cndata  ${OpenCV_LIBS})
78 set_target_properties(kcf PROPERTIES VERSION 1.0.0 SOVERSION 1)
79
80 IF(FFT STREQUAL "fftw")
81   target_link_libraries(kcf fftw3f)
82   IF(OPENMP)
83     target_link_libraries(kcf fftw3_omp)
84   ELSEIF(ASYNC)
85     target_link_libraries(kcf fftw3_threads)
86   ENDIF()
87 ENDIF() #FFTW
88
89 IF(FFT STREQUAL "cuFFTW")
90   target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_cufftw_LIBRARY})
91 ENDIF() #cuFFTW
92
93 IF(FFT STREQUAL "cuFFT")
94     target_link_libraries(kcf ${CUDA_cufft_LIBRARY} ${CUDA_LIBRARIES} complexmat)
95 ENDIF()
96
97 IF(PROFILING)
98   target_link_libraries(kcf pfm)
99 ENDIF()