Skip to content

Commit

Permalink
Include git version in binary build
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad1mir-D committed Jan 25, 2015
1 parent 9022e1f commit 24303c1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ else ( LIBUNWIND_FOUND )
set( LIBUNWIND_LIBRARIES )
endif( LIBUNWIND_FOUND )

add_custom_target( invalidate_files ALL
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" )
execute_process( OUTPUT_VARIABLE ZBACKUP_VERSION
COMMAND git describe --tags --always
OUTPUT_STRIP_TRAILING_WHITESPACE )
if ( ZBACKUP_VERSION )
ADD_DEFINITIONS( -DZBACKUP_VERSION="${ZBACKUP_VERSION}" )
endif( ZBACKUP_VERSION )

file( GLOB sourceFiles "*.cc" )
add_executable( zbackup ${sourceFiles} ${protoSrcs} ${protoHdrs} )

Expand Down
9 changes: 9 additions & 0 deletions version.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE

#include <string>
#ifndef ZBACKUP_VERSION
std::string zbackup_version( "1.4" );
#else
std::string zbackup_version( ZBACKUP_VERSION );
#endif
10 changes: 10 additions & 0 deletions version.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE

#ifndef VERSION_HH_INCLUDED
#define VERSION_HH_INCLUDED
#include <string>

extern std::string zbackup_version;

#endif
5 changes: 3 additions & 2 deletions zbackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "backup_collector.hh"
#include "config.hh"
#include "utils.hh"
#include "version.hh"

using std::vector;
using std::bitset;
Expand Down Expand Up @@ -443,7 +444,7 @@ int main( int argc, char *argv[] )
if ( args.size() < 1 || printHelp )
{
fprintf( stderr,
"ZBackup, a versatile deduplicating backup tool, version 1.4\n"
"ZBackup, a versatile deduplicating backup tool, version %s\n"
"Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and\n"
"ZBackup contributors\n"
"Comes with no warranty. Licensed under GNU GPLv2 or later + OpenSSL.\n"
Expand Down Expand Up @@ -475,7 +476,7 @@ int main( int argc, char *argv[] )
" config [show|edit|set] <storage path> - performs configuration\n"
" manipulations (default is show)\n"
" For export/import storage path must be a valid (initialized) storage\n"
"", *argv );
"", zbackup_version.c_str(), *argv );
return EXIT_FAILURE;
}

Expand Down

0 comments on commit 24303c1

Please sign in to comment.