Merge pull request #3103 from vpisarev:core_imgproc_optim_rearrangements
[profile/ivi/opencv.git] / cmake / OpenCVFindLibsPerf.cmake
1 # ----------------------------------------------------------------------------
2 #  Detect other 3rd-party performance and math libraries
3 # ----------------------------------------------------------------------------
4
5 # --- TBB ---
6 if(WITH_TBB)
7   include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
8 endif(WITH_TBB)
9
10 # --- IPP ---
11 if(WITH_IPP)
12   include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPP.cmake")
13   if(HAVE_IPP)
14     ocv_include_directories(${IPP_INCLUDE_DIRS})
15     list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
16   endif()
17 endif()
18
19 # --- IPP Async ---
20
21 if(WITH_IPP_A)
22   include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPAsync.cmake")
23   if(IPP_A_INCLUDE_DIR AND IPP_A_LIBRARIES)
24     ocv_include_directories(${IPP_A_INCLUDE_DIR})
25     link_directories(${IPP_A_LIBRARIES})
26     set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_A_LIBRARIES})
27    endif()
28 endif(WITH_IPP_A)
29
30 # --- CUDA ---
31 if(WITH_CUDA)
32   include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake")
33 endif(WITH_CUDA)
34
35 # --- Eigen ---
36 if(WITH_EIGEN)
37   find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
38             PATHS /usr/local /opt /usr $ENV{EIGEN_ROOT}/include ENV ProgramFiles ENV ProgramW6432
39             PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2
40             DOC "The path to Eigen3/Eigen2 headers"
41             CMAKE_FIND_ROOT_PATH_BOTH)
42
43   if(EIGEN_INCLUDE_PATH)
44     ocv_include_directories(${EIGEN_INCLUDE_PATH})
45     ocv_parse_header("${EIGEN_INCLUDE_PATH}/Eigen/src/Core/util/Macros.h" EIGEN_VERSION_LINES EIGEN_WORLD_VERSION EIGEN_MAJOR_VERSION EIGEN_MINOR_VERSION)
46     set(HAVE_EIGEN 1)
47   endif()
48 endif(WITH_EIGEN)
49
50 # --- Clp ---
51 # Ubuntu: sudo apt-get install coinor-libclp-dev coinor-libcoinutils-dev
52 ocv_clear_vars(HAVE_CLP)
53 if(WITH_CLP)
54   if(UNIX)
55     PKG_CHECK_MODULES(CLP clp)
56     if(CLP_FOUND)
57       set(HAVE_CLP TRUE)
58       if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "")
59         ocv_include_directories(${CLP_INCLUDE_DIRS})
60       endif()
61       link_directories(${CLP_LIBRARY_DIRS})
62       set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES})
63     endif()
64   endif()
65
66   if(NOT CLP_FOUND)
67     find_path(CLP_INCLUDE_PATH "coin"
68               PATHS "/usr/local/include" "/usr/include" "/opt/include"
69               DOC "The path to Clp headers")
70     if(CLP_INCLUDE_PATH)
71       ocv_include_directories(${CLP_INCLUDE_PATH} "${CLP_INCLUDE_PATH}/coin")
72       get_filename_component(_CLP_LIBRARY_DIR "${CLP_INCLUDE_PATH}/../lib" ABSOLUTE)
73       set(CLP_LIBRARY_DIR "${_CLP_LIBRARY_DIR}" CACHE PATH "Full path of Clp library directory")
74       link_directories(${CLP_LIBRARY_DIR})
75       if(UNIX)
76         set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils m)
77       else()
78         if(MINGW)
79             set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils)
80         else()
81             set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils)
82         endif()
83       endif()
84       set(HAVE_CLP TRUE)
85     endif()
86   endif()
87 endif(WITH_CLP)
88
89 # --- C= ---
90 if(WITH_CSTRIPES AND NOT HAVE_TBB)
91   include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
92 else()
93   set(HAVE_CSTRIPES 0)
94 endif()
95
96 # --- OpenMP ---
97 if(WITH_OPENMP AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
98   find_package(OpenMP)
99   if(OPENMP_FOUND)
100     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
101     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
102   endif()
103   set(HAVE_OPENMP "${OPENMP_FOUND}")
104 endif()
105
106 # --- GCD ---
107 if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP)
108   set(HAVE_GCD 1)
109 else()
110   set(HAVE_GCD 0)
111 endif()
112
113 # --- Concurrency ---
114 if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP)
115   set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concurrencytest.cpp")
116   file(WRITE "${_fname}" "#if _MSC_VER < 1600\n#error\n#endif\nint main() { return 0; }\n")
117   try_compile(HAVE_CONCURRENCY "${CMAKE_BINARY_DIR}" "${_fname}")
118   file(REMOVE "${_fname}")
119 else()
120   set(HAVE_CONCURRENCY 0)
121 endif()