OpenCVFindLibsPerf.cmake 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # ----------------------------------------------------------------------------
  2. # Detect other 3rd-party performance and math libraries
  3. # ----------------------------------------------------------------------------
  4. # --- TBB ---
  5. if(WITH_TBB)
  6. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
  7. endif(WITH_TBB)
  8. # --- IPP ---
  9. if(WITH_IPP)
  10. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPP.cmake")
  11. if(HAVE_IPP)
  12. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPIW.cmake")
  13. if(HAVE_IPP_IW)
  14. ocv_include_directories(${IPP_IW_INCLUDES})
  15. list(APPEND OPENCV_LINKER_LIBS ${IPP_IW_LIBRARIES})
  16. endif()
  17. ocv_include_directories(${IPP_INCLUDE_DIRS})
  18. list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
  19. # Details: #10229
  20. if(ANDROID AND NOT OPENCV_SKIP_ANDROID_IPP_FIX_1)
  21. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a ${CMAKE_SHARED_LINKER_FLAGS}")
  22. elseif(ANDROID AND NOT OPENCV_SKIP_ANDROID_IPP_FIX_2)
  23. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic ${CMAKE_SHARED_LINKER_FLAGS}")
  24. endif()
  25. if(OPENCV_FORCE_IPP_EXCLUDE_LIBS
  26. OR (HAVE_IPP_ICV
  27. AND UNIX AND NOT ANDROID AND NOT APPLE
  28. AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Intel"
  29. )
  30. AND NOT OPENCV_SKIP_IPP_EXCLUDE_LIBS
  31. )
  32. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a ${CMAKE_SHARED_LINKER_FLAGS}")
  33. endif()
  34. endif()
  35. endif()
  36. # --- CUDA ---
  37. if(WITH_CUDA)
  38. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake")
  39. if(NOT HAVE_CUDA)
  40. message(WARNING "OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA).
  41. CUDA support will be disabled in OpenCV build.
  42. To eliminate this warning remove WITH_CUDA=ON CMake configuration option.
  43. ")
  44. endif()
  45. endif(WITH_CUDA)
  46. # --- Eigen ---
  47. if(WITH_EIGEN AND NOT HAVE_EIGEN)
  48. if((OPENCV_FORCE_EIGEN_FIND_PACKAGE_CONFIG
  49. OR NOT (CMAKE_VERSION VERSION_LESS "3.0.0") # Eigen3Targets.cmake required CMake 3.0.0+
  50. ) AND NOT OPENCV_SKIP_EIGEN_FIND_PACKAGE_CONFIG
  51. )
  52. find_package(Eigen3 CONFIG QUIET) # Ceres 2.0.0 CMake scripts doesn't work with CMake's FindEigen3.cmake module (due to missing EIGEN3_VERSION_STRING)
  53. endif()
  54. if(NOT Eigen3_FOUND)
  55. find_package(Eigen3 QUIET)
  56. endif()
  57. if(Eigen3_FOUND)
  58. if(TARGET Eigen3::Eigen)
  59. # Use Eigen3 imported target if possible
  60. list(APPEND OPENCV_LINKER_LIBS Eigen3::Eigen)
  61. set(HAVE_EIGEN 1)
  62. else()
  63. if(DEFINED EIGEN3_INCLUDE_DIRS)
  64. set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIRS})
  65. set(HAVE_EIGEN 1)
  66. elseif(DEFINED EIGEN3_INCLUDE_DIR)
  67. set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIR})
  68. set(HAVE_EIGEN 1)
  69. endif()
  70. endif()
  71. if(HAVE_EIGEN)
  72. if(DEFINED EIGEN3_WORLD_VERSION) # CMake module
  73. set(EIGEN_WORLD_VERSION ${EIGEN3_WORLD_VERSION})
  74. set(EIGEN_MAJOR_VERSION ${EIGEN3_MAJOR_VERSION})
  75. set(EIGEN_MINOR_VERSION ${EIGEN3_MINOR_VERSION})
  76. else() # Eigen config file
  77. set(EIGEN_WORLD_VERSION ${EIGEN3_VERSION_MAJOR})
  78. set(EIGEN_MAJOR_VERSION ${EIGEN3_VERSION_MINOR})
  79. set(EIGEN_MINOR_VERSION ${EIGEN3_VERSION_PATCH})
  80. endif()
  81. endif()
  82. endif()
  83. if(NOT HAVE_EIGEN)
  84. if(NOT EIGEN_INCLUDE_PATH OR NOT EXISTS "${EIGEN_INCLUDE_PATH}")
  85. set(__find_paths "")
  86. set(__find_path_extra_options "")
  87. if(NOT CMAKE_CROSSCOMPILING)
  88. list(APPEND __find_paths /opt)
  89. endif()
  90. if(DEFINED ENV{EIGEN_ROOT})
  91. set(__find_paths "$ENV{EIGEN_ROOT}/include")
  92. list(APPEND __find_path_extra_options NO_DEFAULT_PATH)
  93. else()
  94. set(__find_paths ENV ProgramFiles ENV ProgramW6432)
  95. endif()
  96. find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
  97. PATHS ${__find_paths}
  98. PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2
  99. DOC "The path to Eigen3/Eigen2 headers"
  100. ${__find_path_extra_options}
  101. )
  102. endif()
  103. if(EIGEN_INCLUDE_PATH AND EXISTS "${EIGEN_INCLUDE_PATH}")
  104. ocv_parse_header("${EIGEN_INCLUDE_PATH}/Eigen/src/Core/util/Macros.h" EIGEN_VERSION_LINES EIGEN_WORLD_VERSION EIGEN_MAJOR_VERSION EIGEN_MINOR_VERSION)
  105. set(HAVE_EIGEN 1)
  106. endif()
  107. endif()
  108. endif()
  109. if(HAVE_EIGEN)
  110. if(EIGEN_INCLUDE_PATH AND EXISTS "${EIGEN_INCLUDE_PATH}")
  111. ocv_include_directories(SYSTEM ${EIGEN_INCLUDE_PATH})
  112. endif()
  113. endif()
  114. # --- Clp ---
  115. # Ubuntu: sudo apt-get install coinor-libclp-dev coinor-libcoinutils-dev
  116. ocv_clear_vars(HAVE_CLP)
  117. if(WITH_CLP)
  118. if(UNIX)
  119. ocv_check_modules(CLP clp)
  120. if(CLP_FOUND)
  121. set(HAVE_CLP TRUE)
  122. if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "")
  123. ocv_include_directories(${CLP_INCLUDE_DIRS})
  124. endif()
  125. list(APPEND OPENCV_LINKER_LIBS ${CLP_LIBRARIES})
  126. endif()
  127. endif()
  128. if(NOT CLP_FOUND)
  129. find_path(CLP_INCLUDE_PATH "coin"
  130. PATHS "/usr/local/include" "/usr/include" "/opt/include"
  131. DOC "The path to Clp headers")
  132. if(CLP_INCLUDE_PATH)
  133. ocv_include_directories(${CLP_INCLUDE_PATH} "${CLP_INCLUDE_PATH}/coin")
  134. get_filename_component(_CLP_LIBRARY_DIR "${CLP_INCLUDE_PATH}/../lib" ABSOLUTE)
  135. set(CLP_LIBRARY_DIR "${_CLP_LIBRARY_DIR}" CACHE PATH "Full path of Clp library directory")
  136. link_directories(${CLP_LIBRARY_DIR})
  137. if(UNIX)
  138. set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils m)
  139. else()
  140. if(MINGW)
  141. set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} Clp CoinUtils)
  142. else()
  143. set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils)
  144. endif()
  145. endif()
  146. set(HAVE_CLP TRUE)
  147. endif()
  148. endif()
  149. endif(WITH_CLP)