CMakeLists.txt 1.9 KB

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