diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04c26a30..a12fb3aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,7 +71,10 @@ if (FASTNETMON_PROFILER) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FASTNETMON_PROFILE_FLAGS}") endif() -set(FASTNETMON_APPLICATION_VERSION "1.1.3 master") +# Get last commit hash +execute_process(COMMAND git rev-list HEAD COMMAND head -n 1 OUTPUT_VARIABLE GIT_LAST_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(FASTNETMON_APPLICATION_VERSION "1.1.3 master git-${GIT_LAST_COMMIT_HASH}") configure_file(fast_platform.h.template "${PROJECT_SOURCE_DIR}/fast_platform.h") # With this flag we can diable PF_RING build via console: cmake .. -DDISABLE_PF_RING_SUPPORT=ON diff --git a/src/fastnetmon.cpp b/src/fastnetmon.cpp index 4ec4324d..da3937e8 100644 --- a/src/fastnetmon.cpp +++ b/src/fastnetmon.cpp @@ -2477,6 +2477,7 @@ int main(int argc, char** argv) { po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") + ("version", "show version") ("daemonize", "detach from the terminal") ("configuration_file", po::value(), "set path to custom configuration file") ; @@ -2487,7 +2488,12 @@ int main(int argc, char** argv) { if (vm.count("help")) { std::cout << desc << std::endl; - exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); + } + + if (vm.count("version")) { + std::cout << "Version: " << fastnetmon_version << std::endl; + exit(EXIT_SUCCESS); } if (vm.count("daemonize")) {