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.

93 lines
4.1 KiB

  1. # Setup the project and settings
  2. project(examples)
  3. # Get the sources together
  4. set(example_dirs audio core models others shaders shapes text textures)
  5. set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
  6. include(CheckSymbolExists)
  7. check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
  8. check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
  9. set(CMAKE_REQUIRED_DEFINITIONS)
  10. if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
  11. set(example_dirs ${example_dirs} physac)
  12. endif()
  13. set(example_sources)
  14. set(example_resources)
  15. foreach(example_dir ${example_dirs})
  16. # Get the .c files
  17. file(GLOB sources ${example_dir}/*.c)
  18. list(APPEND example_sources ${sources})
  19. # Any any resources
  20. file(GLOB resources ${example_dir}/resources/*)
  21. list(APPEND example_resources ${resources})
  22. endforeach()
  23. include(CheckIncludeFiles)
  24. set(OUTPUT_EXT)
  25. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
  26. if(${PLATFORM} MATCHES "Android")
  27. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
  28. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
  29. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
  30. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
  31. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
  32. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
  33. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
  34. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
  35. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
  36. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
  37. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
  38. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
  39. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c)
  40. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
  41. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
  42. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
  43. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
  44. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
  45. elseif(${PLATFORM} MATCHES "Web")
  46. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
  47. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
  48. set(OUTPUT_EXT ".html")
  49. endif()
  50. include_directories(BEFORE SYSTEM others/external/include)
  51. if (NOT TARGET raylib)
  52. find_package(raylib 2.0 REQUIRED)
  53. endif()
  54. # Do each example
  55. foreach(example_source ${example_sources})
  56. # Create the basename for the example
  57. get_filename_component(example_name ${example_source} NAME)
  58. string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
  59. # Setup the example
  60. add_executable(${example_name} ${example_source})
  61. target_link_libraries(${example_name} raylib)
  62. endforeach()
  63. if (${PLATFORM} MATCHES "Desktop")
  64. # rlgl_standalone can't be linked with raylib because of duplicate rlgl symbols
  65. foreach (example_source "others/rlgl_standalone.c")
  66. # Create the basename for the example
  67. get_filename_component(example_name ${example_source} NAME)
  68. string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
  69. add_executable(${example_name} ${example_source})
  70. add_dependencies(${example_name} raylib)
  71. target_link_libraries(${example_name} ${raylib_LDFLAGS})
  72. target_include_directories(${example_name} PRIVATE ${raylib_INCLUDE_DIRS})
  73. endforeach()
  74. endif()
  75. # Copy all of the resource files to the destination
  76. file(COPY ${example_resources} DESTINATION "resources/")