Configurable version string in CMakeLists.txt
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 13 Oct 2010 11:29:59 +0000 (13:29 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 13 Oct 2010 11:29:59 +0000 (13:29 +0200)
CMakeLists.txt
src/CMakeLists.txt
src/logger.cpp
src/version_info.h.in [new file with mode: 0644]

index b5a65bb..925d71b 100644 (file)
@@ -2,6 +2,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 PROJECT(bpdyndnsd)
 
+set(MAJOR_VERSION 1)
+set(MINOR_VERSION 0)
+set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
+
 # if you don't want the full compiler output, remove the following line
 SET(CMAKE_VERBOSE_MAKEFILE ON)
 
index 195469e..38b0178 100644 (file)
@@ -8,11 +8,14 @@ find_package(CURL)
 find_package(OpenSSL)
 
 # Includes
-include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
+include_directories(    ${CMAKE_CURRENT_BINARY_DIR}
+                        ${CMAKE_CURRENT_SOURCE_DIR}
                                    ${CURL_INCLUDES}
                                    ${OPENSSL_INCLUDES}
                                 )
 
+configure_file ("${PROJECT_SOURCE_DIR}/src/version_info.h.in" "${PROJECT_BINARY_DIR}/src/version_info.h")
+
 # C++ sources
 set(cpp_sources
         config.cpp
@@ -59,6 +62,7 @@ set(cpp_headers
         tcp_service.hpp
         updater.hpp
         util.hpp
+        version_info.h
     )
 
 add_executable(bpdyndnsd ${cpp_sources} ${cpp_headers})
index 58bdd1e..b548b96 100644 (file)
@@ -9,6 +9,7 @@
 
 
 #include "logger.hpp"
+#include "version_info.h"
 
 #include <iostream>
 #include <syslog.h>
 
 #include <boost/foreach.hpp>
 
-#define VERSION     0
-#define REVISION    1
-#define RELEASE     0
-
 namespace po = boost::program_options;
 
 typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
@@ -239,7 +236,7 @@ void Logger::print_version() const
     if ( level <= Loglevel )
     {
         ostringstream msg;
-        msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << VERSION << "." << REVISION << "." << RELEASE << endl;
+        msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << MAJOR_VERSION << "." << MINOR_VERSION << endl;
         log_notice(msg.str());
     }
 }
diff --git a/src/version_info.h.in b/src/version_info.h.in
new file mode 100644 (file)
index 0000000..ed5dca6
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _VERSION_INFO_H_
+#define _VERSION_INFO_H_
+
+#define MAJOR_VERSION @MAJOR_VERSION@
+#define MINOR_VERSION @MINOR_VERSION@
+
+#endif