使用CMAKE / CPack根据版本设置RPM软件包名称

时间:2018-12-31 15:35:17

标签: c++ linux cmake rpm cpack

我想生成RPM文件,以后再使用构建机进行版本升级。

我想做的是运行cpack -R "100.0.4d"或类似的方式

返回获取rpm文件:myapp-100.0.4d.rpm

这是为了支持自动版本生成 为此,我构造了以下CMakeLists.txt

PROJECT (myapp)
SET (APPLICATION_NAME "MYAPP")
SET (APPLICATION_CODENAME "${PROJECT_NAME}")
SET (APPLICATION_COPYRIGHT_YEARS "2018")
SET (APPLICATION_VERSION_MAJOR "100")
SET (APPLICATION_VERSION_MINOR "0")
SET (APPLICATION_VERSION_PATCH "1")
SET (APPLICATION_VERSION_TYPE DS1)
SET (APPLICATION_VERSION_STRING "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}-${APPLICATION_VERSION_TYPE}")

...
#
# CPack Generic
#

SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "1")
SET(CPACK_PACKAGE_VERSION_PATCH "1")

SET(CPACK_PACKAGE_NAME "myapp")
SET(CPACK_PACKAGE_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "my app servers")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_PACKAGE_VENDOR "${APPLICATION_VENDOR_NAME}")
SET(CPACK_PACKAGE_URL "${APPLICATION_VENDOR_URL}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
SET(CPACK_SOURCE_GENERATOR "RPM")
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
SET(CPACK_RPM_COMPRESSION_TYPE "gzip")
SET(CPACK_GENERATOR "RPM")

使用cpack -R仅设置rpm软件包版本,而不更改文件名。

我尝试使用cpack -D更改CPACK_PACKAGE_VERSION_*APPLICATION_VERSION_*且保持不变。

如何实现?

0 个答案:

没有答案