apple: move all event stuff into callback system, fix cmake support for apple, add gl/vk examples to cmake

This commit is contained in:
IoI_xD 2026-03-25 17:49:28 -07:00
commit 82999d716a
10 changed files with 456 additions and 318 deletions

View file

@ -15,11 +15,16 @@ option(MW_CLASSIC_THEME "Use classic theme" OFF)
option(MW_BUILD_EXAMPLES "Build examples" OFF)
option(MW_USE_STB_IMAGE "Use stb_image" ON)
option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF)
option(MW_USE_FREETYPE2 "Use FreeType 2" ON)
option(MW_BUILD_SHARED "Build a shared library" ON)
option(MW_BUILD_STATIC "Build a static library" OFF)
option(MW_INSTALL_HEADERS "Install headers" ON)
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
option(MW_USE_FREETYPE2 "Use FreeType 2" OFF)
else()
option(MW_USE_FREETYPE2 "Use FreeType 2" ON)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
option(MW_USE_WAYLAND "Enable Wayland backend" ON)
endif()
@ -47,10 +52,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
endif()
if(MW_TRY_OPENGL)
check_include_files(GL/gl.h HAVE_GL_GL_H)
if(HAVE_GL_GL_H)
find_package(OpenGL)
if(OpenGL_FOUND)
set(MW_BUILD_OPENGL ON)
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
if(APPLE)
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m")
endif()
message(STATUS "OpenGL widget has been enabled")
else()
message(WARNING "OpenGL widget has been disabled")
@ -222,6 +230,14 @@ if(MW_USE_WAYLAND)
endif()
endif()
if(APPLE AND MW_BUILD_OPENGL)
target_compile_definitions(
Mw
PRIVATE
GL_SILENCE_DEPRECATION
)
endif()
target_include_directories(
Mw
PUBLIC