You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 line
1.4 KiB

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