diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f2475..f61624d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14) -project(scratchcpp-render VERSION 1.0.0 LANGUAGES CXX) +project(scratchcpp-render VERSION 0.5.0 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) @@ -17,6 +17,10 @@ qt_standard_project_setup(REQUIRES 6.6) add_subdirectory(src) target_compile_definitions(scratchcpp-render PRIVATE SCRATCHCPPRENDER_LIBRARY) +target_compile_definitions(scratchcpp-render PRIVATE SCRATCHCPPRENDER_VERSION="${PROJECT_VERSION}") +target_compile_definitions(scratchcpp-render PRIVATE SCRATCHCPPRENDER_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}) +target_compile_definitions(scratchcpp-render PRIVATE SCRATCHCPPRENDER_VERSION_MINOR=${PROJECT_VERSION_MINOR}) +target_compile_definitions(scratchcpp-render PRIVATE SCRATCHCPPRENDER_VERSION_PATCH=${PROJECT_VERSION_PATCH}) linkQt(scratchcpp-render) diff --git a/include/scratchcpp-render/scratchcpp-render.h b/include/scratchcpp-render/scratchcpp-render.h index de80b15..a2bfad1 100644 --- a/include/scratchcpp-render/scratchcpp-render.h +++ b/include/scratchcpp-render/scratchcpp-render.h @@ -2,6 +2,8 @@ #pragma once +#include + /*! \brief The main namespace of the library. */ namespace scratchcpprender { @@ -9,4 +11,16 @@ namespace scratchcpprender /*! Initializes the library. Call this from main before constructing your Q(Gui)Application object. */ void init(); +/*! Returns the version string of the library. */ +const std::string &version(); + +/*! Returns the major version of the library. */ +int majorVersion(); + +/*! Returns the minor version of the library. */ +int minorVersion(); + +/*! Returns the patch version of the library. */ +int patchVersion(); + } // namespace scratchcpprender diff --git a/src/global_functions.cpp b/src/global_functions.cpp index 38ff464..3dc93a1 100644 --- a/src/global_functions.cpp +++ b/src/global_functions.cpp @@ -8,3 +8,24 @@ void scratchcpprender::init() qputenv("QSG_RENDER_LOOP", "basic"); QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL); } + +const std::string &scratchcpprender::version() +{ + static const std::string ret = SCRATCHCPPRENDER_VERSION; + return ret; +} + +int scratchcpprender::majorVersion() +{ + return SCRATCHCPPRENDER_VERSION_MAJOR; +} + +int scratchcpprender::minorVersion() +{ + return SCRATCHCPPRENDER_VERSION_MINOR; +} + +int scratchcpprender::patchVersion() +{ + return SCRATCHCPPRENDER_VERSION_PATCH; +}