Add i3ipc::get_version()

This commit is contained in:
Sergey Naumov
2016-09-08 18:45:30 +03:00
parent 20ef07959f
commit 21680fd172
3 changed files with 27 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(i3ipc++)
string(TIMESTAMP I3IPCppBUILD_DATETIME "%Y-%m-%d %H:%M:%S")
option(I3IPCpp_WITH_TESTS "Build unit tests executables" OFF)
option(I3IPCpp_BUILD_EXAMPLES "Build example executables" OFF)
@@ -58,6 +60,10 @@ target_compile_options(i3ipc++
PUBLIC -std=c++11 -Wall -Wextra -Wno-unused-parameter
)
target_compile_definitions(i3ipc++
PRIVATE I3IPC_BUILD_DATETIME="${I3IPCppBUILD_DATETIME}"
)
if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
target_compile_options(i3ipc++
PUBLIC -g3

View File

@@ -342,6 +342,12 @@ private:
const std::string m_socket_path;
};
/**
* Get version of i3ipc++
* @return the version of i3ipc++
*/
const version_t& get_version();
}
/**

View File

@@ -553,4 +553,19 @@ int32_t connection::get_main_socket_fd() { return m_main_socket; }
int32_t connection::get_event_socket_fd() { return m_event_socket; }
const version_t& get_version() {
#define I3IPC_VERSION_MAJOR 0
#define I3IPC_VERSION_MINOR 3
#define I3IPC_VERSION_PATCH 0
static version_t version = {
.human_readable = auss_t() << I3IPC_VERSION_MAJOR << '.' << I3IPC_VERSION_MINOR << '.' << I3IPC_VERSION_PATCH << " (built on " << I3IPC_BUILD_DATETIME << ")",
.loaded_config_file_name = std::string(),
.major = I3IPC_VERSION_MAJOR,
.minor = I3IPC_VERSION_MINOR,
.patch = I3IPC_VERSION_PATCH,
};
return version;
}
}