mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
fix: cmake version.txt generation in non-git environments
This was not well defined.
This commit is contained in:
parent
92ee08b093
commit
67f5b1333b
|
@ -42,16 +42,19 @@ find_package(Qt6 REQUIRED COMPONENTS
|
|||
|
||||
#### Compile time files and preprocessor flags
|
||||
|
||||
# Obtain git commit hash
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short=8 HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
string(TIMESTAMP date_for_version_file) # note: this variable is cached for every run, but for user installation, this doesn't matter much
|
||||
configure_file(version.txt.in ${CMAKE_SOURCE_DIR}/version.txt)
|
||||
block() # generate version.txt
|
||||
string(TIMESTAMP build_time)
|
||||
find_package(Git)
|
||||
if (EXISTS "${CMAKE_SOURCE_DIR}/.git" AND GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} -C "${CMAKE_SOURCE_DIR}" rev-parse --short HEAD
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE GIT_HASH)
|
||||
file(WRITE "${CMAKE_SOURCE_DIR}/version.txt" "${PROJECT_VERSION}.${GIT_HASH} at ${build_time}")
|
||||
else () # not built in a git repo
|
||||
file(WRITE "${CMAKE_SOURCE_DIR}/version.txt" "${PROJECT_VERSION} at ${build_time}")
|
||||
endif ()
|
||||
endblock()
|
||||
|
||||
#### Sources Files
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ QString version()
|
|||
QString everything()
|
||||
{
|
||||
return QStringLiteral( "Goldendict-ng " ) + Version::version() + "\n" + "Qt " + QLatin1String( qVersion() ) + " "
|
||||
+ Version::compiler + QSysInfo::productType() + " " + QSysInfo::kernelType() + " " + QSysInfo::kernelVersion() + " "
|
||||
+ QSysInfo::buildAbi() + "\n" + "Flags:" + flags;
|
||||
+ Version::compiler + " " + QSysInfo::productType() + " " + QSysInfo::kernelType() + " " + QSysInfo::kernelVersion()
|
||||
+ " " + QSysInfo::buildAbi() + "\n" + "Flags:" + flags;
|
||||
}
|
||||
|
||||
} // namespace Version
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
${PROJECT_VERSION}.${GIT_HASH} on ${date_for_version_file}
|
Loading…
Reference in a new issue