From e1efefb7f478d6866903346d4870095db10871bd Mon Sep 17 00:00:00 2001 From: Zaveshaa <127344512+zaveshaa@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:19:56 +0300 Subject: [PATCH] [cmake] Propagate Cocoa backend frameworks to consumers of static raylib on macOS (#6086) * [cmake] Fix standalone configuration of examples project Configuring examples/ as a standalone project (cd examples && cmake .) failed with 'Unknown CMake command add_if_flag_compiles' and a missing cmake_minimum_required() error on CMake 4.x. - Add cmake_minimum_required(VERSION 3.22), matching the root project - Include raylib's AddIfFlagCompiles helper via ../cmake - Default PLATFORM to Desktop when not inherited from the raylib build * [cmake] Propagate Cocoa backend frameworks to consumers of static raylib on macOS Bundled GLFW links '-framework Cocoa/IOKit/QuartzCore' privately, and the static-install export block removes glfw from the exported dependencies. As a result the installed CMake package only carried OpenGL.framework, and linking any consumer of libraylib.a failed with undefined Objective-C symbols (_objc_retain etc.). Append the three frameworks to the static install interface when the bundled GLFW is used, so installed consumers get a complete link line. * Gate macOS Cocoa framework propagation to the Desktop platform --- src/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdf3207f3..25b61734d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,6 +114,20 @@ if (NOT BUILD_SHARED_LIBS) if (NOT glfw3_FOUND) list(REMOVE_ITEM raylib_install_private_libs glfw) + + # Bundled GLFW links its Cocoa backend frameworks privately, so they + # must be propagated to consumers of the static library, whose final + # link line would otherwise miss them. Only the Desktop platform uses + # bundled GLFW; other platforms (e.g. Memory) have no Cocoa/GLFW symbols. + if (APPLE AND PLATFORM STREQUAL "Desktop") + find_library(COCOA_FRAMEWORK Cocoa) + find_library(IOKIT_FRAMEWORK IOKit) + find_library(QUARTZCORE_FRAMEWORK QuartzCore) + list(APPEND raylib_install_private_libs + ${COCOA_FRAMEWORK} + ${IOKIT_FRAMEWORK} + ${QUARTZCORE_FRAMEWORK}) + endif () endif() foreach(lib IN LISTS raylib_install_private_libs)