From a766c48e83dd8288b6a776c41c0e0c050e92ebe0 Mon Sep 17 00:00:00 2001 From: Olaf <8780533+OlafRocket@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:44:49 +0100 Subject: [PATCH] Ignore XQuartz prefixes in find_package() on macOS XQuartz installs a Mesa libGL/libGLU plus GL/gl.h under /opt/X11, reachable as /usr/X11 and /usr/X11R6, both of which CMake searches by default via CMAKE_SYSTEM_PREFIX_PATH. CMake's FindOpenGL accepts those names on APPLE, and the vcpkg toolchain sets CMAKE_FIND_FRAMEWORK=LAST, so an installed XQuartz wins over OpenGL.framework and the build picks up Mesa headers and libraries instead of the system ones. The same prefixes also shadow freetype, png and friends, so ignore them wholesale. Signed-off-by: Olaf <8780533+OlafRocket@users.noreply.github.com> --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10fa0f481..8c719fb5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,12 @@ set(XSTUDIO_GLOBAL_NAME xStudio) project(${XSTUDIO_GLOBAL_NAME} VERSION ${XSTUDIO_GLOBAL_VERSION} LANGUAGES CXX) +# XQuartz's Mesa libGL under /opt/X11 shadows OpenGL.framework, so keep it off the search path. +if(APPLE) + list(APPEND CMAKE_IGNORE_PREFIX_PATH /opt/X11 /usr/X11 /usr/X11R6) + list(REMOVE_DUPLICATES CMAKE_IGNORE_PREFIX_PATH) +endif() + # Work around Qt bug: FindWrapOpenGL.cmake links -framework AGL, which was # removed from the macOS SDK in 10.14. Fixed upstream in Qt 6.9+ but not # backported to 6.5/6.8 LTS (see https://codereview.qt-project.org/c/qt/qtbase/+/652022).