| 1 |
cmake_minimum_required(VERSION 3.25) |
| 2 |
#this change avoid the warning that appear when we include raylib using Cmake fatch content |
| 3 |
project(raylib) |
| 4 |
|
| 5 |
# Avoid excessive expansion of variables in conditionals. In particular, if |
| 6 |
# "PLATFORM" is "DRM" then: |
| 7 |
# |
| 8 |
# if (${PLATFORM} MATCHES "DRM") |
| 9 |
# |
| 10 |
# may expand e.g to: |
| 11 |
# |
| 12 |
# if (/usr/lib/aarch64-linux-gnu/libdrm.so MATCHES "DRM") |
| 13 |
# |
| 14 |
# See https://cmake.org/cmake/help/latest/policy/CMP0054.html |
| 15 |
cmake_policy(SET CMP0054 NEW) |
| 16 |
|
| 17 |
# Makes a hidden visibility preset on a static lib respected |
| 18 |
# This is used to hide glfw's symbols from the library exports when building an so/dylib |
| 19 |
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html |
| 20 |
cmake_policy(SET CMP0063 NEW) |
| 21 |
|
| 22 |
# Directory for easier includes |
| 23 |
# Anywhere you see include(...) you can check <root>/cmake for that file |
| 24 |
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 25 |
|
| 26 |
# Sets compiler flags and language standard |
| 27 |
include(CompilerFlags) |
| 28 |
|
| 29 |
# Registers build options that are exposed to cmake |
| 30 |
include(CMakeOptions.txt) |
| 31 |
|
| 32 |
if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM" AND NOT "${PLATFORM}" MATCHES "Web") |
| 33 |
if (NOT GLFW_BUILD_WAYLAND AND NOT GLFW_BUILD_X11) |
| 34 |
message(FATAL_ERROR "Cannot disable both Wayland and X11") |
| 35 |
endif() |
| 36 |
endif() |
| 37 |
|
| 38 |
# Main sources directory (the second parameter sets the output directory name to raylib) |
| 39 |
add_subdirectory(src raylib) |
| 40 |
|
| 41 |
# Uninstall target, only create when building raylib by itself |
| 42 |
# Avoid conflicting target names when using raylib with other libraries |
| 43 |
if(NOT TARGET uninstall AND PROJECT_IS_TOP_LEVEL) |
| 44 |
configure_file( |
| 45 |
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Uninstall.cmake" |
| 46 |
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
| 47 |
IMMEDIATE @ONLY) |
| 48 |
|
| 49 |
add_custom_target(uninstall |
| 50 |
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) |
| 51 |
endif() |
| 52 |
|
| 53 |
if (${BUILD_EXAMPLES}) |
| 54 |
message(STATUS "Building examples is enabled") |
| 55 |
add_subdirectory(examples) |
| 56 |
endif() |
| 57 |
|
| 58 |
enable_testing() |