From 89a4b0c0482764f17f679ef54f4128e9ba04ad78 Mon Sep 17 00:00:00 2001 From: "Pawel \"l0ner\" Soltys" Date: Sun, 18 Jan 2015 14:51:27 +0100 Subject: [PATCH] version defines prefixed with name, full version now the version variables will be prefixed with 'tmux-mem-cpu-load'. This way we won't clash with any future dependency that might redefine those variables. This is exactly how CMake does it in their code, see: https://github.com/Kitware/CMake/blob/f3e92d281682ee482b1425675b9fccd372cd01f3/Source/CMakeVersion.cmake https://github.com/Kitware/CMake/blob/6ae98ee18f6c35b93556a66dc0ce909d84aec18b/Source/cmVersionConfig.h.in https://github.com/Kitware/CMake/blob/6ae98ee18f6c35b93556a66dc0ce909d84aec18b/Source/CMakeVersionCompute.cmake the only difference is that they have functions that return the versions and I use those variables directly. https://github.com/Kitware/CMake/blob/6ae98ee18f6c35b93556a66dc0ce909d84aec18b/Source/cmVersion.cxx Since the partial version variables are not used anywhere in the code we might as well remove them from version.h.in. I've deciced to leave them for now, since we might need them in the future. --- CMakeLists.txt | 9 ++++++--- tmux-mem-cpu-load.cpp | 6 ++---- version.h.in | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69478ff..75079e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,12 @@ endif(COMMAND cmake_policy) ### General Package stuff project( tmux-mem-cpu-load ) -set(VERSION_MAJOR 2) -set(VERSION_MINOR 3) -set(VERSION_PATCH 0) +set(tmux-mem-cpu-load_VERSION_MAJOR 2) +set(tmux-mem-cpu-load_VERSION_MINOR 3) +set(tmux-mem-cpu-load_VERSION_PATCH 0) +#Compute full version string +set(tmux-mem-cpu-load_VERSION + ${tmux-mem-cpu-load_VERSION_MAJOR}.${tmux-mem-cpu-load_VERSION_MINOR}.${tmux-mem-cpu-load_VERSION_PATCH}) # generate header file to handle version configure_file( diff --git a/tmux-mem-cpu-load.cpp b/tmux-mem-cpu-load.cpp index a859889..15d090f 100644 --- a/tmux-mem-cpu-load.cpp +++ b/tmux-mem-cpu-load.cpp @@ -96,10 +96,8 @@ int main( int argc, char** argv ) // ugly, I know std::string intro = "tmux-mem-cpu-load v"; - intro += std::to_string( VERSION_MAJOR ) + "."; - intro += std::to_string( VERSION_MINOR ) + "."; - intro += std::to_string( VERSION_PATCH ) + "\n"; - intro += "Usage: tmux-mem-cpu-load [OPTIONS]"; + intro += tmux_mem_cpu_load_VERSION; + intro += "\nUsage: tmux-mem-cpu-load [OPTIONS]"; arg.setIntroduction( intro ); diff --git a/version.h.in b/version.h.in index 81a4c45..c46dd04 100644 --- a/version.h.in +++ b/version.h.in @@ -17,7 +17,7 @@ */ // the configured options and settings for sysstat -#define VERSION_MAJOR @VERSION_MAJOR@ -#define VERSION_MINOR @VERSION_MINOR@ -#define VERSION_PATCH @VERSION_PATCH@ - +#define tmux_mem_cpu_load_VERSION_MAJOR @tmux-mem-cpu-load_VERSION_MAJOR@ +#define tmux_mem_cpu_load_VERSION_MINOR @tmux-mem-cpu-load_VERSION_MINOR@ +#define tmux_mem_cpu_load_VERSION_PATCH @tmux-mem-cpu-load_VERSION_PATCH@ +#define tmux_mem_cpu_load_VERSION "@tmux-mem-cpu-load_VERSION@"