From d94e24f63a305a28ac7ae3627edc3a636338991f Mon Sep 17 00:00:00 2001 From: Luka Jankovic Date: Wed, 2 Jul 2025 17:41:48 +0200 Subject: [PATCH] cmake option to download raylib --- CMakeLists.txt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5647d93..f6eb3a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,28 @@ project(kubo LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(RAYLIB_VERSION 5.5) -find_package(raylib ${RAYLIB_VERSION} REQUIRED) +option(USE_SYSTEM_RAYLIB "Use system-installed raylib instead of downloading" OFF) + +if(USE_SYSTEM_RAYLIB) + set(RAYLIB_VERSION 5.5) + find_package(raylib ${RAYLIB_VERSION} REQUIRED) +else() + include(FetchContent) + set(FETCHCONTENT_QUIET FALSE) + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples + set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games + set(GLFW_BUILD_WAYLAND "Build the bundled GLFW with Wayland support" ON) + set(GLFW_BUILD_X11 "Build the bundled GLFW with X11 support" ON) + + FetchContent_Declare( + raylib + GIT_REPOSITORY "https://github.com/raysan5/raylib.git" + GIT_TAG "master" + GIT_PROGRESS TRUE + ) + + FetchContent_MakeAvailable(raylib) +endif() set(SOURCES kubo_command.c