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.

96 lines
4.3 KiB

6 years ago
6 years ago
  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}/models/models_rlgl_solar_system.c)
  43. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
  44. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
  45. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
  46. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
  47. list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c)
  48. elseif(${PLATFORM} MATCHES "Web")
  49. 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")
  50. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
  51. set(OUTPUT_EXT ".html")
  52. endif()
  53. include_directories(BEFORE SYSTEM others/external/include)
  54. if (NOT TARGET raylib)
  55. find_package(raylib 2.0 REQUIRED)
  56. endif()
  57. # Do each example
  58. foreach(example_source ${example_sources})
  59. # Create the basename for the example
  60. get_filename_component(example_name ${example_source} NAME)
  61. string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
  62. # Setup the example
  63. add_executable(${example_name} ${example_source})
  64. target_link_libraries(${example_name} raylib)
  65. endforeach()
  66. if (${PLATFORM} MATCHES "Desktop")
  67. # rlgl_standalone can't be linked with raylib because of duplicate rlgl symbols
  68. foreach (example_source "others/rlgl_standalone.c")
  69. # Create the basename for the example
  70. get_filename_component(example_name ${example_source} NAME)
  71. string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
  72. add_executable(${example_name} ${example_source})
  73. add_dependencies(${example_name} raylib)
  74. target_link_libraries(${example_name} ${raylib_LDFLAGS})
  75. target_include_directories(${example_name} PRIVATE ${raylib_INCLUDE_DIRS})
  76. endforeach()
  77. endif()
  78. # Copy all of the resource files to the destination
  79. file(COPY ${example_resources} DESTINATION "resources/")