Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 29 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20)

# Set toolchain before project() if using vcpkg
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT EMSCRIPTEN)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain")
endif()

Expand All @@ -10,6 +10,10 @@ project(rive_tests C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Tell CMake where to find our custom FindTMXLITE.cmake module.
# set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Enable folders in IDEs like Visual Studio
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand Down Expand Up @@ -42,35 +46,25 @@ if(PLATFORM_WEB)
# For Emscripten, we'll use the built-in SDL support
# No need to find SDL3 package
else()
# For other platforms, use vcpkg SDL3
# For other platforms, use vcpkg packages
find_package(SDL3 CONFIG REQUIRED)
find_package(harfbuzz CONFIG REQUIRED)
find_package(PNG REQUIRED)
find_package(WebP CONFIG REQUIRED)
find_package(yoga CONFIG REQUIRED)
find_package(SheenBidi REQUIRED)
find_package(glad CONFIG REQUIRED)
endif()

# Add glad manually (since it's not installed via vcpkg)
add_library(glad STATIC
third_party/glad/src/gl.c
)
find_package(RIVE REQUIRED)

# Platform-specific OpenGL setup
if(PLATFORM_DESKTOP)
find_package(OpenGL REQUIRED)
set(GL_LIBS OpenGL::GL)
target_compile_definitions(glad PUBLIC GLAD_GL)
elseif(PLATFORM_MOBILE OR PLATFORM_WEB)
# Mobile and Web use OpenGL ES
set(GL_LIBS "") # GLES is handled by platform
target_compile_definitions(glad PUBLIC GLAD_GLES2)

if(PLATFORM_WEB)
# Emscripten-specific settings
target_compile_definitions(glad PUBLIC GLAD_GLES2_IMPLEMENTATION)
endif()
endif()

# Add EGL source only for platforms that need it
if(PLATFORM_MOBILE)
target_sources(glad PRIVATE third_party/glad/src/egl.c)
target_compile_definitions(glad PUBLIC GLAD_EGL)
endif()

add_executable(rive_tests src/main.cpp)
Expand All @@ -82,19 +76,18 @@ if(PLATFORM_WEB)
SUFFIX ".html"
OUTPUT_NAME "index"
)
target_compile_options(rive_tests PRIVATE
target_compile_options(rive_tests PRIVATE
"SHELL:-s USE_SDL=3"
"SHELL:-s USE_WEBGL2=1"
)
target_link_options(rive_tests PRIVATE
target_link_options(rive_tests PRIVATE
"SHELL:-s USE_SDL=3"
"SHELL:-s USE_WEBGL2=1"
"SHELL:-s FULL_ES3=1"
"SHELL:-s WASM=1"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s EXPORTED_FUNCTIONS=['_main']"
"SHELL:-s EXPORTED_RUNTIME_METHODS=['ccall','cwrap']"
"SHELL:--shell-file ${CMAKE_SOURCE_DIR}/web/shell.html"
"SHELL:--shell-file=${CMAKE_SOURCE_DIR}/web/shell.html"
)
elseif(PLATFORM_MOBILE)
if(IOS)
Expand All @@ -107,10 +100,6 @@ elseif(PLATFORM_MOBILE)
endif()
endif()

# Include directories
target_include_directories(glad PUBLIC third_party/glad/include)
set_target_properties(glad PROPERTIES LINKER_LANGUAGE C)

# Platform-specific preprocessor definitions
if(PLATFORM_WEB)
target_compile_definitions(rive_tests PRIVATE PLATFORM_WEB)
Expand All @@ -130,14 +119,25 @@ if(PLATFORM_WEB)
# For Emscripten, SDL is handled via link options
target_link_libraries(rive_tests
PRIVATE
glad
RIVE::rive
RIVE::renderer
RIVE::decoders
SheenBidi::SheenBidi
)
else()
target_link_libraries(rive_tests
PRIVATE
SDL3::SDL3
${GL_LIBS}
glad
glad::glad
harfbuzz::harfbuzz
PNG::PNG
WebP::webp
yoga::yogacore
RIVE::rive
RIVE::renderer
RIVE::decoders
SheenBidi::SheenBidi
)
endif()

Expand Down
Binary file added assets/rive_files/alien.rev
Binary file not shown.
Binary file added assets/rive_files/alien.riv
Binary file not shown.
Binary file added assets/rive_files/arcade_controls.rev
Binary file not shown.
Binary file added assets/rive_files/arcade_controls.riv
Binary file not shown.
Binary file added assets/rive_files/audio_sampler.rev
Binary file not shown.
Binary file added assets/rive_files/audio_sampler.riv
Binary file not shown.
Binary file added assets/rive_files/car_interface.rev
Binary file not shown.
Binary file added assets/rive_files/car_interface.riv
Binary file not shown.
Binary file added assets/rive_files/charge.riv
Binary file not shown.
Binary file added assets/rive_files/seasynth.rev
Binary file not shown.
Binary file added assets/rive_files/seasynth.riv
Binary file not shown.
Binary file added assets/rive_files/toymachine_3.rev
Binary file not shown.
Binary file added assets/rive_files/toymachine_3.riv
Binary file not shown.
Binary file added assets/rive_files/ui_elements.rev
Binary file not shown.
Binary file added assets/rive_files/ui_elements.riv
Binary file not shown.
Loading