CMake: Project template fix to easily target raylib version

This commit is contained in:
Rob Loach 2022-09-17 14:48:01 -04:00
parent c328f09efc
commit 433fea45c2
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A

View File

@ -5,12 +5,13 @@ project(example)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Dependencies # Dependencies
find_package(raylib 4.2.0 QUIET) # QUIET or REQUIRED set(RAYLIB_VERSION 4.2.0)
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
if (NOT raylib_FOUND) # If there's none, fetch and build raylib if (NOT raylib_FOUND) # If there's none, fetch and build raylib
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
raylib raylib
URL https://github.com/raysan5/raylib/archive/refs/tags/4.0.0.tar.gz URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
) )
FetchContent_GetProperties(raylib) FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet? if (NOT raylib_POPULATED) # Have we downloaded raylib yet?