[cmake] Fix standalone configuration of examples project - #6079
Open
zaveshaa wants to merge 1 commit into
Open
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
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.
Problem
Configuring the examples as a standalone project currently fails:
Two causes:
add_if_flag_compiles()is defined incmake/AddIfFlagCompiles.cmake, which is only included by the root project — never when examples are configured on their owncmake_minimum_required()in this file, which is a hard error on CMake 4.xFix
cmake_minimum_required(VERSION 3.22), matching the root project../cmaketoCMAKE_MODULE_PATHand includeAddIfFlagCompiles, so the pthread/c11 flag checks work standalonePLATFORMtoDesktopwhen it isn't inherited from a parent raylib buildVerification (macOS 15, Intel, Apple clang 14)
cmake ..fails withUnknown CMake command "add_if_flag_compiles"-DBUILD_EXAMPLES=ONstill configures and builds examples correctlyNote: after this fix, standalone configure succeeds but linking against an installed static raylib fails on macOS because the installed CMake package only propagates
OpenGL.framework(Cocoa/IOKitare missing). That looks like a separate pre-existing issue — happy to file/fix it next if confirmed.