[cmake] Propagate Cocoa backend frameworks to consumers of static raylib on macOS - #6086
Open
zaveshaa wants to merge 2 commits into
Open
[cmake] Propagate Cocoa backend frameworks to consumers of static raylib on macOS#6086zaveshaa wants to merge 2 commits into
zaveshaa wants to merge 2 commits into
Conversation
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
…lib 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6080
Problem
When raylib is built as a static library and consumed via
find_package(raylib)on macOS, linking fails with undefined Objective-C symbols:Root cause chain:
Cocoa,IOKit,QuartzCore) as PRIVATEsrc/CMakeLists.txtremovesglfwfrom exported dependencies (correct — its symbols are inside the archive)OpenGL.frameworkFix
In the static-only export block, when the bundled GLFW is used on
APPLE, append the same three frameworks GLFW's Cocoa backend declares, resolved viafind_library(). Shared builds are untouched (the block is guarded byNOT BUILD_SHARED_LIBS).Verification (macOS 15, Intel, Apple clang 14)
Full standalone flow, before → after:
cd examples && cmake .. -DCMAKE_PREFIX_PATH=<stage>make core_basic_windowRepro script:
Note: this PR depends on #6079 for the examples to configure standalone; the library-side fix here is independent.