Skip to content

Explain shared and static builds, and honor BUILD_SHARED_LIBS from the parent project - #552

Merged
paceholder merged 2 commits into
masterfrom
shared-static-build
Nov 23, 2026
Merged

paceholder merged 2 commits into
masterfrom
shared-static-build

Conversation

@paceholder

Copy link
Copy Markdown
Owner

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation/refactoring

Description

Two commits, one for the docs and one for the build file.

  1. Explain shared and static builds in the docs. New section "Shared and static library" in docs/getting-started/installation.rst, a pointer in the README, and a FAQ entry for the error "Cannot link against shared and static simultaneously" (NODE_EDITOR_SHARED added to target public definition #409). It says that QtNodes defines NODE_EDITOR_SHARED or NODE_EDITOR_STATIC for its users, that users must not define them (or NODE_EDITOR_EXPORTS) themselves, and that a static QtNodes still needs Qt. It also fixes the default of BUILD_TESTING and BUILD_EXAMPLES in the options table: ON for a top-level project, OFF with add_subdirectory.
  2. Honor BUILD_SHARED_LIBS set by the parent project. With policy CMP0077 at the old behavior, option() removes a normal variable set by the parent. So set(BUILD_SHARED_LIBS OFF) before add_subdirectory(nodeeditor) was ignored, and QtNodes was built shared. The fix sets CMP0077 to NEW. That needs CMake 3.13, so the minimum goes from 3.11 to 3.13. The docs now say that a plain set() works.

Testing

  • Qt version tested: Qt 6.12.0, macOS (Apple Clang), CMake 4.4.5
  • Existing tests still pass (761 assertions in 69 test cases, offscreen). The examples build.
  • A consumer project with a plain set(BUILD_SHARED_LIBS OFF) before add_subdirectory now builds a static libQtNodes.a. A plain set(... ON), the cache form, -DBUILD_SHARED_LIBS=OFF and no setting all behave as expected.
  • I also tried cmake --install for a shared and a static build, and find_package(QtNodes) from a consumer. Both work, and the consumer gets the right macro.
  • Not tested: CMake 3.13 to 3.15 themselves, Windows, Qt 5. The docs were not built (Sphinx is not installed). CI covers Linux, macOS and Windows.

Breaking changes?

No API change. Two points for the release notes:

  • The minimum CMake version is now 3.13. Qt 6 needs CMake 3.16 anyway.
  • A parent project that already had set(BUILD_SHARED_LIBS OFF) got a shared QtNodes without knowing. It now gets a static one, as documented.

Related issue

Related to #409 and #256 (both closed).

Describe BUILD_SHARED_LIBS, the NODE_EDITOR_* definitions that the
library sets, and why users must not define them. Note that Qt stays
a dependency and that a plain set() does not reach add_subdirectory.
Fix the BUILD_TESTING and BUILD_EXAMPLES defaults. Add an FAQ entry.
With policy CMP0077 at the old behavior, option() removes a normal
variable set by the parent. So set(BUILD_SHARED_LIBS OFF) before
add_subdirectory was ignored, and QtNodes was built shared.

Set CMP0077 to NEW. This needs CMake 3.13, so raise the minimum from
3.11 to 3.13. This is safe: Qt 6 needs CMake 3.16 anyway.

Update the CMake version in README.rst and docs. Update the docs to say
that a plain set() works.
@paceholder
paceholder merged commit df77c3d into master Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant