Skip to content

Commit

Permalink
Fix OpenGL on macosx
Browse files Browse the repository at this point in the history
With new versions of the OS and/or the command line tools a OpenGL version
installed with brew was used which somehow doesn't work. With the change the
system version from the OpenGL framework is used.

(cherry picked from commit 87daf31)
(see #556)
  • Loading branch information
fuhlig1 authored and dennisklein committed Nov 18, 2024
1 parent 29b9d08 commit 1fc624c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/legacy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ ExternalProject_Add(root
${root_cocoa}
UPDATE_DISCONNECTED ON
PATCH_COMMAND ${patch} -p1 -i "${CMAKE_SOURCE_DIR}/legacy/root/fix_macos_sdk_mismatch.patch"
COMMAND ${patch} -p1 -i "${CMAKE_SOURCE_DIR}/legacy/root/fix_macosx_findOpenGL.patch"
DEPENDS pythia6 pythia8 vc ${extract_source_cache_target}
${LOG_TO_FILE}
)
Expand Down
32 changes: 32 additions & 0 deletions legacy/root/fix_macosx_findOpenGL.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index 682de46f27..57addbc948 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -565,6 +565,17 @@ find_package(Python3 3.8 COMPONENTS ${python_components})
#---Check for OpenGL installation-------------------------------------------------------
if(opengl)
message(STATUS "Looking for OpenGL")
+ # Search for the OpenGL installation first in the system.
+ # OpenGL installed via brew (mesa, mesa-glu) and X11 seems not to work
+ # properly so it is needed to use the system version.
+ # CMAKE_FIND_FRAMEWORK defines the search order on macosx which as
+ # default is search first for frameworks.
+ # ROOT changes the order to search last for the framework.
+ # Temporarely change the search order for OpenGL.
+ if(APPLE)
+ set(frame_temp ${CMAKE_FIND_FRAMEWORK})
+ set(CMAKE_FIND_FRAMEWORK FIRST)
+ endif()
find_package(OpenGL)
if(NOT OPENGL_FOUND OR NOT OPENGL_GLU_FOUND)
if(fail-on-missing)
@@ -574,6 +585,9 @@ if(opengl)
set(opengl OFF CACHE BOOL "Disabled because OpenGL (with GLU) not found (${opengl_description})" FORCE)
endif()
endif()
+ if (APPLE)
+ set(CMAKE_FIND_FRAMEWORK ${frame_temp})
+ endif()
endif()
# OpenGL should be working only with x11 (Linux),
# in case when -Dall=ON -Dx11=OFF, we will just disable opengl.

0 comments on commit 1fc624c

Please sign in to comment.