Skip to content

Commit 946e73c

Browse files
mcoliverCopilot
andauthored
build: SG-42130: XCode26 support (#1091)
### [ 1090: Build with Xcode26 ] ### Linked issues Fixes #1090 ### Summarize your change. Backported a patch to Qt 6.5.3 and 6.8.3 which are the community versions available and do not have the patch in commercial versions ### Describe the reason for the change. Want to build with Xcode26. Was annoying to constantly have to switch with xcode-select. Additionally xcode26 should bring some compiler optimizations that may improve performance. ### Describe what you have tested and on which operating system. macos26.2 with Xcode26.2. RV CY2025 --------- Signed-off-by: Michael Oliver <mcoliver@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f3c38ee commit 946e73c

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

apply_qt_fix.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
# This script applies a patch to fix an issue in
4+
# Qt versions 6.5.3 and 6.8.3 that require AGL when
5+
# Xcode26 no longer includes it.
6+
#
7+
# The script requires the QT_HOME environment variable to be set to the directory
8+
# where your Qt versions are installed.
9+
#
10+
# References:
11+
# https://qt-project.atlassian.net/browse/QTBUG-137687
12+
# https://github.com/qt/qtbase/commit/cdb33c3d5621ce035ad6950c8e2268fe94b73de5
13+
# https://github.com/Homebrew/homebrew-core/commit/9ef09378761c7d975da890566451726fba53ea51
14+
15+
if [[ "$(uname)" != "Darwin" ]]; then
16+
echo "Error: This script is only intended for macOS (Darwin)."
17+
exit 1
18+
fi
19+
20+
if [ -z "$QT_HOME" ]; then
21+
echo "Error: QT_HOME environment variable is not set."
22+
echo "Please set it to your Qt installation directory (e.g., /Users/moliver/Qt)."
23+
exit 1
24+
fi
25+
26+
if [ ! -d "$QT_HOME" ]; then
27+
echo "Error: QT_HOME directory '$QT_HOME' does not exist."
28+
exit 1
29+
fi
30+
31+
PATCH_FILE="$(dirname "$0")/qt_fix.patch"
32+
33+
if [ ! -f "$PATCH_FILE" ]; then
34+
echo "Error: Patch file not found at '$PATCH_FILE'."
35+
exit 1
36+
fi
37+
38+
QT_VERSIONS=("6.5.3" "6.8.3")
39+
40+
for version in "${QT_VERSIONS[@]}"; do
41+
QT_DIR="$QT_HOME/$version/macos"
42+
if [ -d "$QT_DIR" ]; then
43+
echo "Checking Qt version $version in $QT_DIR..."
44+
45+
FIND_MODULE="$QT_DIR/lib/cmake/Qt6/FindWrapOpenGL.cmake"
46+
MAC_CONF="$QT_DIR/mkspecs/common/mac.conf"
47+
48+
# Ensure expected Qt files exist before proceeding
49+
if [ ! -f "$FIND_MODULE" ] || [ ! -f "$MAC_CONF" ]; then
50+
echo "Warning: Required Qt files not found for version $version. Skipping."
51+
continue
52+
fi
53+
54+
# Check if patch is already applied:
55+
# - WrapOpenGL_AGL removed from FindWrapOpenGL.cmake
56+
# - -framework AGL removed from mkspecs/common/mac.conf
57+
if ! grep -q "WrapOpenGL_AGL" "$FIND_MODULE" && \
58+
! grep -q -- "-framework AGL" "$MAC_CONF"; then
59+
echo "Patch is already applied for version $version. Skipping."
60+
continue
61+
fi
62+
63+
# Check if patch applies cleanly
64+
if patch -p1 -d "$QT_DIR" --dry-run --batch < "$PATCH_FILE" >/dev/null 2>&1; then
65+
echo "Applying patch to $version..."
66+
patch -p1 -d "$QT_DIR" --batch < "$PATCH_FILE"
67+
echo "Successfully patched $version."
68+
else
69+
echo "Error: Could not apply patch for version $version. It might be incompatible or already modified."
70+
echo "Please check the files in $QT_DIR manually."
71+
# Show dry run output for debugging
72+
patch -p1 -d "$QT_DIR" --dry-run --batch < "$PATCH_FILE"
73+
fi
74+
else
75+
echo "Warning: Qt version $version not found at $QT_DIR. Skipping."
76+
fi
77+
done
78+
79+
echo "Done."

cmake/dependencies/python3.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ ELSE()
538538
ENDIF()
539539

540540
ADD_LIBRARY(Python::Python SHARED IMPORTED GLOBAL)
541+
SET_TARGET_PROPERTIES(
542+
Python::Python
543+
PROPERTIES SYSTEM FALSE
544+
)
541545
ADD_DEPENDENCIES(Python::Python ${_python3_target})
542546
SET_PROPERTY(
543547
TARGET Python::Python

docs/build_system/config_macos.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ From macOS System Settings > Privacy & Security > App Management, allow Terminal
9595

9696
## Install Xcode
9797

98-
**Heads Up:** Xcode 26 isn't supported yet because it needs the fix for [QTBUG-137687](https://bugreports.qt.io/browse/QTBUG-137687). This fix is available in Qt 6.5.10, but there isn't a PySide6 version that matches this Qt version as of now. In the meantime, you can use Xcode 16.4 on the latest macOS Tahoe 26 to build Open RV.
98+
**Heads Up:**
99+
If you are using >= Xcode 26 you will need to patch Qt 6.5.3 and 6.8.3 to implement the fix for [QTBUG-137687](https://bugreports.qt.io/browse/QTBUG-137687).
100+
101+
This patch is run during the sourcing of rvcmds.sh. You can also run it directly via `sh apply_qt_fix.sh`
102+
103+
Alternately you can use Xcode 16.4 on the latest macOS Tahoe 26 to build Open RV.
99104

100105
From the App Store, download Xcode 16.4. Make sure that it is the source of the active developer directory.
101106

qt_fix.patch

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
diff --git a/lib/cmake/Qt6/FindWrapOpenGL.cmake b/lib/cmake/Qt6/FindWrapOpenGL.cmake
2+
index 3f95561..e794e78 100644
3+
--- a/lib/cmake/Qt6/FindWrapOpenGL.cmake
4+
+++ b/lib/cmake/Qt6/FindWrapOpenGL.cmake
5+
@@ -35,16 +35,7 @@ if (OpenGL_FOUND)
6+
set(__opengl_fw_path "-framework OpenGL")
7+
endif()
8+
9+
- find_library(WrapOpenGL_AGL NAMES AGL)
10+
- if(WrapOpenGL_AGL)
11+
- set(__opengl_agl_fw_path "${WrapOpenGL_AGL}")
12+
- endif()
13+
- if(NOT __opengl_agl_fw_path)
14+
- set(__opengl_agl_fw_path "-framework AGL")
15+
- endif()
16+
-
17+
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_fw_path})
18+
- target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_agl_fw_path})
19+
else()
20+
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL)
21+
endif()
22+
diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
23+
index 303cf65..6650949 100644
24+
--- a/mkspecs/common/mac.conf
25+
+++ b/mkspecs/common/mac.conf
26+
@@ -14,8 +14,7 @@ QMAKE_LIBDIR =
27+
28+
# sdk.prf will prefix the proper SDK sysroot
29+
QMAKE_INCDIR_OPENGL = \
30+
- /System/Library/Frameworks/OpenGL.framework/Headers \
31+
- /System/Library/Frameworks/AGL.framework/Headers/
32+
+ /System/Library/Frameworks/OpenGL.framework/Headers
33+
34+
QMAKE_FIX_RPATH = install_name_tool -id
35+
36+
@@ -25,7 +24,7 @@ QMAKE_LFLAGS_GCSECTIONS = -Wl,-dead_strip
37+
QMAKE_REL_RPATH_BASE = @loader_path
38+
39+
QMAKE_LIBS_DYNLOAD =
40+
-QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL
41+
+QMAKE_LIBS_OPENGL = -framework OpenGL
42+
QMAKE_LIBS_THREAD =
43+
44+
QMAKE_INCDIR_WAYLAND =

rvcmds.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ else
153153
fi
154154
fi
155155

156+
# If on macOS and Xcode version is 26 or higher, apply the Qt AGL fix
157+
if [[ "$OSTYPE" == "darwin"* ]] && [ -n "$QT_HOME" ] && command -v xcodebuild >/dev/null 2>&1; then
158+
XCODE_MAJOR_VERSION=$(xcodebuild -version | head -n 1 | awk '{print $2}' | cut -d. -f1)
159+
if [[ -n "$XCODE_MAJOR_VERSION" && "$XCODE_MAJOR_VERSION" =~ ^[0-9]+$ && "$XCODE_MAJOR_VERSION" -ge 26 ]]; then
160+
QT_BASE_DIR="$(dirname "$(dirname "$QT_HOME")")"
161+
if [ -d "$QT_BASE_DIR" ]; then
162+
echo "Xcode 26+ detected, ensuring Qt AGL fix is applied..."
163+
QT_HOME="$QT_BASE_DIR" bash "$SCRIPT_HOME/apply_qt_fix.sh"
164+
fi
165+
fi
166+
fi
167+
156168
# Must be executed in a function as it changes the shell environment
157169
__rv_env_shell() {
158170
local activate_path=".venv/bin/activate"

0 commit comments

Comments
 (0)