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.

58 lines
1.8 KiB

  1. # Setup the project and settings
  2. project(examples)
  3. include("../utils.cmake")
  4. # Make sure raylib has been built
  5. # TODO `build` directory should maybe be something else...
  6. # TODO place somewhere else?
  7. include_directories("../build/release")
  8. include_directories("../src/external")
  9. include_directories("../src/external/glfw/include")
  10. # Get the sources together
  11. set(example_dirs audio core models others shaders shapes text textures)
  12. set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
  13. include(CheckSymbolExists)
  14. check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
  15. check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
  16. set(CMAKE_REQUIRED_DEFINITIONS)
  17. if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
  18. set(example_dirs ${example_dirs} physac)
  19. endif()
  20. set(example_sources)
  21. set(example_resources)
  22. foreach(example_dir ${example_dirs})
  23. # Get the .c files
  24. file(GLOB sources ${example_dir}/*.c)
  25. list(APPEND example_sources ${sources})
  26. # Any any resources
  27. file(GLOB resources ${example_dir}/resources/*)
  28. list(APPEND example_resources ${resources})
  29. endforeach()
  30. include(CheckIncludeFiles)
  31. check_include_files(OVR_CAPI_GL.h HAVE_OCULUS_CAPI)
  32. if(NOT HAVE_OCULUS_CAPI)
  33. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/oculus_rift.c)
  34. endif()
  35. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
  36. # Do each example
  37. foreach(example_source ${example_sources})
  38. # Create the basename for the example
  39. get_filename_component(example_name ${example_source} NAME)
  40. string(REPLACE ".c" "" example_name ${example_name})
  41. # Setup the example
  42. add_executable(${example_name} ${example_source})
  43. # Link the libraries
  44. link_libraries_to_executable(${example_name})
  45. endforeach()
  46. # Copy all of the resource files to the destination
  47. file(COPY ${example_resources} DESTINATION "resources/")