From 80a040ac772132a8d8e7385c0261f545adc88aee Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 23 Apr 2014 19:13:00 -0700 Subject: [PATCH] fixes to scm_rev generation to make it conistent with windows build --- CMakeLists.txt | 1 + .../GetGitRevisionDescription.cmake | 28 +++++++++++++++++++ src/common/CMakeLists.txt | 6 ++-- src/common/scm_rev.cpp.in | 4 +-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83a819a7fd..08e1eb0ca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modul include(GetGitRevisionDescription) get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) +git_branch_name(GIT_BRANCH) # external includes include_directories(${OPENGL_INCLUDE_DIR}) diff --git a/externals/cmake-modules/GetGitRevisionDescription.cmake b/externals/cmake-modules/GetGitRevisionDescription.cmake index 2b9cde061c..087f5deeae 100644 --- a/externals/cmake-modules/GetGitRevisionDescription.cmake +++ b/externals/cmake-modules/GetGitRevisionDescription.cmake @@ -80,6 +80,34 @@ function(get_git_head_revision _refspecvar _hashvar) set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) endfunction() +function(git_branch_name _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + function(git_describe _var) if(NOT GIT_FOUND) find_package(Git QUIET) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 1495e433b1..5eaf673652 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,4 +1,4 @@ -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp" @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY) set(SRCS break_points.cpp console_listener.cpp @@ -13,10 +13,10 @@ set(SRCS break_points.cpp misc.cpp msg_handler.cpp string_util.cpp + scm_rev.cpp symbols.cpp thread.cpp timer.cpp - utf8.cpp - ${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp) + utf8.cpp) add_library(common STATIC ${SRCS}) diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 9e2bcfdd8d..512c5bd4ce 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -5,13 +5,13 @@ #include "common/scm_rev.h" #define GIT_REV "@GIT_REV@" -#define GIT_REF_SPEC "@GIT_REF_SPEC@" +#define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESC "@GIT_DESC@" namespace Common { const char g_scm_rev[] = GIT_REV; -const char g_scm_ref_spec[] = GIT_REF_SPEC; +const char g_scm_ref_spec[] = GIT_BRANCH; const char g_scm_desc[] = GIT_DESC; } // namespace