Skip to content

Add version API #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions include/scratchcpp-render/scratchcpp-render.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

#pragma once

#include <string>

/*! \brief The main namespace of the library. */
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
21 changes: 21 additions & 0 deletions src/global_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}