OpenCVPackaging.cmake 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ocv_cmake_hook(INIT_CPACK)
  2. if(NOT EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  3. message(STATUS "CPack is not found. SKIP")
  4. return()
  5. endif()
  6. set(CPACK_set_DESTDIR "on")
  7. if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
  8. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Computer Vision Library")
  9. set(CPACK_PACKAGE_DESCRIPTION
  10. "OpenCV (Open Source Computer Vision Library) is an open source computer vision
  11. and machine learning software library. OpenCV was built to provide a common
  12. infrastructure for computer vision applications and to accelerate the use of
  13. machine perception in the commercial products. Being a BSD-licensed product,
  14. OpenCV makes it easy for businesses to utilize and modify the code.")
  15. set(CPACK_PACKAGE_VENDOR "OpenCV Foundation")
  16. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
  17. set(CPACK_PACKAGE_CONTACT "admin@opencv.org")
  18. set(CPACK_PACKAGE_VERSION_MAJOR "${OPENCV_VERSION_MAJOR}")
  19. set(CPACK_PACKAGE_VERSION_MINOR "${OPENCV_VERSION_MINOR}")
  20. set(CPACK_PACKAGE_VERSION_PATCH "${OPENCV_VERSION_PATCH}")
  21. set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
  22. endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
  23. #arch
  24. if(X86)
  25. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
  26. set(CPACK_RPM_PACKAGE_ARCHITECTURE "i686")
  27. elseif(X86_64)
  28. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
  29. set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
  30. elseif(ARM)
  31. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
  32. set(CPACK_RPM_PACKAGE_ARCHITECTURE "armhf")
  33. elseif(AARCH64)
  34. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
  35. set(CPACK_RPM_PACKAGE_ARCHITECTURE "aarch64")
  36. elseif(PPC64LE)
  37. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "ppc64el")
  38. set(CPACK_RPM_PACKAGE_ARCHITECTURE "ppc64le")
  39. else()
  40. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
  41. set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
  42. endif()
  43. if(CPACK_GENERATOR STREQUAL "DEB")
  44. set(OPENCV_PACKAGE_ARCH_SUFFIX ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
  45. elseif(CPACK_GENERATOR STREQUAL "RPM")
  46. set(OPENCV_PACKAGE_ARCH_SUFFIX ${CPACK_RPM_PACKAGE_ARCHITECTURE})
  47. else()
  48. set(OPENCV_PACKAGE_ARCH_SUFFIX ${CMAKE_SYSTEM_PROCESSOR})
  49. endif()
  50. set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VCSVERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
  51. set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VCSVERSION}-${OPENCV_PACKAGE_ARCH_SUFFIX}")
  52. #rpm options
  53. set(CPACK_RPM_COMPONENT_INSTALL TRUE)
  54. set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  55. set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
  56. set(CPACK_RPM_PACKAGE_URL "http://opencv.org")
  57. set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
  58. #deb options
  59. set(CPACK_DEB_COMPONENT_INSTALL TRUE)
  60. set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
  61. set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
  62. set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencv.org")
  63. #display names
  64. set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files")
  65. set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documentation")
  66. set(CPACK_COMPONENT_JAVA_DISPLAY_NAME "Java bindings")
  67. set(CPACK_COMPONENT_LIBS_DISPLAY_NAME "Libraries and data")
  68. set(CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python bindings")
  69. set(CPACK_COMPONENT_SAMPLES_DISPLAY_NAME "Samples")
  70. set(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Tests")
  71. #depencencies
  72. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
  73. set(CPACK_COMPONENT_LIBS_REQUIRED TRUE)
  74. set(CPACK_COMPONENT_SAMPLES_DEPENDS libs)
  75. set(CPACK_COMPONENT_DEV_DEPENDS libs)
  76. set(CPACK_COMPONENT_DOCS_DEPENDS libs)
  77. set(CPACK_COMPONENT_JAVA_DEPENDS libs)
  78. set(CPACK_COMPONENT_PYTHON_DEPENDS libs)
  79. set(CPACK_COMPONENT_TESTS_DEPENDS libs)
  80. if(HAVE_CUDA)
  81. string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION})
  82. if(CUDA_VERSION VERSION_LESS "6.5")
  83. set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
  84. set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
  85. else()
  86. set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-cudart-${cuda_version_suffix}, cuda-npp-${cuda_version_suffix}")
  87. set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-cudart-dev-${cuda_version_suffix}, cuda-npp-dev-${cuda_version_suffix}")
  88. if(HAVE_CUFFT)
  89. set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cufft-${cuda_version_suffix}")
  90. set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cufft-dev-${cuda_version_suffix}")
  91. endif()
  92. if(HAVE_CUBLAS)
  93. set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cublas-${cuda_version_suffix}")
  94. set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cublas-dev-${cuda_version_suffix}")
  95. endif()
  96. if(HAVE_CUDNN)
  97. # TODO
  98. #ex: libcudnn7_7.5.1.10-1+cuda10.1_amd64
  99. #ex: libcudnn7-dev_7.5.1.10-1+cuda10.1_amd64
  100. endif()
  101. endif()
  102. set(CPACK_COMPONENT_dev_DEPENDS libs)
  103. endif()
  104. if(HAVE_TBB AND NOT BUILD_TBB)
  105. if(CPACK_DEB_DEV_PACKAGE_DEPENDS)
  106. set(CPACK_DEB_DEV_PACKAGE_DEPENDS "${CPACK_DEB_DEV_PACKAGE_DEPENDS}, libtbb-dev")
  107. else()
  108. set(CPACK_DEB_DEV_PACKAGE_DEPENDS "libtbb-dev")
  109. endif()
  110. endif()
  111. set(STD_OPENCV_LIBS opencv-data)
  112. set(STD_OPENCV_DEV libopencv-dev)
  113. foreach(module calib3d core dnn features2d flann gapi highgui
  114. imgcodecs imgproc ml objdetect
  115. photo stitching ts video videoio)
  116. if(HAVE_opencv_${module})
  117. list(APPEND STD_OPENCV_LIBS "libopencv-${module}4.0")
  118. list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev")
  119. endif()
  120. endforeach()
  121. string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}")
  122. string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_PROVIDES "${STD_OPENCV_LIBS}")
  123. string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_REPLACES "${STD_OPENCV_LIBS}")
  124. string(REPLACE ";" ", " CPACK_COMPONENT_DEV_CONFLICTS "${STD_OPENCV_DEV}")
  125. string(REPLACE ";" ", " CPACK_COMPONENT_DEV_PROVIDES "${STD_OPENCV_DEV}")
  126. string(REPLACE ";" ", " CPACK_COMPONENT_DEV_REPLACES "${STD_OPENCV_DEV}")
  127. set(CPACK_COMPONENT_PYTHON_CONFLICTS python-opencv)
  128. set(CPACK_COMPONENT_PYTHON_PROVIDES python-opencv)
  129. set(CPACK_COMPONENT_PYTHON_REPLACES python-opencv)
  130. set(CPACK_COMPONENT_JAVA_CONFLICTS "libopencv4.0-java, libopencv4.0-jni")
  131. set(CPACK_COMPONENT_JAVA_PROVIDES "libopencv4.0-java, libopencv4.0-jni")
  132. set(CPACK_COMPONENT_JAVA_REPLACES "libopencv4.0-java, libopencv4.0-jni")
  133. set(CPACK_COMPONENT_DOCS_CONFLICTS opencv-doc)
  134. set(CPACK_COMPONENT_SAMPLES_CONFLICTS opencv-doc)
  135. if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
  136. set(CPACK_COMPONENT_LIBS_DESCRIPTION "Open Computer Vision Library")
  137. set(CPACK_DEBIAN_COMPONENT_LIBS_NAME "lib${CMAKE_PROJECT_NAME}")
  138. set(CPACK_COMPONENT_PYTHON_DESCRIPTION "Python bindings for Open Source Computer Vision Library")
  139. set(CPACK_DEBIAN_COMPONENT_PYTHON_NAME "lib${CMAKE_PROJECT_NAME}-python")
  140. set(CPACK_COMPONENT_JAVA_DESCRIPTION "Java bindings for Open Source Computer Vision Library")
  141. set(CPACK_DEBIAN_COMPONENT_JAVA_NAME "lib${CMAKE_PROJECT_NAME}-java")
  142. set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for Open Source Computer Vision Library")
  143. set(CPACK_DEBIAN_COMPONENT_DEV_NAME "lib${CMAKE_PROJECT_NAME}-dev")
  144. set(CPACK_COMPONENT_DOCS_DESCRIPTION "Documentation for Open Source Computer Vision Library")
  145. set(CPACK_DEBIAN_COMPONENT_DOCS_NAME "lib${CMAKE_PROJECT_NAME}-docs")
  146. set(CPACK_COMPONENT_SAMPLES_DESCRIPTION "Samples for Open Source Computer Vision Library")
  147. set(CPACK_DEBIAN_COMPONENT_SAMPLES_NAME "lib${CMAKE_PROJECT_NAME}-samples")
  148. set(CPACK_COMPONENT_TESTS_DESCRIPTION "Accuracy and performance tests for Open Source Computer Vision Library")
  149. set(CPACK_DEBIAN_COMPONENT_TESTS_NAME "lib${CMAKE_PROJECT_NAME}-tests")
  150. endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
  151. ocv_cmake_hook(PRE_CPACK)
  152. include(CPack)
  153. ocv_cmake_hook(POST_CPACK)