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 lines
1.5 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 5.5)
  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_MakeAvailable(raylib)
  19. set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
  20. endif()
  21. endif()
  22. # Our Project
  23. add_executable(${PROJECT_NAME} core_basic_window.c)
  24. #set(raylib_VERBOSE 1)
  25. target_link_libraries(${PROJECT_NAME} raylib)
  26. # Web Configurations
  27. if (${PLATFORM} STREQUAL "Web")
  28. set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html") # Tell Emscripten to build an example.html file.
  29. 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")
  30. endif()
  31. # Checks if OSX and links appropriate frameworks (Only required on MacOS)
  32. if (APPLE)
  33. target_link_libraries(${PROJECT_NAME} "-framework IOKit")
  34. target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
  35. target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
  36. endif()