From 2c0021ad89eef713d3f7a48ac1a50b3d15a46619 Mon Sep 17 00:00:00 2001 From: Zaveshaa <127344512+zaveshaa@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:34:47 +0300 Subject: [PATCH] [cmake] Fix standalone configuration of examples project (#6079) 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 --- examples/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cdc52af88..5f484eee4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,18 @@ # Setup the project and settings +cmake_minimum_required(VERSION 3.22) project(examples) +# Include raylib's cmake helper functions, so the examples can also be +# configured standalone (`cd examples && cmake .`) and not only as part +# of the raylib project. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") +include(AddIfFlagCompiles) + +# Default to the Desktop platform when configured standalone. +if (NOT DEFINED PLATFORM) + set(PLATFORM "Desktop" CACHE STRING "Platform to build examples for") +endif () + # Directories that contain examples set(example_dirs audio