macOS: Disable OpenGL 1.x on newer macOS

This commit is contained in:
Vicki Pfau 2022-06-26 01:44:09 -07:00
parent bf3d31b24e
commit e1c43b9287
4 changed files with 16 additions and 10 deletions

View File

@ -235,6 +235,7 @@ elseif(UNIX)
endif() endif()
if(APPLE) if(APPLE)
execute_process(COMMAND xcrun --show-sdk-version OUTPUT_VARIABLE MACOSX_SDK)
add_definitions(-D_DARWIN_C_SOURCE) add_definitions(-D_DARWIN_C_SOURCE)
list(APPEND OS_LIB "-framework Foundation") list(APPEND OS_LIB "-framework Foundation")
if(NOT CMAKE_SYSTEM_VERSION VERSION_LESS "10.0") # Darwin 10.x is Mac OS X 10.6 if(NOT CMAKE_SYSTEM_VERSION VERSION_LESS "10.0") # Darwin 10.x is Mac OS X 10.6
@ -413,7 +414,7 @@ endif()
if(BUILD_GL) if(BUILD_GL)
find_package(OpenGL QUIET) find_package(OpenGL QUIET)
if(NOT OPENGL_FOUND) if(NOT OPENGL_FOUND OR (APPLE AND MACOSX_SDK VERSION_GREATER 10.14))
set(BUILD_GL OFF CACHE BOOL "OpenGL not found" FORCE) set(BUILD_GL OFF CACHE BOOL "OpenGL not found" FORCE)
elseif(UNIX AND NOT APPLE AND TARGET OpenGL::GL) elseif(UNIX AND NOT APPLE AND TARGET OpenGL::GL)
set(OPENGL_LIBRARY OpenGL::GL) set(OPENGL_LIBRARY OpenGL::GL)
@ -430,6 +431,11 @@ if(NOT BUILD_GL AND NOT LIBMGBA_ONLY)
endif() endif()
if(BUILD_GLES2 AND NOT BUILD_GL) if(BUILD_GLES2 AND NOT BUILD_GL)
if(APPLE AND MACOSX_SDK VERSION_GREATER 10.14)
find_package(OpenGL QUIET)
set(OPENGLES2_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
set(OPENGLES2_LIBRARY ${OPENGL_LIBRARY})
endif()
find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h) find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h)
find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM) find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM)
if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY) if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY)
@ -443,6 +449,11 @@ if(BUILD_GLES2)
endif() endif()
if(BUILD_GLES3 AND NOT BUILD_GL) if(BUILD_GLES3 AND NOT BUILD_GL)
if(APPLE AND MACOSX_SDK VERSION_GREATER 10.14)
find_package(OpenGL QUIET)
set(OPENGLES3_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
set(OPENGLES3_LIBRARY ${OPENGL_LIBRARY})
endif()
find_path(OPENGLES3_INCLUDE_DIR NAMES GLES3/gl3.h) find_path(OPENGLES3_INCLUDE_DIR NAMES GLES3/gl3.h)
find_library(OPENGLES3_LIBRARY NAMES GLESv3 GLESv2) find_library(OPENGLES3_LIBRARY NAMES GLESv3 GLESv2)
if(NOT OPENGLES3_INCLUDE_DIR OR NOT OPENGLES3_LIBRARY) if(NOT OPENGLES3_INCLUDE_DIR OR NOT OPENGLES3_LIBRARY)

View File

@ -20,14 +20,12 @@ CXX_GUARD_START
#ifdef USE_EPOXY #ifdef USE_EPOXY
#include <epoxy/gl.h> #include <epoxy/gl.h>
#elif defined(BUILD_GL) #elif defined(__APPLE__)
#ifdef __APPLE__
#include <OpenGL/gl3.h> #include <OpenGL/gl3.h>
#else #elif defined(BUILD_GL)
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
#endif
#else #else
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#endif #endif

View File

@ -12,14 +12,12 @@ CXX_GUARD_START
#ifdef USE_EPOXY #ifdef USE_EPOXY
#include <epoxy/gl.h> #include <epoxy/gl.h>
#elif defined(BUILD_GL) #elif defined(__APPLE__)
#ifdef __APPLE__
#include <OpenGL/gl3.h> #include <OpenGL/gl3.h>
#else #elif defined(BUILD_GL)
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
#endif
#elif defined(BUILD_GLES3) #elif defined(BUILD_GLES3)
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#else #else

View File

@ -39,7 +39,6 @@ if(NOT ${QT}Widgets_FOUND)
endif() endif()
if(APPLE) if(APPLE)
execute_process(COMMAND xcrun --show-sdk-version OUTPUT_VARIABLE MACOSX_SDK)
if(MACOSX_SDK VERSION_GREATER 10.14) if(MACOSX_SDK VERSION_GREATER 10.14)
list(APPEND QT_DEFINES USE_SHARE_WIDGET) list(APPEND QT_DEFINES USE_SHARE_WIDGET)
endif() endif()