From e2f9863608fa5c9569d90f1ff2a15c2a401cad29 Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:36:37 +0100 Subject: [PATCH 1/4] Declare the project version and install a package version file --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc44cef..eae741af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_policy(SET CMP0072 NEW) # new in 3.11. The NEW behavior for this policy is cmake_policy(SET CMP0068 NEW) # new in 3.9. The NEW behavior of this policy is to ignore the RPATH settings for install_name on macOS. -project(QtNodesLibrary CXX) +project(QtNodesLibrary VERSION 3.2.1 LANGUAGES CXX) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) @@ -199,6 +199,8 @@ set_target_properties(QtNodes ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} ) ########### @@ -255,7 +257,14 @@ configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/QtNodesConfig.cmak INSTALL_DESTINATION ${INSTALL_CONFIGDIR} ) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/QtNodesConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtNodesConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/QtNodesConfigVersion.cmake DESTINATION ${INSTALL_CONFIGDIR} ) From 7b30f1fd31d29b27d5218a58af49f2701f9eef01 Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:36:49 +0100 Subject: [PATCH 2/4] Generate a version header from the project version --- CMakeLists.txt | 11 +++++++++++ cmake/Version.hpp.in | 13 +++++++++++++ include/QtNodes/Version | 1 + 3 files changed, 25 insertions(+) create mode 100644 cmake/Version.hpp.in create mode 100644 include/QtNodes/Version diff --git a/CMakeLists.txt b/CMakeLists.txt index eae741af..f7a1c5fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,13 @@ set(CPP_SOURCE_FILES resources/resources.qrc ) +set(QT_NODES_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) + +configure_file(cmake/Version.hpp.in + ${QT_NODES_GENERATED_INCLUDE_DIR}/QtNodes/internal/Version.hpp + @ONLY +) + set(HPP_HEADER_FILES include/QtNodes/internal/AbstractConnectionPainter.hpp include/QtNodes/internal/AbstractGraphModel.hpp @@ -148,6 +155,7 @@ target_include_directories(QtNodes PUBLIC $ $ + $ PRIVATE $ $ @@ -244,6 +252,9 @@ install(TARGETS QtNodes install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${QT_NODES_GENERATED_INCLUDE_DIR}/QtNodes/internal/Version.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/QtNodes/internal) + install(EXPORT QtNodesTargets FILE QtNodesTargets.cmake NAMESPACE QtNodes:: diff --git a/cmake/Version.hpp.in b/cmake/Version.hpp.in new file mode 100644 index 00000000..a209f5f8 --- /dev/null +++ b/cmake/Version.hpp.in @@ -0,0 +1,13 @@ +#pragma once + +// Generated by CMake from the version in project(). Do not edit. + +#define QTNODES_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define QTNODES_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define QTNODES_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define QTNODES_VERSION_STR "@PROJECT_VERSION@" + +#define QTNODES_VERSION_CHECK(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch)) + +#define QTNODES_VERSION \ + QTNODES_VERSION_CHECK(QTNODES_VERSION_MAJOR, QTNODES_VERSION_MINOR, QTNODES_VERSION_PATCH) diff --git a/include/QtNodes/Version b/include/QtNodes/Version new file mode 100644 index 00000000..d9f8d831 --- /dev/null +++ b/include/QtNodes/Version @@ -0,0 +1 @@ +#include From 9ae819ad144f616e58ccb18064497df389db4f7e Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:36:54 +0100 Subject: [PATCH 3/4] Test the generated version macros --- test/CMakeLists.txt | 1 + test/src/TestVersion.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/src/TestVersion.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 53ba18ea..b44dc026 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,6 +27,7 @@ add_executable(test_nodes src/TestNodeStyleRole.cpp src/TestCopyPaste.cpp src/TestSerializedItemCommands.cpp + src/TestVersion.cpp src/TestZoomFeatures.cpp src/TestLoopDetection.cpp include/ApplicationSetup.hpp diff --git a/test/src/TestVersion.cpp b/test/src/TestVersion.cpp new file mode 100644 index 00000000..bf42342b --- /dev/null +++ b/test/src/TestVersion.cpp @@ -0,0 +1,22 @@ +#include + +#include + +#include + +TEST_CASE("The version string is built from the version numbers", "[core][version]") +{ + std::string const expected = std::to_string(QTNODES_VERSION_MAJOR) + "." + + std::to_string(QTNODES_VERSION_MINOR) + "." + + std::to_string(QTNODES_VERSION_PATCH); + + CHECK(std::string(QTNODES_VERSION_STR) == expected); +} + +TEST_CASE("Newer versions compare greater with QTNODES_VERSION_CHECK", "[core][version]") +{ + CHECK(QTNODES_VERSION_CHECK(3, 2, 1) < QTNODES_VERSION_CHECK(3, 2, 2)); + CHECK(QTNODES_VERSION_CHECK(3, 2, 9) < QTNODES_VERSION_CHECK(3, 3, 0)); + CHECK(QTNODES_VERSION_CHECK(3, 9, 9) < QTNODES_VERSION_CHECK(4, 0, 0)); + CHECK(QTNODES_VERSION >= QTNODES_VERSION_CHECK(QTNODES_VERSION_MAJOR, 0, 0)); +} From 606dfc3580f1adeb8180fded58df9ba7b40fc597 Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:36:54 +0100 Subject: [PATCH 4/4] Take the docs version from the project version --- docs/Doxyfile.in | 2 +- docs/conf.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index d58dcbf5..76b06a7d 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = "QtNodes" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1 +PROJECT_NUMBER = @PROJECT_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/docs/conf.py b/docs/conf.py index ff97b881..efc3de7f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,4 @@ -import subprocess, os +import subprocess, os, re def configureDoxyfile(input_dir, output_dir): with open('Doxyfile.in', 'r') as file : @@ -34,8 +34,10 @@ def configureDoxyfile(input_dir, output_dir): copyright = '2022, Dmitry Pinaev' author = 'Dmitry Pinaev' -# The full version, including alpha/beta/rc tags -release = '3.0' +# The version is declared once, in project() of the top CMakeLists.txt. +with open(os.path.join(os.path.dirname(__file__), '..', 'CMakeLists.txt')) as f: + release = re.search(r'project\(\s*QtNodesLibrary\s+VERSION\s+([\d.]+)', f.read()).group(1) +version = '.'.join(release.split('.')[:2]) # -- General configuration ---------------------------------------------------