CMakeLists.txt 1.3 KB

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