Skip to content

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented Sep 18, 2025

This PR modernizes how the generator discovers Qt headers/frameworks and vendors a newer simplecpp with framework-aware search logic. Together these changes make builds robust on macOS (Qt frameworks) and cleaner across all platforms.

Vendor simplecpp update

  • Bumps generator/simplecpp/{simplecpp.h, simplecpp.cpp} to patched-2025-08-30-37fa4f49b (upstream: commontk/simplecpp@bfc53ad; previously danmar/simplecpp@37fa4f4).

  • Re-applies local patch: generator/simplecpp/do_not_stop_on_error.patch.

  • Introduces a typed, ordered search path API:

    • DUI::PathKind { Include, SystemInclude, Framework, SystemFramework }
    • DUI::searchPaths plus helpers addIncludePath, addSystemIncludePath, addFrameworkPath, addSystemFrameworkPath
    • Back-compat: if searchPaths is empty, legacy includePaths is mirrored as Include.
  • Adds Apple framework resolution for #include <Pkg/Hdr.h><Pkg.framework/Headers/Hdr.h> (and PrivateHeaders fallback).

  • Interleaves -I and -F in the original CLI order; handles -isystem and -iframework.

Upstream compare: commontk/simplecpp@37fa4f4...bfc53ad

Note

This changes are vendored from the commontk/simplecpp fork including commit backported from:

Generator: discover Qt headers via QLibraryInfo

  • Prefers QLibraryInfo::HeadersPath; falls back to $QTDIR/include if needed.

  • Accepts include roots from:

    • PYTHONQT_INCLUDE (path list; validated)
    • --include-paths (validated)
  • Probes and appends existing module subdirs under the Qt include root: QtCore, QtGui, QtNetwork, QtOpenGL, QtXml.

  • Starts using DUI::addIncludePath(...) instead of pushing to the legacy includePaths.

  • Removes hardcoded macOS /Library/Frameworks/.../Headers assumptions (to defer to new framework discovery).

Generator: discover Qt framework paths dynamically (macOS)

  • New getFrameworkDirectories(...) collects framework/library search roots from:

    • . (cwd)
    • PYTHONQT_FRAMEWORK (validated)
    • --framework-paths (validated)
    • ${QTDIR}/lib/<Module>.framework when present, plus ${QTDIR}/lib
    • QLibraryInfo::LibrariesPath when available
  • Passes these paths to the preprocessor using DUI::addFrameworkPath(...).

Generator: detect Qt version from frameworks on macOS

  • getQtVersion(...) now accepts either header include directories or framework roots.
  • On macOS, probes Versions/A/Headers/qtcoreversion.h when given a framework root (e.g., .../QtCore.framework).
  • Tries include paths first, then framework paths; aborts early with a clear error message if neither yields a version.

This pull request supersedes the following ones:


This pull request fixes the following issues:

@jcfr
Copy link
Contributor Author

jcfr commented Sep 18, 2025

@jamesobutler Now this has been proposed upstream, we will be able to contribute CMakeLists.txt changes including Qt6 support, along with finalizing CTK & Slicer Qt updates 🚀

@jcfr
Copy link
Contributor Author

jcfr commented Sep 18, 2025

@mrbean-bremen Thanks for the review 🙏 I will revisit and update shortly 🚀

…a4f49b (bfc53ad); was master (37fa4f4)

Upstream: commontk/simplecpp@bfc53ad
Source date: 2025-08-30
Files:   generator/simplecpp/simplecpp.h, generator/simplecpp/simplecpp.cpp
Patch:   generator/simplecpp/do_not_stop_on_error.patch re-applied

Compare: commontk/simplecpp@37fa4f4...bfc53ad
@jcfr jcfr force-pushed the update-simplecpp-apple-framework-support branch from 4c7ea5a to 9a945d4 Compare September 19, 2025 02:22
- Prefer `QLibraryInfo::{HeadersPath}` to locate Qt headers; fall back to
  `$QTDIR/include` when `QLibraryInfo` is unavailable or invalid.
- Accept include roots from `PYTHONQT_INCLUDE` and `--include-paths`; warn
  and skip non-existent paths; normalize with `QDir::cleanPath`.
- Probe module subdirs under the Qt include root and append those that
  exist (QtCore, QtGui, QtNetwork, QtOpenGL, QtXml).
- Use `DUI::addIncludePath(...)` instead of pushing to `includePaths`.
- Minor cleanups: Use QStringLiteral, add helpers for path joining/dir checks.

Remove hardcoded macOS `/Library/Frameworks` header paths from the QTDIR-missing
branch anticipating the addition of `getFrameworkDirectories` function.
@jcfr jcfr force-pushed the update-simplecpp-apple-framework-support branch from 9a945d4 to b330ba7 Compare September 19, 2025 02:29
jcfr and others added 4 commits September 19, 2025 01:49
… PYTHONQT_FRAMEWORK

Add `getFrameworkDirectories` to collect framework/library search roots from:
- `.` (cwd),
- `PYTHONQT_FRAMEWORK` (path-list, validated),
- `--framework-paths` CLI arg (validated),
- `${QTDIR}/lib/<Module>` when present, plus `${QTDIR}/lib`.

Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu>
- Extend Qt version discovery to accept framework roots (e.g.,
  .../QtCore.framework) in addition to include dirs.
- On macOS, also probe `Versions/A/Headers/qtcoreversion.h`.
- Try include paths first, then framework paths; abort with a clear
  error if neither yields a version.

Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu>
This improves header file detection on macOS by introducing support for
additional common paths where `qtcoreversion.h` might be located. This
change enhances compatibility with different Qt installations.
@jcfr jcfr force-pushed the update-simplecpp-apple-framework-support branch from 9689614 to dd42ec8 Compare September 19, 2025 05:50
@jcfr
Copy link
Contributor Author

jcfr commented Sep 19, 2025

@mrbean-bremen This now ready for final review & integration 🙏 🚀

Copy link
Contributor

@mrbean-bremen mrbean-bremen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice - thank you!

@mrbean-bremen mrbean-bremen merged commit 57688f5 into MeVisLab:master Sep 19, 2025
19 checks passed
@jcfr jcfr deleted the update-simplecpp-apple-framework-support branch September 19, 2025 07:09
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.

Qt6 on macos: missing generated_cpp
2 participants