Fix headless builds on macOS and Windows - #3826
Conversation
The include is not referenced anywhere in src/sound/coreaudio-mac/ and breaks CONFIG+=headless builds on macOS, where the widgets module is not available. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGdLtGxMrbExBFG3aReNAH
The #ifdef _WIN32 block runs in headless builds too, but <QApplication> is only included when HEADLESS is not defined, so headless Windows builds fail to compile. applicationDirPath() is a static inherited from QCoreApplication, so this is behavior-neutral in GUI builds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGdLtGxMrbExBFG3aReNAH
A third headless-on-macOS gap, found once the sound.h fix let the headless build reach the link stage: main.cpp calls qt_set_sequence_auto_mnemonic() unconditionally on Q_OS_MACOS, but the symbol only resolves when QtWidgets is linked -- so a plain CONFIG+=headless build fails at link time with "symbol(s) not found for architecture arm64". Menu-accelerator mnemonics are meaningless without a GUI, so gate both the extern declaration and the call site behind !defined(HEADLESS) as well. mac/activity.h and the CActivity app-nap-prevention machinery stay unconditional for macOS -- headless servers/clients still want nap prevention, only the mnemonic bits are GUI-only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGdLtGxMrbExBFG3aReNAH
There was a problem hiding this comment.
Pull request overview
This PR fixes CONFIG+=headless builds on macOS and Windows by removing/guarding GUI-only Qt usage so headless targets compile and link consistently across platforms.
Changes:
- Removed an unnecessary
QMessageBoxinclude from the macOS CoreAudio sound header to avoid QtWidgets dependency in headless builds. - Guarded macOS mnemonic-key enabling (
qt_set_sequence_auto_mnemonic) so it’s not referenced in headless builds. - Switched Windows
applicationDirPath()usage fromQApplicationtoQCoreApplicationso headless builds don’t requireQApplication.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/sound/coreaudio-mac/sound.h | Drops a QtWidgets header include that breaks headless compilation on macOS. |
| src/main.cpp | Avoids QtWidgets-only symbols/types in headless builds on macOS/Windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ann0see
left a comment
There was a problem hiding this comment.
macOS works fine. Needed to compile it twice - probably it didn't create qrc_qmake_qmake_qm_files.cpp first, but not part of this PR...
error: Build input file cannot be found: '/private/tmp/jamulus/qrc_qmake_qmake_qm_files.cpp'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? (in target 'Jamulus' from project 'Jamulus')
|
MY LLM WROTE: this comment. I asked it to test this branch on hardware I had available and report the result. Tested this branch on the legacy macOS toolchain the official release CI still uses for the "MacOS Legacy" leg: Xcode 14.2 Command Line Tools + Qt 5.15.2 (x86_64, via Result: clean build, no So this fix also holds on Qt5/x86_64, not just Qt6/arm64 — a combination neither CI nor this branch had been exercised on before. |
ann0see
left a comment
There was a problem hiding this comment.
After this has been run on Windows once I'm inclined to approve and merge this.
|
Might be the weekend before I get to try anything on my Windows box. |
Short description of changes
Three one-line fixes so that
CONFIG+=headlesscompiles (and links) on macOS and Windows, as it already does on Linux.CHANGELOG: Build: Fixed headless builds (
CONFIG+=headless) not compiling on macOS and Windows.Context: Fixes an issue?
Fixes: #3825
Does this change need documentation? What needs to be documented and how?
No.
Status of this Pull Request
Working implementation, CI-verified..
What is missing until this pull request can be merged?
Nothing known.
fatal error: 'QMessageBox' file not found, thenUndefined symbols … qt_set_sequence_auto_mnemonic(bool)error C2027: use of undefined type 'QApplication'Checklist
AUTOBUILD: Please build all targets