From 5a94a280d0a7d2866a12e6f9144401881e17de02 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 28 Jul 2018 16:35:21 +0200 Subject: [PATCH] CMake: include rlgl_standalone in -DBUILD_EXAMPLES With the recent CMake cleanup, getting raylib's dependencies for use when building rlgl_standalone is quite straight forward, so lets enable it again. Fixes #508, just properly this time. :) --- examples/CMakeLists.txt | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 708c08c6..90a1e902 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,12 +25,12 @@ foreach(example_dir ${example_dirs}) endforeach() include(CheckIncludeFiles) -list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) -list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) # see #588 set(OUTPUT_EXT) +list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) if(${PLATFORM} MATCHES "Android") list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) 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) @@ -49,12 +49,16 @@ if(${PLATFORM} MATCHES "Android") 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) + 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") + endif() +include_directories(BEFORE SYSTEM others/external/include) + if (NOT TARGET raylib) find_package(raylib 2.0 REQUIRED) endif() @@ -68,9 +72,22 @@ foreach(example_source ${example_sources}) # Setup the example add_executable(${example_name} ${example_source}) - # Link the libraries target_link_libraries(${example_name} raylib) endforeach() +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() + # Copy all of the resource files to the destination file(COPY ${example_resources} DESTINATION "resources/")