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.

81 lines
3.4 KiB

  1. # Setup the project and settings
  2. project(examples)
  3. include("../cmake/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. if(${PLATFORM} MATCHES "Android")
  37. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
  38. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
  39. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
  40. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
  41. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
  42. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
  43. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
  44. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
  45. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
  46. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
  47. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
  48. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c)
  49. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
  50. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
  51. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
  52. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
  53. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
  54. endif()
  55. # Do each example
  56. foreach(example_source ${example_sources})
  57. # Create the basename for the example
  58. get_filename_component(example_name ${example_source} NAME)
  59. string(REPLACE ".c" "" example_name ${example_name})
  60. # Setup the example
  61. add_executable(${example_name} ${example_source})
  62. # Link the libraries
  63. link_libraries_to_executable(${example_name})
  64. endforeach()
  65. # Copy all of the resource files to the destination
  66. file(COPY ${example_resources} DESTINATION "resources/")