RIVE integration into JUCE8

Hi all,

I’m a beginner struggling to figure out how to integrate Rive into my JUCE8 project. Does anyone know if this is even possible?

I have managed to build a prototype of using the JUCE framework of the back end, but i wanted to skin the plugin using Rive.

Most of my setup has worked so far, all the OpenGL and PluginProcessor parts have been coded etc (using AI)

The most persistent issue seems to be my CMAKELIST isn’t including my Source folder *.cpp and *.h files in the solution.

I am building it in Visual Studio 2022 using Clang-CL after using CMAKE to build with the CMAKELISTS method etc not using the PROJUCER tool.

I was able to get around the linker errors by adding the source files manually in the Visual Studio Solution Explorer after creating the solution file.

Does anyone know of an open-source project that I can take a look at that has Rive integrated into it?

Or examples of really well done GUI / UI’s that I can learn from.

I have a visual design background so that is why im trying hard to make the UI aspect stand out.

Thanks for your help,

Joe

If you’ve gotten this far with AI/ML, keep going.

Paste the whole project to the AI/ML and ask it to fix it.

Or, put your stuff in a repo and share it here.

Anything less is simply un-debuggable. AI/ML could do it though, paste it on through and let us know, yo.

Hi ibisum,

Thanks for the suggestion and you’re right – this was my first commit though ive been working on this for weeks now :sweat_smile:

This is the git repo:


After I CMAKE the project and create the VS solution, I have to then manually add the DemoTape/Sources folder *.cpp / *.h files to enable a compile via VS.

There are other errors that im working through here one by one as this does effectively work around the linker errors (not finding the pluginprocessor.cpp etc).

CMAKE just doesnt include those source files and its slightly annoying manually adding them everytime (seems strange?)

My concern is if it will affect the rest of the build somehow and im not wasting time debugging when the problem may have been that CMAKE linker errors..

Thanks Ibi ^^

1 Like

Some fixes for you, see the comments:

cmake_minimum_required(VERSION 3.15)

project(DemoTape VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find and include JUCE
set(JUCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../JUCE" CACHE PATH "Path to JUCE library")
if(NOT EXISTS "${JUCE_PATH}/CMakeLists.txt")
    message(FATAL_ERROR "JUCE path doesn't exist or isn't a JUCE repository: ${JUCE_PATH}")
endif()

# MSVC-specific settings should come before adding subdirectories
if(MSVC)
    add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)
endif()

add_subdirectory(${JUCE_PATH} ${CMAKE_BINARY_DIR}/JUCE EXCLUDE_FROM_ALL)

# Define paths
set(RIVE_CPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/include")
set(RIVE_RENDERER_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/renderer/include")
set(RIVE_RENDERER_SRC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/renderer/src")
set(RIVE_CPP_LIB_PATH "E:/__Design/__/__VST/__Phoenix/rive-runtime-main/out/debug/rive.lib")

# Source and header files
set(PLUGIN_SOURCES
    "Source/RiveOpenGLRenderer.cpp"
    "Source/PluginProcessor.cpp"
    "Source/PluginEditor.cpp"
    "Source/RiveComponent.cpp"
)

set(PLUGIN_HEADERS
    "Source/juce_config.h"
    "Source/PluginEditor.h"
    "Source/PluginProcessor.h"
    "Source/RiveComponent.h"
    "Source/RiveDemo.h"
    "Source/RiveFactory.h"
    "Source/RiveOpenGLRenderer.h"
)

# Define the plugin
juce_add_plugin(DemoTape
    COMPANY_NAME "YourCompany"
    PLUGIN_MANUFACTURER_CODE "Ydmo"
    PLUGIN_CODE "Dmtp"
    FORMATS VST3 Standalone
    PRODUCT_NAME "DemoTape"
)

# Generate JUCE header
juce_generate_juce_header(DemoTape)

# Include directories
target_include_directories(DemoTape
    PRIVATE
        "${CMAKE_CURRENT_SOURCE_DIR}/Source"
        "${RIVE_CPP_INCLUDE_DIR}"
        "${RIVE_RENDERER_INCLUDE_DIR}"
        "${RIVE_RENDERER_SRC_INCLUDE_DIR}"
)

# Compile definitions
target_compile_definitions(DemoTape
    PRIVATE
        JUCE_VST3_CAN_REPLACE_VST2=0
        JUCE_DISPLAY_SPLASH_SCREEN=0
)

# Platform-specific settings
if(WIN32)
    target_compile_definitions(DemoTape
        PRIVATE
            _USE_MATH_DEFINES
            WIN32_LEAN_AND_MEAN
    )
endif()

# Link libraries
target_link_libraries(DemoTape
    PRIVATE
        juce::juce_audio_utils
        juce::juce_opengl
        juce::juce_audio_plugin_client
        "${RIVE_CPP_LIB_PATH}"
    PUBLIC
        juce::juce_recommended_config_flags
        juce::juce_recommended_lto_flags
)

# Add sources to target
target_sources(DemoTape
    PRIVATE
        ${PLUGIN_SOURCES}
        ${PLUGIN_HEADERS}
)

# MSVC-specific compiler options
if(MSVC)
    target_compile_options(DemoTape
        PRIVATE
            $<$<CONFIG:Debug>:/MDd>
    )
    
    target_link_options(DemoTape
        PRIVATE
            $<$<CONFIG:Debug>:/NODEFAULTLIB:MSVCPRTD>
            $<$<CONFIG:Debug>:/NODEFAULTLIB:MSVCRTD>
            $<$<CONFIG:Debug>:/NODEFAULTLIB:LIBCMTD>
            $<$<CONFIG:Debug>:/FORCE:MULTIPLE>
    )
endif()

# Diagnostic messages
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "JUCE_PATH: ${JUCE_PATH}")
message(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")

# Source grouping for IDEs
source_group("Source Files" FILES ${PLUGIN_SOURCES})
source_group("Header Files" FILES ${PLUGIN_HEADERS})

Key fixes and improvements:

  1. Removed redundant preprocessor definitions (some were defined twice)

  2. Simplified source file paths by making them relative to CMAKE_CURRENT_SOURCE_DIR

  3. Added target_sources which is the proper way to add source files to a JUCE plugin target

  4. Moved MSVC-specific definitions to appropriate sections

  5. Removed commented-out code that’s not needed

  6. Consolidated platform-specific settings

  7. Improved organization and readability

  8. Removed unnecessary generator expressions where simple if(MSVC) suffices

  9. Removed redundant diagnostic check for RIVE_CPP_INCLUDE_DIR

  10. Fixed source_group to use the variables instead of repeating file lists

Potential remaining considerations:

  1. The absolute path to rive.lib might need to be configurable or have a debug/release variant

  2. You might want to add checks for the existence of the Rive library path

  3. Consider adding install rules if needed

  4. You might want to add configuration-specific library paths for Debug/Release builds

The CMakeLists.txt should now build correctly assuming all the referenced files and paths exist on your system. Make sure to adjust the RIVE_CPP_LIB_PATH if it’s different on your build machine or if you need different paths for different configurations.

If this CMakeLists.txt works out, the next thing to do would be to get rive.lib through some better mechanism, as a build target perhaps. But, that’s over to you to work out (and don’t forget to share the details, because RIVE looks pretty good).. Disclaimer: I haven’t done anything in RIVE yet, I just like helping folks with easy JUCE stuff … :wink:

1 Like

RIVE seems cool, so I tried to do a demo project, which I’ll share here:

Not yet working, but I’ll bash at it for a few days ..

Okay, seems to build okay but I don’t yet have a “.riv” file to test with, maybe you want to contribute one and we can look at what it takes to wire things up vis a vis RIVE/JUCE .. If you’re interested, search for TODO: in my sample project, these are the entry points for RIVE and JUCE, and the real meat of the work is still yet to be done .. however, the project setup of JUCE and RIVE, integrated, seems to compile fine for now .. ymmv .. but the meat of the work is left up to you .. :wink:

1 Like

Thanks for checking it out Ibi these suggestions are super helpful.
Having a project to look through helps with learning!

I was going to test it with this .Riv file – its a demo with two knobs that comes with Riv.

I also have a stripped down basic version with no animation as I wanted to just test to see if the setup would even work.

tape_vst2.zip (132.2 KB)

feathering_demo_tape_vst.zip (140.7 KB)

Its super, super exciting if this is even possible and it would open up a lot of creative UI abilities. Combined with JUCE would be spectactular way of building plugins.

I’d love to see what it requires to hook it up too though im a mega noob – its but i’m very dedicated in learning to do it. :sweat_smile:

as they say, so far so good :laughing:

thanks for your help ibi!!

I’ve started already integrating the Rive renderer on top of the JUCE 7 ISC modules but it’s a separate project. It can already target all major desktop, mobile and web, but of course is still under heavy development and might lack the level of complexity of something like juce. But i’m looking for contributors (also someone with UI experience would be great), as it’s a fully open source initiative with no intention to close it down, and we can only keep making it better.

3 Likes

I saw this and it inspired me to try and work with it.

I’m a complete beginner with plugin coding/C++ but I love that you had the foresight to see Rive being extremely powerful to combine with JUCE. I’m also just diving into the Rive workflow but I have a lot of experience with UI.

If I end up using your open source library, I will suerly contribute in my own way and share!

That would be awesome, if you could contribute with your UI design experience (like creating controls in Rive) !