From 796a163e6a44f91bb07487c835a7243861f878b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Walenciak?= Date: Sun, 22 Mar 2026 22:20:37 +0100 Subject: [PATCH] Add versioning to libraries --- CMakeLists.txt | 13 ++++++++++++- include/cpp_restapi/version.hpp.in | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 include/cpp_restapi/version.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index dc01092..662a82d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(cppRestAPI) +project(cppRestAPI VERSION 2.2.0) if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) @@ -57,6 +57,17 @@ target_link_libraries(cpp_restapi generate_export_header(cpp_restapi) +configure_file( + ${PROJECT_SOURCE_DIR}/include/cpp_restapi/version.hpp.in + ${PROJECT_BINARY_DIR}/cpp_restapi/version.hpp + @ONLY +) + +set_target_properties(cpp_restapi PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + if(NOT CppRestAPI_QtBackend AND NOT CppRestAPI_CurlBackend AND NOT CppRestAPI_CppHttplibBackend) message(FATAL_ERROR "No backend was chosen. Set CppRestAPI_QtBackend, CppRestAPI_CurlBackend or CppRestAPI_CppHttplibBackend variable to ON") endif() diff --git a/include/cpp_restapi/version.hpp.in b/include/cpp_restapi/version.hpp.in new file mode 100644 index 0000000..468b0e7 --- /dev/null +++ b/include/cpp_restapi/version.hpp.in @@ -0,0 +1,17 @@ +#ifndef CPP_RESTAPI_VERSION_HPP +#define CPP_RESTAPI_VERSION_HPP + +#define CPP_RESTAPI_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define CPP_RESTAPI_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define CPP_RESTAPI_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define CPP_RESTAPI_VERSION "@PROJECT_VERSION@" + +namespace cpp_restapi +{ + inline constexpr int versionMajor = @PROJECT_VERSION_MAJOR@; + inline constexpr int versionMinor = @PROJECT_VERSION_MINOR@; + inline constexpr int versionPatch = @PROJECT_VERSION_PATCH@; + inline constexpr char version[] = "@PROJECT_VERSION@"; +} + +#endif