1
0
Fork 0

Implement detection whether we are in a git repo and use the toplevel source dir.

This commit is contained in:
Wilfried Goesgens 2016-08-18 17:53:47 +02:00
parent 7250db8830
commit dadd9833d1
3 changed files with 20 additions and 5 deletions

View File

@ -123,11 +123,23 @@ configure_file(
NEWLINE_STYLE UNIX
)
################################################################################
## Find the git revision
find_program (GIT_EXE git)
set (EXECUTE_COMMAND ${GIT_EXE} describe --all --tags --long --dirty=-dirty)
execute_process(COMMAND ${EXECUTE_COMMAND} OUTPUT_VARIABLE GIT_OUTPUT)
string(STRIP ${GIT_OUTPUT} REPOSITORY_VERSION)
set(ARANGODB_BUILD_REPOSITORY ${REPOSITORY_VERSION})
message("${CMAKE_SOURCE_DIR}/.git")
if (DEFINED GIT_EXE AND IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT_EXE} describe --all --tags --long --dirty=-dirty
OUTPUT_VARIABLE GIT_OUTPUT)
string(STRIP ${GIT_OUTPUT} REPOSITORY_VERSION)
set(ARANGODB_BUILD_REPOSITORY ${REPOSITORY_VERSION})
set(HAVE_ARANGODB_BUILD_REPOSITORY "1")
else ()
set(ARANGODB_BUILD_REPOSITORY "")
set(HAVE_ARANGODB_BUILD_REPOSITORY "0")
endif()
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/build-repository.h.in"

View File

@ -1 +1,2 @@
#define ARANGODB_BUILD_REPOSITORY "@ARANGODB_BUILD_REPOSITORY@"
#define HAVE_ARANGODB_BUILD_REPOSITORY @HAVE_ARANGODB_BUILD_REPOSITORY@

View File

@ -96,7 +96,9 @@ void Version::initialize() {
Values["asm-crc32"] = (ENABLE_ASM_CRC32) ? "true" : "false";
Values["boost-version"] = getBoostVersion();
Values["build-date"] = getBuildDate();
#if HAVE_ARANGODB_BUILD_REPOSITORY
Values["build-repository"] = getBuildRepository();
#endif
Values["compiler"] = getCompiler();
Values["endianness"] = getEndianness();
Values["fd-setsize"] = arangodb::basics::StringUtils::itoa(FD_SETSIZE);
@ -338,7 +340,7 @@ std::string Version::getBuildDate() {
////////////////////////////////////////////////////////////////////////////////
std::string Version::getBuildRepository() {
#ifdef ARANGODB_BUILD_REPOSITORY
#ifdef HAVE_ARANGODB_BUILD_REPOSITORY
return std::string(ARANGODB_BUILD_REPOSITORY);
#else
return std::string("");