From 58c417c4db7000971efda838664961c2a6df271c Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Tue, 5 Mar 2024 18:16:43 +0100 Subject: [PATCH 1/2] Add definitions for project version --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57f65922..3d9a8456 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14) -project(libscratchcpp LANGUAGES C CXX) +project(libscratchcpp VERSION 0.9.0 LANGUAGES C CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) @@ -92,6 +92,10 @@ if (LIBSCRATCHCPP_NETWORK_SUPPORT) endif() target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_LIBRARY) +target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION="${PROJECT_VERSION}") +target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}) +target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION_MINOR=${PROJECT_VERSION_MINOR}) +target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION_PATCH=${PROJECT_VERSION_PATCH}) if (LIBSCRATCHCPP_BUILD_UNIT_TESTS) enable_testing() From 36dccb86cd84656c58371baca3ef9b25a0d4a6c6 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Tue, 5 Mar 2024 18:17:18 +0100 Subject: [PATCH 2/2] Add version API --- include/scratchcpp/scratchconfiguration.h | 5 +++++ src/scratchconfiguration.cpp | 25 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/scratchcpp/scratchconfiguration.h b/include/scratchcpp/scratchconfiguration.h index 46414e7b..991bdcdc 100644 --- a/include/scratchcpp/scratchconfiguration.h +++ b/include/scratchcpp/scratchconfiguration.h @@ -40,6 +40,11 @@ class LIBSCRATCHCPP_EXPORT ScratchConfiguration static void removeGraphicsEffect(const std::string &name); static IGraphicsEffect *getGraphicsEffect(const std::string &name); + static const std::string &version(); + static int majorVersion(); + static int minorVersion(); + static int patchVersion(); + private: static const std::vector> getExtensions(); diff --git a/src/scratchconfiguration.cpp b/src/scratchconfiguration.cpp index 196813bb..24411dec 100644 --- a/src/scratchconfiguration.cpp +++ b/src/scratchconfiguration.cpp @@ -49,6 +49,31 @@ IGraphicsEffect *ScratchConfiguration::getGraphicsEffect(const std::string &name return it->second.get(); } +/*! Returns the version string of the library. */ +const std::string &ScratchConfiguration::version() +{ + static const std::string ret = LIBSCRATCHCPP_VERSION; + return ret; +} + +/*! Returns the major version of the library. */ +int ScratchConfiguration::majorVersion() +{ + return LIBSCRATCHCPP_VERSION_MAJOR; +} + +/*! Returns the minor version of the library. */ +int ScratchConfiguration::minorVersion() +{ + return LIBSCRATCHCPP_VERSION_MINOR; +} + +/*! Returns the patch version of the library. */ +int ScratchConfiguration::patchVersion() +{ + return LIBSCRATCHCPP_VERSION_PATCH; +} + const std::vector> ScratchConfiguration::getExtensions() { return impl->extensions;