//set(CPACK_GENERATOR "TGZ")
7Z(.7z)
7Zzip(.7z)
TBZ2(tar.bz2)
TGZ(.tar.gz)
TXZ(.tar.xz)
TZ(.tar.Z)
ZIP(.zip)
vInstallCpack.cmake 文件内容如下:
###install
install(FILES [FileName] DESTINATION [InstallFoldName])
install(TARGETS [ExeName] [LibName]
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
###cpack
string(TIMESTAMP vTimeStamp "%Y%m%d%H%M%S")
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE vGitCommit
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE vGitBranch
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${vTimeStamp}-${vGitBranch}-${vGitCommit}")
include(CPack)
在CMakeLists.txt 文件中添加:
include(${CMAKE_CURRENT_SOURCE_DIR}/vInstallCpack.cmake)
在run.sh 文件中添加:
make package