From 98f1bba4ab9c148fd03a548e3d386884bf4c9db4 Mon Sep 17 00:00:00 2001 From: Matchman Green Date: Sun, 6 May 2012 22:40:58 +0800 Subject: [PATCH] added -v to display version --- CMakeLists.txt | 2 ++ grive/CMakeLists.txt | 2 ++ grive/src/main.cc | 9 ++++++++- libgrive/CMakeLists.txt | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7310308..5c7d1c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 2.8) +set( GRIVE_VERSION "0.0.4" ) + add_subdirectory( libgrive ) add_subdirectory( grive ) diff --git a/grive/CMakeLists.txt b/grive/CMakeLists.txt index 48243b8..e2dead6 100644 --- a/grive/CMakeLists.txt +++ b/grive/CMakeLists.txt @@ -5,6 +5,8 @@ include_directories( ${OPT_INCS} ) +add_definitions( -DVERSION="${GRIVE_VERSION}" ) + add_executable( grive_executable src/main.cc ) diff --git a/grive/src/main.cc b/grive/src/main.cc index ef14874..24cdd6d 100644 --- a/grive/src/main.cc +++ b/grive/src/main.cc @@ -87,7 +87,7 @@ int main( int argc, char **argv ) Json config = ReadConfig() ; int c ; - while ((c = getopt (argc, argv, "ac:")) != -1) + while ((c = getopt (argc, argv, "ac:v")) != -1) { switch ( c ) { @@ -115,6 +115,13 @@ int main( int argc, char **argv ) break ; } + + case 'v' : + { + std::cout + << "grive version " VERSION " " __DATE__ " " __TIME__ << std::endl ; + return 0 ; + } } } diff --git a/libgrive/CMakeLists.txt b/libgrive/CMakeLists.txt index 6f4be84..e133587 100644 --- a/libgrive/CMakeLists.txt +++ b/libgrive/CMakeLists.txt @@ -34,6 +34,8 @@ file (GLOB LIBGRIVE_SRC src/util/*.cc ) +add_definitions( -DVERSION="${GRIVE_VERSION}" ) + add_library( grive SHARED ${LIBGRIVE_SRC} ) target_link_libraries( grive @@ -43,7 +45,7 @@ target_link_libraries( grive ) set_target_properties(grive PROPERTIES - SOVERSION 0 VERSION 0.0.3 + SOVERSION 0 VERSION 0.0.4 ) install(TARGETS grive LIBRARY DESTINATION lib)