代码拉取完成,页面将自动刷新
cmake_host_system_information(RESULT HOSTNAME QUERY HOSTNAME)
string(TIMESTAMP TODAY "%Y%m%d-%H%M%S")
message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
# 获取当前分支名称
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# string(SUBSTRING ${CURRENT_BRANCH} 0 1 CURRENT_BRANCH)
# message(STATUS "git current branch=${CURRENT_BRANCH}")
# 获取 git hash
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# string(SUBSTRING ${COMMIT_HASH} 0 8 COMMIT_HASH)
# message(STATUS "git bash=${COMMIT_HASH}")
# 获取 git tag
execute_process(
COMMAND git --no-pager describe --tags --always
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# 获取 git status
execute_process(
COMMAND git status -s -uno
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if("${out}" STREQUAL "")
set(GIT_STATUS "CLEAN")
else()
set(GIT_STATUS "DIRTY")
endif()
# 获取提交次数
execute_process(
COMMAND git rev-list HEAD --count
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# string(STRIP ${COMMIT_COUNT} COMMIT_COUNT)
# message(STATUS "git commit count=${GIT_COUNT}")
else(EXISTS "${PROJECT_SOURCE_DIR}/.git")
set(GIT_BRANCH "No production")
set(GIT_COMMIT_HASH "00000000")
set(GIT_TAG "no ready version")
set(GIT_COUNT "0")
set(GIT_STATUS "NON")
endif(EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(STATUS "Git current branch: ${GIT_BRANCH}")
message(STATUS "Git commit hash: ${GIT_COMMIT_HASH}")
message(STATUS "Git current tag: ${GIT_TAG}")
message(STATUS "Git status: ${GIT_STATUS}")
message(STATUS "Git commit count: ${GIT_COMMIT_COUNT}")
message(STATUS "Generating version.h ...")
# 生成版本信息
# set(commit_info "${GIT_BRANCH}-${GIT_COMMIT_HASH}-${GIT_TAG}-${GIT_STATUS})
# message(STATUS "Version info: ${commit_info}")
configure_file(
${PROJECT_SOURCE_DIR}/version.h.in
${PROJECT_SOURCE_DIR}/version.h
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。