mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 03:31:45 +08:00
修改服务器版本信息声明相关代码
This commit is contained in:
@@ -1,44 +1,7 @@
|
||||
include_directories(../3rdpart)
|
||||
file(GLOB jsoncpp_src_list ../3rdpart/jsoncpp/*.cpp ../3rdpart/jsoncpp/*.h )
|
||||
add_library(jsoncpp STATIC ${jsoncpp_src_list})
|
||||
|
||||
file(GLOB MediaServer_src_list ./*.cpp ./*.h)
|
||||
#message(STATUS ${MediaServer_src_list})
|
||||
|
||||
# 添加git版本信息
|
||||
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
||||
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
|
||||
set(BUILD_TIME "")
|
||||
|
||||
string(TIMESTAMP BUILD_TIME "%Y/%m/%d-%H:%M:%S")
|
||||
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
||||
OUTPUT_VARIABLE BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
|
||||
${CMAKE_BINARY_DIR}/Version.h
|
||||
@ONLY
|
||||
)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
add_definitions(-DENABLE_VERSION)
|
||||
|
||||
add_executable(MediaServer ${MediaServer_src_list})
|
||||
|
||||
|
||||
@@ -154,9 +154,9 @@ public:
|
||||
(*_parser) << Option('v', "version", Option::ArgNone, nullptr, false, "显示版本号",
|
||||
[](const std::shared_ptr<ostream> &stream, const string &arg) -> bool {
|
||||
//版本信息
|
||||
*stream << "编译日期: " << build_time << std::endl;
|
||||
*stream << "当前git分支: " << branch_name << std::endl;
|
||||
*stream << "当前git hash值: " << commit_hash << std::endl;
|
||||
*stream << "编译日期: " << BUILD_TIME << std::endl;
|
||||
*stream << "当前git分支: " << BRANCH_TIME << std::endl;
|
||||
*stream << "当前git hash值: " << COMMIT_HASH << std::endl;
|
||||
throw ExitException();
|
||||
});
|
||||
#endif
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __GIT_VERSION_H__
|
||||
#define __GIT_VERSION_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
const std::string commit_hash = "@COMMIT_HASH@";
|
||||
const std::string branch_name = "@BRANCH_NAME@";
|
||||
const std::string build_time = "@BUILD_TIME@";
|
||||
|
||||
#endif //__GIT_VERSION_H__
|
||||
|
||||
Reference in New Issue
Block a user