2023-12-15 21:17:44 +03:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2021-01-14 01:10:02 +03:00
|
|
|
project(raylib)
|
|
|
|
|
2022-08-09 10:52:56 +03:00
|
|
|
# Avoid excessive expansion of variables in conditionals. In particular, if
|
2023-11-28 22:43:45 +03:00
|
|
|
# "PLATFORM" is "DRM" then:
|
2022-08-09 10:52:56 +03:00
|
|
|
#
|
|
|
|
# if (${PLATFORM} MATCHES "DRM")
|
|
|
|
#
|
|
|
|
# may expand e.g to:
|
|
|
|
#
|
|
|
|
# if (/usr/lib/aarch64-linux-gnu/libdrm.so MATCHES "DRM")
|
|
|
|
#
|
|
|
|
# See https://cmake.org/cmake/help/latest/policy/CMP0054.html
|
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
|
2023-11-28 22:43:45 +03:00
|
|
|
# Makes a hidden visibility preset on a static lib respected
|
|
|
|
# This is used to hide glfw's symbols from the library exports when building an so/dylib
|
|
|
|
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html
|
|
|
|
cmake_policy(SET CMP0063 NEW)
|
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
# Directory for easier includes
|
2021-01-26 16:34:27 +03:00
|
|
|
# Anywhere you see include(...) you can check <root>/cmake for that file
|
2018-05-20 21:08:43 +03:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2017-07-23 02:45:36 +03:00
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
# RAYLIB_IS_MAIN determines whether the project is being used from root
|
|
|
|
# or if it is added as a dependency (through add_subdirectory for example).
|
2020-12-14 21:24:20 +03:00
|
|
|
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
set(RAYLIB_IS_MAIN TRUE)
|
|
|
|
else()
|
|
|
|
set(RAYLIB_IS_MAIN FALSE)
|
|
|
|
endif()
|
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
# Sets compiler flags and language standard
|
|
|
|
include(CompilerFlags)
|
2018-02-24 17:26:13 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
# Registers build options that are exposed to cmake
|
|
|
|
include(CMakeOptions.txt)
|
2017-11-27 03:24:08 +03:00
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
# Enforces a few environment and compiler configurations
|
2021-01-14 01:10:02 +03:00
|
|
|
include(BuildOptions)
|
2018-03-14 17:23:14 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
# Main sources directory (the second parameter sets the output directory name to raylib)
|
|
|
|
add_subdirectory(src raylib)
|
2017-07-23 02:45:36 +03:00
|
|
|
|
2023-11-06 12:12:36 +03:00
|
|
|
# Uninstall target
|
|
|
|
if(NOT TARGET uninstall)
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_MODULE_PATH}/Uninstall.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
endif()
|
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
if (${BUILD_EXAMPLES})
|
2020-12-14 21:24:20 +03:00
|
|
|
MESSAGE(STATUS "Building examples is enabled")
|
2017-07-23 02:45:36 +03:00
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
|
|
|
|
2018-07-03 21:34:31 +03:00
|
|
|
enable_testing()
|