| 1 |
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+ |
| 2 |
project(example) |
| 3 |
|
| 4 |
# Generate compile_commands.json |
| 5 |
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 6 |
|
| 7 |
# Dependencies |
| 8 |
set(RAYLIB_VERSION 6.0) |
| 9 |
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED |
| 10 |
if (NOT raylib_FOUND) # If there's none, fetch and build raylib |
| 11 |
include(FetchContent) |
| 12 |
FetchContent_Declare( |
| 13 |
raylib |
| 14 |
DOWNLOAD_EXTRACT_TIMESTAMP OFF |
| 15 |
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz |
| 16 |
) |
| 17 |
FetchContent_GetProperties(raylib) |
| 18 |
if (NOT raylib_POPULATED) # Have we downloaded raylib yet? |
| 19 |
set(FETCHCONTENT_QUIET NO) |
| 20 |
FetchContent_MakeAvailable(raylib) |
| 21 |
endif() |
| 22 |
endif() |
| 23 |
|
| 24 |
# Our Project |
| 25 |
|
| 26 |
add_executable(${PROJECT_NAME} core_basic_window.c) |
| 27 |
#set(raylib_VERBOSE 1) |
| 28 |
target_link_libraries(${PROJECT_NAME} raylib) |
| 29 |
|
| 30 |
# Web Configurations |
| 31 |
if (${PLATFORM} STREQUAL "Web") |
| 32 |
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html") # Tell Emscripten to build an example.html file. |
| 33 |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1") |
| 34 |
endif() |
| 35 |
|
| 36 |
# Checks if OSX and links appropriate frameworks (Only required on MacOS) |
| 37 |
if (APPLE) |
| 38 |
target_link_libraries(${PROJECT_NAME} "-framework IOKit") |
| 39 |
target_link_libraries(${PROJECT_NAME} "-framework Cocoa") |
| 40 |
target_link_libraries(${PROJECT_NAME} "-framework OpenGL") |
| 41 |
endif() |