CMake: Check Git commit SHA1

This is for PandaSystem::get_git_commit()
This commit is contained in:
Sam Edwards 2018-05-25 13:33:47 -06:00
parent 2d5d1400be
commit 399f4a33a1
2 changed files with 14 additions and 0 deletions

View File

@ -73,6 +73,16 @@ set(PANDA_VERSION_SYMBOL panda_version_${PROJECT_VERSION_MAJOR}_${PROJECT_VERSIO
# for each component.
math(EXPR PANDA_NUMERIC_VERSION "${PROJECT_VERSION_MAJOR}*1000000 + ${PROJECT_VERSION_MINOR}*1000 + ${PROJECT_VERSION_PATCH}")
# The Panda Git SHA1 refspec, for PandaSystem::get_git_commit()
find_package(Git QUIET)
if(GIT_EXECUTABLE)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE PANDA_GIT_COMMIT_STR
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Separate the plugin version into its three components.
string(REPLACE "." ";" P3D_PLUGIN_VERSION_LIST "${P3D_PLUGIN_VERSION}")
list(GET P3D_PLUGIN_VERSION_LIST 0 P3D_PLUGIN_MAJOR_VERSION)

View File

@ -49,6 +49,10 @@
out from CVS by the builder). */
#define PANDA_VERSION_STR "@PANDA_VERSION_STR@"
/* This is the Git commit we built Panda from, or an empty string if this isn't
known. */
#define PANDA_GIT_COMMIT_STR "@PANDA_GIT_COMMIT_STR@"
/* This is the version of the Panda3D ABI expressed as a string.
This usually means the major and minor version. It should be the
same for Panda3D versions that are supposed to be backward