2018-01-01 00:40:17 +01:00
|
|
|
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
2010-10-03 16:30:22 +02:00
|
|
|
#
|
|
|
|
|
# This file is free software; as a special exception the author gives
|
|
|
|
|
# unlimited permission to copy and/or distribute it, with or without
|
|
|
|
|
# modifications, as long as this notice is preserved.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
2013-02-11 20:04:27 +01:00
|
|
|
# User has manually chosen to ignore the git-tests, so throw them a warning.
|
|
|
|
|
# This is done EACH compile so they can be alerted about the consequences.
|
2013-02-11 23:27:20 +01:00
|
|
|
|
|
|
|
|
if(NOT BUILDDIR)
|
2015-02-22 20:51:25 +01:00
|
|
|
# Workaround for funny MSVC behaviour - this segment is only used when using cmake gui
|
2013-02-11 23:27:20 +01:00
|
|
|
set(BUILDDIR ${CMAKE_BINARY_DIR})
|
|
|
|
|
endif()
|
|
|
|
|
|
2015-02-22 20:51:25 +01:00
|
|
|
if(WITHOUT_GIT)
|
2013-02-11 20:04:27 +01:00
|
|
|
set(rev_date "1970-01-01 00:00:00 +0000")
|
2013-02-27 15:42:57 +01:00
|
|
|
set(rev_hash "unknown")
|
|
|
|
|
set(rev_branch "Archived")
|
2013-02-11 01:56:25 +01:00
|
|
|
else()
|
2015-02-22 20:51:25 +01:00
|
|
|
if(GIT_EXECUTABLE)
|
2013-02-11 20:04:27 +01:00
|
|
|
# Create a revision-string that we can use
|
2013-02-11 14:51:26 +01:00
|
|
|
execute_process(
|
2016-03-31 23:39:53 +02:00
|
|
|
COMMAND "${GIT_EXECUTABLE}" describe --long --match init --dirty=+ --abbrev=12
|
2013-02-11 14:51:26 +01:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
|
OUTPUT_VARIABLE rev_info
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
|
|
|
|
)
|
2013-02-11 20:04:27 +01:00
|
|
|
|
2013-02-11 23:27:20 +01:00
|
|
|
# And grab the commits timestamp
|
2013-02-11 14:51:26 +01:00
|
|
|
execute_process(
|
2015-02-22 20:51:25 +01:00
|
|
|
COMMAND "${GIT_EXECUTABLE}" show -s --format=%ci
|
2013-02-11 14:51:26 +01:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
|
OUTPUT_VARIABLE rev_date
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
|
|
|
|
)
|
2014-08-27 23:21:55 +02:00
|
|
|
|
2013-02-27 15:42:57 +01:00
|
|
|
# Also retrieve branch name
|
|
|
|
|
execute_process(
|
2015-02-22 20:51:25 +01:00
|
|
|
COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
|
2013-02-27 15:42:57 +01:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
|
OUTPUT_VARIABLE rev_branch
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
|
|
|
|
)
|
2013-02-11 14:51:26 +01:00
|
|
|
endif()
|
2010-10-03 16:30:22 +02:00
|
|
|
|
2013-02-11 23:27:20 +01:00
|
|
|
# Last minute check - ensure that we have a proper revision
|
|
|
|
|
# If everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag)
|
|
|
|
|
if(NOT rev_info)
|
|
|
|
|
# No valid ways available to find/set the revision/hash, so let's force some defaults
|
|
|
|
|
message(STATUS "
|
|
|
|
|
Could not find a proper repository signature (hash) - you may need to pull tags with git fetch -t
|
2013-10-15 20:22:28 +02:00
|
|
|
Continuing anyway - note that the versionstring will be set to \"unknown 1970-01-01 00:00:00 (Archived)\"")
|
2013-02-11 23:27:20 +01:00
|
|
|
set(rev_date "1970-01-01 00:00:00 +0000")
|
2013-02-27 15:42:57 +01:00
|
|
|
set(rev_hash "unknown")
|
|
|
|
|
set(rev_branch "Archived")
|
2013-02-11 23:27:20 +01:00
|
|
|
else()
|
|
|
|
|
# Extract information required to build a proper versionstring
|
|
|
|
|
string(REGEX REPLACE init-|[0-9]+-g "" rev_hash ${rev_info})
|
|
|
|
|
endif()
|
2010-10-03 16:55:24 +02:00
|
|
|
endif()
|
|
|
|
|
|
2015-08-16 16:56:11 +02:00
|
|
|
# Create the actual revision_data.h file from the above params
|
|
|
|
|
if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision_data.h")
|
2010-10-14 22:48:55 +02:00
|
|
|
configure_file(
|
2015-08-16 16:56:11 +02:00
|
|
|
"${CMAKE_SOURCE_DIR}/revision_data.h.in.cmake"
|
|
|
|
|
"${BUILDDIR}/revision_data.h"
|
2010-10-14 22:48:55 +02:00
|
|
|
@ONLY
|
|
|
|
|
)
|
2011-08-04 22:53:33 +02:00
|
|
|
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
|
2013-02-27 15:42:57 +01:00
|
|
|
set(rev_branch_cached "${rev_branch}" CACHE INTERNAL "Cached branch name")
|
2010-10-14 22:48:55 +02:00
|
|
|
endif()
|