CMakePack.cmake 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # 声明包的名称
  2. set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
  3. # 声明包的供应商
  4. set(CPACK_PACKAGE_VENDOR "青岛数智船海科技有限公司")
  5. # 打包的源代码将包括一个描述文件。这是带有安装说明的纯文本文件
  6. set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
  7. # 添加包的描述
  8. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJCT_DESCRIPTION}")
  9. # 许可证文件
  10. set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
  11. # site
  12. set(CPACK_SITE "${PROJECT_HOMEPAGE_URL}")
  13. # 从发布包中安装时,文件将放在/opt/${PROJECT_NAME}目录下
  14. #[[if(SYS_WIN)
  15. set(CPACK_PACKAGING_INSTALL_PREFIX "C:\\Program Files\\${PROJECT_NAME}")
  16. else()
  17. set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
  18. endif()]]
  19. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
  20. # CPack所需的主要、次要和补丁版本:
  21. set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
  22. set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
  23. set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
  24. # 设置了在包装的时候需要忽略的文件列表和目录
  25. set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/install/;/.git/;/.vscode/;.gitignore")
  26. # 列出了源代码归档的打包生成器
  27. set(CPACK_SOURCE_GENERATOR "ZIP;TGZ")
  28. # 二进制存档生成器
  29. set(CPACK_GENERATOR "ZIP;TGZ")
  30. # 声明平台原生二进制安装程序,从DEB和RPM包生成器开始,不过只适用于GNU/Linux
  31. if(UNIX)
  32. if(CMAKE_SYSTEM_NAME MATCHES Linux)
  33. find_program(_deb dpkg-deb)
  34. string(FIND ${_deb} "dpkg-deb" _result)
  35. if(NOT _result STREQUAL "-1")
  36. list(APPEND CPACK_GENERATOR "DEB")
  37. set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
  38. set(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION})
  39. set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR})
  40. set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_SITE})
  41. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  42. set(CPACK_DEBIAN_PACKAGE_RELEASE "1")
  43. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libfontconfig-dev")
  44. endif()
  45. find_program(_rpm rpmbuild)
  46. string(FIND ${_rpm} "rpmbuild" _result)
  47. if(NOT _result STREQUAL "-1")
  48. list(APPEND CPACK_GENERATOR "RPM")
  49. set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  50. set(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
  51. set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION})
  52. set(CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR})
  53. set(CPACK_RPM_PACKAGE_URL ${CPACK_SITE})
  54. set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  55. set(CPACK_RPM_PACKAGE_RELEASE "1")
  56. set(CPACK_RPM_PACKAGE_LICENSE "BSD 3-Clause")
  57. set(CPACK_RPM_PACKAGE_REQUIRES "fontconfig-devel")
  58. set(CPACK_RPM_PACKAGE_AUTOREQ NO)
  59. endif()
  60. endif()
  61. endif()
  62. # 在windows上生成一个NSIS安装程序
  63. # NSIS相关的变量https://cmake.org/cmake/help/latest/cpack_gen/nsis.html#cpack_gen:CPack%20NSIS%20Generator
  64. if(WIN32 OR MINGW)
  65. if (NSIS_EXECUTABLE)
  66. list(APPEND CPACK_GENERATOR "NSIS")
  67. #set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME}")
  68. #set(CPACK_NSIS_INSTALL_ROOT "C:\\Program Files")
  69. set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/src/qrc/QUI/main.ico")
  70. set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/src/qrc/QUI/uninstall.ico")
  71. #set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/src/qrc/QUI/WELCOMEFINISHPAGE.bmp")
  72. #set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/src/qrc/QUI/UNWELCOMEFINISHPAGE.bmp")
  73. #set(CPACK_NSIS_MUI_HEADERIMAGE "${CMAKE_SOURCE_DIR}/src/qrc/QUI/HEADERIMAGE.bmp")
  74. set(CPACK_NSIS_MODIFY_PATH ON)
  75. set(CPACK_NSIS_MUI_FINISHPAGE_RUN ON)
  76. set(CPACK_NSIS_HELP_LINK "http://www.fastcae.com/index.php?mod=document")
  77. set(CPACK_NSIS_URL_INFO_ABOUT "http://www.fastcae.com/index.php?mod=product")
  78. set(CPACK_NSIS_MENU_LINKS "http://www.fastcae.com/" "FastCAE网站")
  79. set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
  80. elseif(WIX_EXECUTABLE)
  81. list(APPEND CPACK_GENERATOR "WIX")
  82. set(CPACK_WIX_PROPERTY_ARPCOMMENTS ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  83. set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "http://www.fastcae.com/index.php?mod=product")
  84. set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.fastcae.com/")
  85. endif ()
  86. endif()
  87. # 向用户打印一条信息
  88. message(STATUS "CPack generators: ${CPACK_GENERATOR}")