Skip to content
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
12 changes: 12 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,15 @@ that include QtNodes choose their own standard.
- Versions follow semver. A tag on a later commit must have a higher version than the tags
before it. Never move or delete a published tag.
- Branches: `master` (latest dev state) and `v3`. Older versions are tags (`1.0`, `2.*`).

### Version

- The only source of the version is `project(QtNodesLibrary VERSION x.y.z)` in `CMakeLists.txt`.
The version header, the package version file, the library version and the docs read it from
there. Do not write the version by hand anywhere else.
- `CITATION.cff` (`version` and `date-released`) and the git tag are copies that cannot be
generated. `cmake/CheckVersion.cmake` compares `CITATION.cff` with `project()`, and CTest runs
it. Add any new copy to that script.
- Change the version only to prepare a release, in any commit. Then run
`cmake -P cmake/Tag.cmake`. It creates the annotated tag from `project()` and refuses a version
that is not higher than every local and remote tag. Tag and push only when asked.
19 changes: 19 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cff-version: 1.2.0
message: "If you use QtNodes, please cite it with the version you used."
type: software
title: "QtNodes. Node Editor"
abstract: "A Qt-based C++ library for building node graph editors and data-flow editors."
authors:
- family-names: "Pinaev"
given-names: "Dmitry"
- name: "QtNodes contributors"
repository-code: "https://github.com/paceholder/nodeeditor"
url: "https://github.com/paceholder/nodeeditor"
license: BSD-3-Clause
version: 3.2.1
date-released: 2026-11-23
keywords:
- Qt
- C++
- node editor
- data flow
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,6 +155,7 @@ target_include_directories(QtNodes
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${QT_NODES_GENERATED_INCLUDE_DIR}>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/QtNodes/internal>
Expand Down Expand Up @@ -199,6 +207,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}
)

###########
Expand Down Expand Up @@ -242,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::
Expand All @@ -255,7 +268,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}
)
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BSD-3-Clause license
====================

Copyright (c) 2022, Dmitry Pinaev
Copyright (c) 2013-2026, Dmitry Pinaev
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
35 changes: 30 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ Contribution
#. Describe your issue in details
#. Provide some use cases.

#. Do not change the version number in a pull request. The maintainer sets it at release,
see `Releasing`_.

#. I maintain this project in my free time, when I am not busy with my work or
my family. **If I do not react or do not answer for too long, please ping
me**.
Expand All @@ -239,22 +242,44 @@ Contribution
Citing
======

Use the ``Cite this repository`` button on the GitHub page. It reads ``CITATION.cff``.
Please cite the version you used.

::

Dmitry Pinaev et al, Qt Nodes, (2013-2025), GitHub repository, https://github.com/paceholder/nodeeditor
Dmitry Pinaev et al, Qt Nodes, (2013-2026), GitHub repository, https://github.com/paceholder/nodeeditor

BibTeX::

@misc{Pinaev2025,
@misc{Pinaev2026,
author = {Dmitry Pinaev et al},
title = {QtNodes. Node Editor},
year = {2025},
year = {2026},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/paceholder/nodeeditor}},
commit = {877ddb8c447a7a061a5022e9956a3194132e3dd9}
howpublished = {\url{https://github.com/paceholder/nodeeditor}}
}

Releasing
=========

The version is written once, in ``project(QtNodesLibrary VERSION x.y.z)`` in
``CMakeLists.txt``. The version header, the CMake package version, the library version and
the docs read it from there. ``CITATION.cff`` and the git tag hold copies. To release:

#. Set the new version in ``project()`` and in ``CITATION.cff`` (``version`` and
``date-released``), in any commit.
#. Run ``cmake -P cmake/Tag.cmake`` on that commit. It creates the annotated tag from the
version in ``project()``. It stops if the version is not higher than every tag, local and
on the remote, or if ``CITATION.cff`` differs. Use ``-DREMOTE=<name>`` if your remote is
not ``origin``.
#. Push the commit and the tag::

git push origin master x.y.z

``cmake -P cmake/CheckVersion.cmake`` checks that ``CITATION.cff`` and ``project()`` agree. The
tests run it.

Support
=======

Expand Down
28 changes: 28 additions & 0 deletions cmake/CheckVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Checks that the release version is the same in every place that names it.
#
# cmake -P cmake/CheckVersion.cmake
#
# The version in project() of CMakeLists.txt is the source of truth.

get_filename_component(root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(version_regex "[0-9]+\\.[0-9]+\\.[0-9]+")

# Sets <name>_version to the first group of the pattern in the file.
function(read_version name file pattern)
file(READ "${root}/${file}" text)
if(NOT text MATCHES "${pattern}")
message(FATAL_ERROR "No version found in ${file}")
endif()
set(${name}_version "${CMAKE_MATCH_1}" PARENT_SCOPE)
endfunction()

read_version(project CMakeLists.txt
"project\\(QtNodesLibrary[ \t\r\n]+VERSION[ \t\r\n]+(${version_regex})")
read_version(citation CITATION.cff "\nversion: (${version_regex})")

if(NOT citation_version STREQUAL project_version)
message(FATAL_ERROR
"CITATION.cff has version ${citation_version}, project() has ${project_version}")
endif()

message(STATUS "Version ${project_version} is the same everywhere")
63 changes: 63 additions & 0 deletions cmake/Tag.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Creates the annotated git tag for the version in project() of CMakeLists.txt.
# It tags the current commit. It does not push.
#
# cmake -P cmake/Tag.cmake
# cmake -DREMOTE=github -P cmake/Tag.cmake # remote to compare with, default: origin
#
# It stops if CITATION.cff differs from project(), if tracked files have changes, or if the
# version is not higher than every version tag, local and on the remote.

include("${CMAKE_CURRENT_LIST_DIR}/CheckVersion.cmake")

if(NOT DEFINED REMOTE)
set(REMOTE origin)
endif()

function(run_git)
execute_process(COMMAND git ${ARGN}
WORKING_DIRECTORY "${root}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT result EQUAL 0)
string(REPLACE ";" " " command "${ARGN}")
message(FATAL_ERROR "git ${command} failed: ${error}")
endif()
set(git_output "${output}" PARENT_SCOPE)
endfunction()

run_git(status --porcelain --untracked-files=no)
if(NOT git_output STREQUAL "")
message(FATAL_ERROR "Tracked files have uncommitted changes. Commit them first.")
endif()

run_git(tag --list)
set(tags "${git_output}")
run_git(ls-remote --tags --refs "${REMOTE}")
string(REGEX MATCHALL "refs/tags/[^\n]+" remote_refs "${git_output}")
foreach(ref IN LISTS remote_refs)
string(REPLACE "refs/tags/" "" ref "${ref}")
list(APPEND tags "${ref}")
endforeach()
string(REPLACE "\n" ";" tags "${tags}")

set(latest "")
foreach(tag IN LISTS tags)
if(NOT tag MATCHES "^${version_regex}$")
continue()
endif()
if(tag STREQUAL project_version)
message(FATAL_ERROR "The tag ${project_version} already exists, locally or on '${REMOTE}'.")
endif()
if(latest STREQUAL "" OR tag VERSION_GREATER latest)
set(latest "${tag}")
endif()
endforeach()

if(NOT latest STREQUAL "" AND NOT project_version VERSION_GREATER latest)
message(FATAL_ERROR "The version ${project_version} is not higher than the tag ${latest}.")
endif()

run_git(tag -a "${project_version}" -m "QtNodes ${project_version}")
message(STATUS "Created the tag ${project_version}. Push it with: git push ${REMOTE} ${project_version}")
13 changes: 13 additions & 0 deletions cmake/Version.hpp.in
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import subprocess, os
import subprocess, os, re

def configureDoxyfile(input_dir, output_dir):
with open('Doxyfile.in', 'r') as file :
Expand Down Expand Up @@ -31,11 +31,13 @@ def configureDoxyfile(input_dir, output_dir):
# -- Project information -----------------------------------------------------

project = 'QtNodes'
copyright = '2022, Dmitry Pinaev'
copyright = '2026, 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 ---------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions docs/getting-started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,27 @@ After running ``cmake --install .``:

If you installed to a custom prefix, pass it with ``-DCMAKE_PREFIX_PATH=<prefix>``.

Checking the Version
--------------------

``find_package`` takes a minimum version. ``3.2`` accepts any ``3.x`` from ``3.2`` on and
rejects ``4.0``:

.. code-block:: cmake

find_package(QtNodes 3.2 REQUIRED)

In C++, ``QtNodes/Version`` defines ``QTNODES_VERSION_MAJOR``, ``QTNODES_VERSION_MINOR``,
``QTNODES_VERSION_PATCH``, the string ``QTNODES_VERSION_STR`` and ``QTNODES_VERSION_CHECK``:

.. code-block:: cpp

#include <QtNodes/Version>

#if QTNODES_VERSION >= QTNODES_VERSION_CHECK(3, 2, 0)
// ...
#endif

Verifying Installation
----------------------

Expand Down
1 change: 1 addition & 0 deletions include/QtNodes/Version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <QtNodes/internal/Version.hpp>
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,3 +56,8 @@ add_test(
$<TARGET_FILE:test_nodes>
$<$<BOOL:${NE_FORCE_TEST_COLOR}>:--use-colour=yes>
)

add_test(
NAME version_is_the_same_everywhere
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/CheckVersion.cmake
)
22 changes: 22 additions & 0 deletions test/src/TestVersion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <QtNodes/Version>

#include <catch2/catch.hpp>

#include <string>

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));
}
Loading