config: include version and git revision

This commit is contained in:
anna 2021-09-19 16:39:05 +02:00
parent 6ac206051a
commit a34fd6caaa
Signed by: fef
GPG key ID: EC22E476DC2D3D84
3 changed files with 48 additions and 0 deletions

28
cmake/git.cmake Normal file
View file

@ -0,0 +1,28 @@
# See the end of this file for copyright and license terms.
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE gaybsd_GIT_REVISION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT "${gaybsd_GIT_REVISION}" STREQUAL "")
set(gaybsd_VERSION_SUFFIX "-${gaybsd_GIT_REVISION}")
endif()
endif()
# This file is part of GayBSD.
# Copyright (c) 2021 fef <owo@fef.moe>.
#
# GayBSD is nonviolent software: you may only use, redistribute, and/or
# modify it under the terms of the Cooperative Nonviolent Public License
# (CNPL) as found in the LICENSE file in the source code root directory
# or at <https://git.pixie.town/thufie/npl-builder>; either version 7
# of the license, or (at your option) any later version.
#
# GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
# permitted by applicable law. See the CNPL for details.