Skip to content

macOS: update build for Apple Silicon and Homebrew - #1453

Open
mikefsq wants to merge 16 commits into
OpenPHDGuiding:masterfrom
mikefsq:macos-build
Open

mikefsq wants to merge 16 commits into
OpenPHDGuiding:masterfrom
mikefsq:macos-build

Conversation

@mikefsq

@mikefsq mikefsq commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Update the PHD2 build process to build an Apple Silicon binary (or a universal binary if all of the dependencies are also universal binaries). This adds support for linking against the library versions installed by a current homebrew toolchain. Note that this preserves the existing linking behavior which on osx only finds static dependencies, so a homebrew user will now see an error message to set PHD_MACOS_STATIC_DEPS off.

Two reported bugs are also addressed by this update:

Changes:

  • run_cmake-osx: default CMAKE_OSX_ARCHITECTURES to the host arch ($(uname -m)) instead of hardcoded x86_64; override APPLE_ARCH for a universal build.

  • thirdparty.cmake: add PHD_MACOS_STATIC_DEPS (default ON) to choose static cfitsio/libnova for a self-contained bundle vs shared libs (e.g. Homebrew); emit a clear message when a static lib is missing.

  • thirdparty.cmake: link zlib where the static INDI client is linked (it needs uncompress for BLOBs) via find_package(ZLIB).

  • thirdparty.cmake: recover the Eigen include dir from the Eigen3::Eigen target when EIGEN3_INCLUDE_DIR is unset (config-only Eigen 3.4+).

  • thirdparty.cmake: SBIG off by default (no arm64 driver), SVB and ogmacam point at universal/arm64 lib paths, non-fatal skips so universal/arm64 builds still configure.

  • CMakeLists.txt: define wxNO_REQUIRE_LITERAL_MSGIDS for wxWidgets >= 3.3.

  • ship universal (arm64+x86_64) libASICamera2 and libqhyccd dylibs.

mikefsq added 14 commits June 14, 2026 11:39
Make PHD2 build cleanly on Apple Silicon and against an up-to-date
Homebrew toolchain, while keeping the existing static/release build path.

- run_cmake-osx: default CMAKE_OSX_ARCHITECTURES to the host arch
  ($(uname -m)) instead of hardcoded x86_64; override APPLE_ARCH for a
  universal build.
- thirdparty.cmake: add PHD_MACOS_STATIC_DEPS (default ON) to choose
  static cfitsio/libnova for a self-contained bundle vs shared libs
  (e.g. Homebrew); emit a clear message when a static lib is missing.
- thirdparty.cmake: link zlib where the static INDI client is linked
  (it needs uncompress for BLOBs) via find_package(ZLIB).
- thirdparty.cmake: recover the Eigen include dir from the Eigen3::Eigen
  target when EIGEN3_INCLUDE_DIR is unset (config-only Eigen 3.4+).
- thirdparty.cmake: SBIG off by default (no arm64 driver), SVB and
  ogmacam point at universal/arm64 lib paths, non-fatal skips so
  universal/arm64 builds still configure.
- CMakeLists.txt: define wxNO_REQUIRE_LITERAL_MSGIDS for wxWidgets >= 3.3.
- ship universal (arm64+x86_64) libASICamera2 and libqhyccd dylibs.
@MichaelJEvan

Copy link
Copy Markdown
Contributor

Tested this PR on Apple silicon: builds native and guides on the simulator.

Machine

  • Apple M5 Max (Mac17,7), 128 GB, macOS 26.6.2 (25G83)
  • Xcode clang 21.0.0, cmake 4.4.3
  • PR head dfc8d55 (2.6.13dev8), 13 commits behind master

Build

  1. build/build-macdeps: OK, 1 min 43 s. wxWidgets 3.2.11, cfitsio 4.6.4, libnova 0.16, Eigen 3.4.0, all static in tmp_macdeps.
  2. build/build-mac: OK, 1 min 25 s. check_library_dependencies passed, ctest 4 of 4 passed.
  3. PHD2 is arm64. Bundled ASICamera2, PlayerOneCamera, ogmacam, qhyccd and toupcam are universal (x86_64 arm64); libusb_openphd is arm64.
  4. Footprint 124 MB after the guiding run.

Simulator (Simulator camera + On-camera mount, 3.75 µm, 240 mm, driven through the event server)

  1. Connect, calibrate (9 steps each axis, no advisory), guide, settle: OK.
  2. 180 s guiding: 169 guide steps, star never lost, RMS 0.12 px RA / 0.18 px Dec (0.39" / 0.58").
  3. Dither 5 px + settle, pause/resume, get_star_image, stop, disconnect: OK.
  4. flip_calibration twice gives back the original calibration.

Notes

  1. build-macdeps requires glibtoolize (Homebrew's name). With GNU libtool installed as libtoolize the check fails although autoreconf would work; I linked glibtoolize to it. Accepting either name would help.
  2. The zip is still named PHD2-2.6.13dev8-OSX-64-sonoma+.zip; it does not say it is arm64-only.
  3. A first profile without a pixel size (focal length 500) gave simulator stars of about 1.4 px HFD, under the default minimum of 1.5 px, so many frames were dropped. Min HFD 1.0 fixed it. Probably not this PR, not checked on an Intel build.
  4. Not tested: real cameras, mounts, INDI, a universal build, signing.

Separate from this PR: run_phd2_macos ends with exec "$HERE"/PHD2 without "$@", so open -a PHD2.app --args -i 2 loses its arguments and a second instance cannot be started that way. Running PHD2.app/Contents/MacOS/PHD2 -i 2 directly works. Same line on master.

@MichaelJEvan

Copy link
Copy Markdown
Contributor

Follow-up: INDI on the same build (PR head dfc8d55, arm64).

Setup

  • indiserver 2.2.2, native arm64: Telescope Simulator + Guide Simulator (1280x1024, 2.4 µm, 240 mm; its default drift, 6" seeing, 3" PE over 120 s).
  • Stars for the simulator from a local GSC stand-in (Gaia, mag <= 10).

Result

  1. Connect, calibrate (12 steps West, then North, no advisory), guide, settle: OK.
  2. 180 s guiding: 163 guide steps, star never lost, RMS 0.17 px RA / 0.13 px Dec (0.35" / 0.27").
  3. Dither 5 px + settle, pause/resume, get_star_image, stop, flip_calibration twice, disconnect: OK.

Found, not from this PR: with CCD_COMPRESSION on, INDI 2.2.2 sends frames as .fits.fz (fpack). cam_indi.cpp only accepts .fits, so PHD2 shows "Unknown image format: .fits.fz" and capture stops. Same lines on master. Because this INDI version compresses with fpack, I could not exercise the PR's zlib path.

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.

2 participants