Currently, when building, the cmake example in projects/CMake gives this warning, with CMake 3.30.2 CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1953 (message): Calling FetchContent_Populate(raylib) is deprecated, call FetchContent_MakeAvailable(raylib) instead. Policy CMP0169 can be set to OLD to allow FetchContent_Populate(raylib) to be called directly for now, but the ability to call it with declared details will be removed completely in a future version. Call Stack (most recent call first): CMakeLists.txt:20 (FetchContent_Populate) This warning is for project developers. Use -Wno-dev to suppress it. Changing FetchContent_Populate to FetchContent_MakeAvailable didn't cause any issues I could observe when building. I'm not sure why it wasn't like that to begin with.
42 lines
1.4 KiB
CMake
42 lines
1.4 KiB
CMake
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
|
|
project(example)
|
|
|
|
# Generate compile_commands.json
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# Dependencies
|
|
set(RAYLIB_VERSION 5.5)
|
|
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
|
|
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
raylib
|
|
DOWNLOAD_EXTRACT_TIMESTAMP OFF
|
|
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
|
|
)
|
|
FetchContent_GetProperties(raylib)
|
|
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
|
set(FETCHCONTENT_QUIET NO)
|
|
FetchContent_MakeAvailable(raylib)
|
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
|
|
endif()
|
|
endif()
|
|
|
|
# Our Project
|
|
|
|
add_executable(${PROJECT_NAME} core_basic_window.c)
|
|
#set(raylib_VERBOSE 1)
|
|
target_link_libraries(${PROJECT_NAME} raylib)
|
|
|
|
# Web Configurations
|
|
if (${PLATFORM} STREQUAL "Web")
|
|
# Tell Emscripten to build an example.html file.
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html")
|
|
endif()
|
|
|
|
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
|
if (APPLE)
|
|
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
|
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
|
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
|
endif()
|