Adding git commit number to package name:
CMakeLists.txt
SET(FAST_SMTP_VERSION "1.2.6")
EXEC_PROGRAM("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe" OUTPUT_VARIABLE GIT_DESCRIBE_VERSION)
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\1" VERSION_MAJOR ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\2" VERSION_MINOR ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\3" VERSION_PATCH ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\4" VERSION_COMMIT ${GIT_DESCRIBE_VERSION} )
...
SET(CPACK_PACKAGE_VERSION "${FAST_SMTP_VERSION}+git${VERSION_COMMIT}")
And viola!
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: fast_smtp
CPack: - Install project: fast_smtp
CPack: Create package
CPack: - package: /tmp/d1ac5d/fastsmtp-1.2.6+git17-x86_64.deb generated.
CMakeLists.txt
SET(FAST_SMTP_VERSION "1.2.6")
EXEC_PROGRAM("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe" OUTPUT_VARIABLE GIT_DESCRIBE_VERSION)
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\1" VERSION_MAJOR ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\2" VERSION_MINOR ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\3" VERSION_PATCH ${GIT_DESCRIBE_VERSION} )
STRING( REGEX REPLACE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-([0-9]+)-.*" "\\4" VERSION_COMMIT ${GIT_DESCRIBE_VERSION} )
...
SET(CPACK_PACKAGE_VERSION "${FAST_SMTP_VERSION}+git${VERSION_COMMIT}")
And viola!
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: fast_smtp
CPack: - Install project: fast_smtp
CPack: Create package
CPack: - package: /tmp/d1ac5d/fastsmtp-1.2.6+git17-x86_64.deb generated.
No comments:
Post a Comment