[Amarok] f9cb630 Set version to 'git describe' output when building

Rick W. Chen stuffcorpse at archlinux.us
Tue Jun 22 00:41:05 CEST 2010


commit f9cb630ba664110231425f3f3538275b93c77cc5
Author: Rick W. Chen <stuffcorpse at archlinux.us>
Date:   Tue Jun 22 04:28:11 2010 +1200

    Set version to 'git describe' output when building in a git repo
    
    This has the downside where the version string is only updated when
    cmake is run. If some commits are made that do not cause cmake to be
    invoked, then the version is unchanged. A simple solution is to touch
    the CMakeCache.txt file before build.
    
    CCMAIL: amarok-devel at kde.org

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d2b2df0..8dbe21e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,10 +44,14 @@ include(CheckTagLibFileName)
 check_taglib_filename(COMPLEX_TAGLIB_FILENAME)
 
 # Figure out problems inside KAboutData before re-enabling
-#execute_process( COMMAND "git" "describe" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE GIT_OUTPUT_VALUE OUTPUT_VARIABLE CURRENT_GIT_VERSION )
-#if(GIT_OUTPUT_VALUE EQUAL 0)
-#    message(STATUS "Building git version ${CURRENT_GIT_VERSION}")
-#endif(GIT_OUTPUT_VALUE EQUAL 0)
+execute_process( COMMAND "git" "describe"
+                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+                 RESULT_VARIABLE GIT_OUTPUT_VALUE
+                 OUTPUT_VARIABLE CURRENT_GIT_VERSION
+                 OUTPUT_STRIP_TRAILING_WHITESPACE )
+if(GIT_OUTPUT_VALUE EQUAL 0)
+   message(STATUS "Building git version ${CURRENT_GIT_VERSION}")
+endif(GIT_OUTPUT_VALUE EQUAL 0)
 
 
 # Needed to conditionally build tests and gui
diff --git a/config-amarok.h.cmake b/config-amarok.h.cmake
index ff107e9..95b625d 100644
--- a/config-amarok.h.cmake
+++ b/config-amarok.h.cmake
@@ -34,7 +34,7 @@
 #cmakedefine COMPLEX_TAGLIB_FILENAME 1
 
 /* The Git version being compiled, if any. undef means not running from Git. */
-#cmakedefine CURRENT_GIT_VERSION ${CURRENT_GIT_VERSION}
+#cmakedefine CURRENT_GIT_VERSION "${CURRENT_GIT_VERSION}"
 
 /* If liblastfm is found */
 #cmakedefine HAVE_LIBLASTFM 1
diff --git a/shared/Version.h b/shared/Version.h
index adf30e9..d7afe00 100644
--- a/shared/Version.h
+++ b/shared/Version.h
@@ -17,13 +17,13 @@
 #ifndef AMAROK_VERSION_H
 #define AMAROK_VERSION_H
 
+#include "config-amarok.h"
 
 /// Update this when necessary
-//#ifdef CURRENT_GIT_VERSION
-//#define AMAROK_VERSION #CURRENT_GIT_VERSION
-//#else
-#define AMAROK_VERSION "2.3-GIT"
-//#endif
-
+#ifdef CURRENT_GIT_VERSION
+# define AMAROK_VERSION CURRENT_GIT_VERSION
+#else
+# define AMAROK_VERSION "2.3-GIT"
+#endif
 
 #endif  // End include guard


More information about the Amarok-devel mailing list