Skip to content

Commit c71874b

Browse files
authored
Add versioning and 1.1.0 as version (#16)
1 parent 002c931 commit c71874b

File tree

7 files changed

+25
-1
lines changed

7 files changed

+25
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
# limitations under the License.
1414

1515
cmake_minimum_required(VERSION 3.8)
16-
project(mgclient VERSION 0.1)
16+
17+
project(mgclient VERSION 1.1.0)
18+
# Minor version increase can also mean ABI incompatibility with previous
19+
# versions. IMPORTANT: Take care of the SO version manually.
20+
set(mgclient_SOVERSION 2)
21+
add_definitions(-DMGCLIENT_VERSION="${mgclient_VERSION}")
22+
1723
# Building tests is disabled by default to simplify the default build config.
1824
option(BUILD_TESTING "" OFF)
1925
message(STATUS "BUILD_TESTING: ${BUILD_TESTING}")

examples/basic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ int main(int argc, char *argv[]) {
99
exit(1);
1010
}
1111

12+
printf("mgclient version: %s\n", mg_client_version());
13+
1214
mg_session_params *params = mg_session_params_make();
1315
if (!params) {
1416
fprintf(stderr, "failed to allocate session parameters\n");

examples/basic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ int main(int argc, char *argv[]) {
99
exit(1);
1010
}
1111

12+
std::cout << "mgclient version: " << mg::Client::Version() << std::endl;
1213
mg::Client::Params params;
1314
params.host = argv[1];
1415
params.port = static_cast<uint16_t>(atoi(argv[2]));

include/mgclient.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ extern "C" {
129129

130130
#include <stdint.h>
131131

132+
/// Client software version.
133+
///
134+
/// \return Client version in the major.minor.patch format.
135+
MGCLIENT_EXPORT const char *mg_client_version();
136+
132137
/// An enum listing all the types as specified by Bolt protocol.
133138
enum mg_value_type {
134139
MG_VALUE_TYPE_NULL,

include/mgclient.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <optional>
1919

2020
#include "mgclient.h"
21+
2122
#include "mgvalue.hpp"
2223

2324
namespace mg {
@@ -41,6 +42,10 @@ class Client {
4142
Client &operator=(Client &&) = delete;
4243
~Client();
4344

45+
/// \brief Client software version.
46+
/// \return client version in the major.minor.patch format.
47+
static const char *Version();
48+
4449
/// \brief Executes the given Cypher `statement`.
4550
/// \return true when the statement is successfully executed, false otherwise.
4651
/// \note
@@ -121,6 +126,8 @@ inline Client::Client(mg_session *session) : session_(session) {}
121126

122127
inline Client::~Client() { mg_session_destroy(session_); }
123128

129+
inline const char *Client::Version() { return mg_client_version(); }
130+
124131
inline bool Client::Execute(const std::string &statement) {
125132
int status = mg_session_run(session_, statement.c_str(), nullptr, nullptr,
126133
nullptr, nullptr);

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ target_link_libraries(mgclient-static PRIVATE ${OPENSSL_LIBRARIES} project_optio
4545
add_library(mgclient-shared SHARED ${mgclient_src_files})
4646
set_target_properties(mgclient-shared PROPERTIES
4747
OUTPUT_NAME mgclient
48+
SOVERSION ${mgclient_SOVERSION}
4849
C_VISIBILITY_PRESET hidden)
4950
target_include_directories(mgclient-shared
5051
PUBLIC

src/mgclient.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "mgsession.h"
3535
#include "mgvalue.h"
3636

37+
const char *mg_client_version() { return MGCLIENT_VERSION; }
38+
3739
typedef struct mg_session_params {
3840
const char *address;
3941
const char *host;

0 commit comments

Comments
 (0)