2017-07-23 02:45:36 +03:00
|
|
|
# Setup the project and settings
|
|
|
|
project(examples)
|
|
|
|
|
|
|
|
# Get the sources together
|
2018-01-17 22:14:14 +03:00
|
|
|
set(example_dirs audio core models others shaders shapes text textures)
|
2017-11-25 22:27:53 +03:00
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
|
|
|
|
check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
|
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
|
|
|
if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
|
|
|
|
set(example_dirs ${example_dirs} physac)
|
|
|
|
endif()
|
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
set(example_sources)
|
|
|
|
set(example_resources)
|
|
|
|
foreach(example_dir ${example_dirs})
|
|
|
|
# Get the .c files
|
|
|
|
file(GLOB sources ${example_dir}/*.c)
|
|
|
|
list(APPEND example_sources ${sources})
|
|
|
|
|
|
|
|
# Any any resources
|
|
|
|
file(GLOB resources ${example_dir}/resources/*)
|
|
|
|
list(APPEND example_resources ${resources})
|
|
|
|
endforeach()
|
|
|
|
|
2017-11-25 22:27:53 +03:00
|
|
|
include(CheckIncludeFiles)
|
2018-07-25 01:39:17 +03:00
|
|
|
set(OUTPUT_EXT)
|
2018-07-28 17:35:21 +03:00
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
2017-11-25 22:27:53 +03:00
|
|
|
|
2018-05-21 01:58:49 +03:00
|
|
|
if(${PLATFORM} MATCHES "Android")
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
2018-07-28 17:35:21 +03:00
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
|
2018-05-21 01:58:49 +03:00
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
|
|
|
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
|
|
|
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
|
|
|
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
2018-07-28 17:35:21 +03:00
|
|
|
|
2018-07-25 01:39:17 +03:00
|
|
|
elseif(${PLATFORM} MATCHES "Web")
|
|
|
|
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")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
|
|
|
|
set(OUTPUT_EXT ".html")
|
2018-07-28 17:35:21 +03:00
|
|
|
|
2018-05-21 01:58:49 +03:00
|
|
|
endif()
|
|
|
|
|
2018-07-28 17:35:21 +03:00
|
|
|
include_directories(BEFORE SYSTEM others/external/include)
|
|
|
|
|
2018-07-28 17:08:41 +03:00
|
|
|
if (NOT TARGET raylib)
|
|
|
|
find_package(raylib 2.0 REQUIRED)
|
|
|
|
endif()
|
2017-11-25 22:27:53 +03:00
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
# Do each example
|
|
|
|
foreach(example_source ${example_sources})
|
|
|
|
# Create the basename for the example
|
|
|
|
get_filename_component(example_name ${example_source} NAME)
|
2018-07-25 01:39:17 +03:00
|
|
|
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
|
2017-07-23 02:45:36 +03:00
|
|
|
|
|
|
|
# Setup the example
|
|
|
|
add_executable(${example_name} ${example_source})
|
|
|
|
|
2018-07-28 17:08:41 +03:00
|
|
|
target_link_libraries(${example_name} raylib)
|
2017-07-23 02:45:36 +03:00
|
|
|
endforeach()
|
|
|
|
|
2018-07-28 17:35:21 +03:00
|
|
|
if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
# rlgl_standalone can't be linked with raylib because of duplicate rlgl symbols
|
|
|
|
foreach (example_source "others/rlgl_standalone.c")
|
|
|
|
# Create the basename for the example
|
|
|
|
get_filename_component(example_name ${example_source} NAME)
|
|
|
|
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
|
|
|
|
add_executable(${example_name} ${example_source})
|
|
|
|
add_dependencies(${example_name} raylib)
|
|
|
|
target_link_libraries(${example_name} ${raylib_LDFLAGS})
|
|
|
|
target_include_directories(${example_name} PRIVATE ${raylib_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
# Copy all of the resource files to the destination
|
|
|
|
file(COPY ${example_resources} DESTINATION "resources/")
|