packages.cmake 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. # cmake file for generating distribution packages
  2. # Default packages to build
  3. IF (APPLE)
  4. SET ( CPACK_GENERATOR "DragNDrop")
  5. SET ( CPACK_DMG_FORMAT "UDBZ" )
  6. ELSEIF (UNIX)
  7. SET ( CPACK_GENERATOR "TGZ")
  8. ELSEIF (WIN32)
  9. SET ( CPACK_GENERATOR "ZIP" "NSIS")
  10. ENDIF()
  11. # Determine packages by found generator executables
  12. find_package(RpmBuilder)
  13. IF(RPM_BUILDER_FOUND)
  14. message(STATUS "CPACK: Found RPM builder")
  15. SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "RPM")
  16. ENDIF()
  17. find_package(DebBuilder)
  18. IF(DEB_BUILDER_FOUND)
  19. message(STATUS "CPACK: Found DEB builder")
  20. SET ( CPACK_GENERATOR ${CPACK_GENERATOR} "DEB")
  21. ENDIF()
  22. # Overwrite CMAKE_SYSTEM_NAME for mac (visual)
  23. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  24. if(${CMAKE_HOST_APPLE})
  25. set(CMAKE_SYSTEM_NAME "macOS")
  26. endif()
  27. endif()
  28. # Overwrite CMAKE_SYSTEM_PROCESSOR for Windows (visual)
  29. if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
  30. if(${CMAKE_HOST_WIN32})
  31. set(CMAKE_SYSTEM_PROCESSOR "x64")
  32. endif()
  33. endif()
  34. # Apply to all packages, some of these can be overwritten with generator specific content
  35. # https://cmake.org/cmake/help/v3.5/module/CPack.html
  36. SET ( CPACK_PACKAGE_NAME "Hyperion" )
  37. SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient light implementation" )
  38. SET ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" )
  39. # Replease "+", as cmake/rpm has an issue if "+" occurs in CPACK_PACKAGE_VERSION
  40. string(REPLACE "+" "." HYPERION_PACKAGE_VERSION ${HYPERION_VERSION})
  41. SET ( CPACK_PACKAGE_FILE_NAME "Hyperion-${HYPERION_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
  42. SET ( CPACK_PACKAGE_CONTACT "packages@hyperion-project.org")
  43. SET ( CPACK_PACKAGE_VENDOR "hyperion-project")
  44. SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" )
  45. SET ( CPACK_PACKAGE_INSTALL_DIRECTORY "Hyperion" )
  46. SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-icon-32px.png" )
  47. SET ( CPACK_PACKAGE_VERSION_MAJOR "${HYPERION_VERSION_MAJOR}")
  48. SET ( CPACK_PACKAGE_VERSION_MINOR "${HYPERION_VERSION_MINOR}")
  49. SET ( CPACK_PACKAGE_VERSION_PATCH "${HYPERION_VERSION_PATCH}")
  50. SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" )
  51. SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" )
  52. SET ( CPACK_CREATE_DESKTOP_LINKS "hyperiond;Hyperion" )
  53. # Append pre-release version to CPACK_PACKAGE_VERSION_PATCH if exists
  54. if (NOT "${HYPERION_VERSION_PRE}" STREQUAL "")
  55. string(APPEND CPACK_PACKAGE_VERSION_PATCH ${HYPERION_VERSION_PRE})
  56. endif()
  57. # Specific CPack Package Generators
  58. # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators
  59. # .deb files for apt
  60. # https://cmake.org/cmake/help/latest/cpack_gen/deb.html
  61. SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
  62. SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4 | libcec (>= 4.0)" )
  63. SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" )
  64. # .rpm for rpm
  65. # https://cmake.org/cmake/help/latest/cpack_gen/rpm.html
  66. SET ( CPACK_RPM_PACKAGE_RELEASE 1 )
  67. SET ( CPACK_RPM_PACKAGE_LICENSE "MIT" )
  68. SET ( CPACK_RPM_PACKAGE_GROUP "Applications" )
  69. SET ( CPACK_RPM_PACKAGE_REQUIRES "libcec >= 4.0.0" )
  70. SET ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst" )
  71. SET ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst" )
  72. SET ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
  73. # .dmg for Apple macOS
  74. # https://cmake.org/cmake/help/latest/cpack_gen/dmg.html
  75. IF (APPLE)
  76. SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/osxbundle/PackageIcon.icns" )
  77. SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE" )
  78. SET ( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/cmake/osxbundle/Background.png" )
  79. SET ( CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/osxbundle/AppleScript.scpt" )
  80. ENDIF(APPLE)
  81. # Windows NSIS
  82. # Use custom script based on cpack nsis template
  83. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/nsis/template ${CMAKE_MODULE_PATH})
  84. # Some path transformations
  85. if(WIN32)
  86. file(TO_NATIVE_PATH ${CPACK_PACKAGE_ICON} CPACK_PACKAGE_ICON)
  87. STRING(REGEX REPLACE "\\\\" "\\\\\\\\" CPACK_PACKAGE_ICON ${CPACK_PACKAGE_ICON})
  88. endif()
  89. file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico" NSIS_HYP_ICO)
  90. file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/header.bmp" NSIS_HYP_LOGO_HORI)
  91. file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/cmake/nsis/logo.bmp" NSIS_HYP_LOGO_VERT)
  92. STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_ICO "${NSIS_HYP_ICO}")
  93. STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_VERT "${NSIS_HYP_LOGO_VERT}")
  94. STRING(REGEX REPLACE "\\\\" "\\\\\\\\" NSIS_HYP_LOGO_HORI "${NSIS_HYP_LOGO_HORI}")
  95. SET ( CPACK_NSIS_MODIFY_PATH ON )
  96. SET ( CPACK_NSIS_MUI_ICON ${NSIS_HYP_ICO})
  97. SET ( CPACK_NSIS_MUI_UNIICON ${NSIS_HYP_ICO})
  98. SET ( CPACK_NSIS_MUI_HEADERIMAGE ${NSIS_HYP_LOGO_HORI} )
  99. SET ( CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${NSIS_HYP_LOGO_VERT})
  100. SET ( CPACK_NSIS_DISPLAY_NAME "Hyperion Ambient Light")
  101. SET ( CPACK_NSIS_PACKAGE_NAME "Hyperion" )
  102. SET ( CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\hyperiond.exe")
  103. SET ( CPACK_NSIS_HELP_LINK "https://www.hyperion-project.org")
  104. SET ( CPACK_NSIS_URL_INFO_ABOUT "https://www.hyperion-project.org")
  105. SET ( CPACK_NSIS_MUI_FINISHPAGE_RUN "hyperiond.exe")
  106. SET ( CPACK_NSIS_BRANDING_TEXT "Hyperion-${HYPERION_VERSION}")
  107. # custom nsis plugin directory
  108. SET ( CPACK_NSIS_EXTRA_DEFS "!addplugindir ${CMAKE_SOURCE_DIR}/cmake/nsis/plugins")
  109. # additional hyperiond startmenu link, won't be created if the user disables startmenu links
  110. SET ( CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Hyperion (Console).lnk' '$INSTDIR\\\\bin\\\\hyperiond.exe' '-d -c'")
  111. SET ( CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Hyperion (Console).lnk'")
  112. # Define the install components
  113. # See also https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Component-Install-With-CPack
  114. # and https://cmake.org/cmake/help/latest/module/CPackComponent.html
  115. SET ( CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE")
  116. # Components base (All builds)
  117. SET ( CPACK_COMPONENTS_ALL "Hyperion" )
  118. # Optional compiled
  119. if(ENABLE_REMOTE_CTL)
  120. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_remote" )
  121. endif()
  122. # only include standalone grabber with build was with flatbuffer client
  123. if(ENABLE_FLATBUF_CONNECT)
  124. if(ENABLE_QT)
  125. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_qt" )
  126. endif()
  127. if(ENABLE_AMLOGIC)
  128. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_aml" )
  129. endif()
  130. if(ENABLE_V4L2)
  131. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_v4l2" )
  132. endif()
  133. if(ENABLE_AUDIO)
  134. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_audio" )
  135. endif()
  136. if(ENABLE_X11)
  137. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_x11" )
  138. endif()
  139. if(ENABLE_XCB)
  140. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_xcb" )
  141. endif()
  142. if(ENABLE_DISPMANX)
  143. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_dispmanx" )
  144. endif()
  145. if(ENABLE_FB)
  146. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_framebuffer" )
  147. endif()
  148. if(ENABLE_OSX)
  149. SET ( CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} "hyperion_osx" )
  150. endif()
  151. endif(ENABLE_FLATBUF_CONNECT)
  152. # Only include Hyperion to macOS dmg package (without standalone programs)
  153. IF ( CPACK_GENERATOR MATCHES "DragNDrop" )
  154. LIST ( REMOVE_ITEM CPACK_COMPONENTS_ALL "hyperion_remote" "hyperion_qt" "hyperion_osx" )
  155. ENDIF()
  156. SET ( CPACK_ARCHIVE_COMPONENT_INSTALL ON )
  157. SET ( CPACK_DEB_COMPONENT_INSTALL ON )
  158. SET ( CPACK_RPM_COMPONENT_INSTALL ON )
  159. SET ( CPACK_STRIP_FILES ON )
  160. # no code after following line!
  161. INCLUDE ( CPack )
  162. cpack_add_install_type(Full DISPLAY_NAME "Full")
  163. cpack_add_install_type(Min DISPLAY_NAME "Minimal")
  164. cpack_add_component_group(Runtime EXPANDED DESCRIPTION "Hyperion runtime")
  165. # Components base
  166. cpack_add_component(Hyperion
  167. DISPLAY_NAME "Hyperion"
  168. DESCRIPTION "Hyperion runtime"
  169. INSTALL_TYPES Full Min
  170. GROUP Runtime
  171. REQUIRED
  172. )
  173. # optional components
  174. if(ENABLE_REMOTE_CTL)
  175. cpack_add_component_group(Remote DESCRIPTION "hyperion-remote commandline tool")
  176. cpack_add_component(hyperion_remote
  177. DISPLAY_NAME "Hyperion Remote"
  178. DESCRIPTION "Hyperion remote cli tool"
  179. INSTALL_TYPES Full
  180. GROUP Remote
  181. DEPENDS Hyperion
  182. )
  183. endif()
  184. # only include standalone grabber with build was with flatbuffer client
  185. if(ENABLE_FLATBUF_CONNECT)
  186. cpack_add_component_group(Screencapture EXPANDED DESCRIPTION "Standalone Screencapture commandline programs")
  187. if(ENABLE_QT)
  188. cpack_add_component(hyperion_qt
  189. DISPLAY_NAME "Qt Standalone Screencap"
  190. DESCRIPTION "Qt based standalone screen capture"
  191. INSTALL_TYPES Full
  192. GROUP Screencapture
  193. DEPENDS Hyperion
  194. )
  195. endif()
  196. if(ENABLE_AMLOGIC)
  197. cpack_add_component(hyperion_aml
  198. DISPLAY_NAME "Amlogic Standalone Screencap"
  199. DESCRIPTION "Amlogic based standalone screen capture"
  200. INSTALL_TYPES Full
  201. GROUP Screencapture
  202. DEPENDS Hyperion
  203. )
  204. endif()
  205. if(ENABLE_V4L2)
  206. cpack_add_component(hyperion_v4l2
  207. DISPLAY_NAME "V4l2 Standalone Screencap"
  208. DESCRIPTION "Video for Linux 2 based standalone screen capture"
  209. INSTALL_TYPES Full
  210. GROUP Screencapture
  211. DEPENDS Hyperion
  212. )
  213. endif()
  214. if(ENABLE_X11)
  215. cpack_add_component(hyperion_x11
  216. DISPLAY_NAME "X11 Standalone Screencap"
  217. DESCRIPTION "X11 based standalone screen capture"
  218. INSTALL_TYPES Full
  219. GROUP Screencapture
  220. DEPENDS Hyperion
  221. )
  222. endif()
  223. if(ENABLE_XCB)
  224. cpack_add_component(hyperion_xcb
  225. DISPLAY_NAME "XCB Standalone Screencap"
  226. DESCRIPTION "XCB based standalone screen capture"
  227. INSTALL_TYPES Full
  228. GROUP Screencapture
  229. DEPENDS Hyperion
  230. )
  231. endif()
  232. if(ENABLE_DISPMANX)
  233. cpack_add_component(hyperion_dispmanx
  234. DISPLAY_NAME "RPi dispmanx Standalone Screencap"
  235. DESCRIPTION "Raspbery Pi dispmanx based standalone screen capture"
  236. INSTALL_TYPES Full
  237. GROUP Screencapture
  238. DEPENDS Hyperion
  239. )
  240. endif()
  241. if(ENABLE_FB)
  242. cpack_add_component(hyperion_framebuffer
  243. DISPLAY_NAME "Framebuffer Standalone Screencap"
  244. DESCRIPTION "Framebuffer based standalone screen capture"
  245. INSTALL_TYPES Full
  246. GROUP Screencapture
  247. DEPENDS Hyperion
  248. )
  249. endif()
  250. if(ENABLE_OSX)
  251. cpack_add_component(hyperion_osx
  252. DISPLAY_NAME "Mac osx Standalone Screencap"
  253. DESCRIPTION "Mac osx based standalone screen capture"
  254. INSTALL_TYPES Full
  255. GROUP Screencapture
  256. DEPENDS Hyperion
  257. )
  258. endif()
  259. endif(ENABLE_FLATBUF_CONNECT)