Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
!/build/.gitkeep
.vscode
export/*
.cache
26 changes: 21 additions & 5 deletions App.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
# up by default. This function accepts many optional arguments. Check the readme at
# `docs/CMake API.md` in the JUCE repo for the full list.

if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
set(_needs_web_browser NEEDS_WEB_BROWSER TRUE)
endif()

juce_add_gui_app(RNBOApp
# VERSION ... # Set this if the app version is different to the project version
# ICON_BIG ... # ICON_* arguments specify a path to an image file to use as an icon
# ICON_SMALL ...
# DOCUMENT_EXTENSIONS ... # Specify file extensions that should be associated with this app
COMPANY_NAME "cycling74" # Specify the name of the app's author
PRODUCT_NAME "RNBO App Example") # The name of the final executable, which can differ from the target name
PRODUCT_NAME "RNBO App Example" # The name of the final executable, which can differ from the target name
${_needs_web_browser})

# `juce_generate_juce_header` will create a JuceHeader.h for a given target, which will be generated
# into your build tree. This should be included with `#include <JuceHeader.h>`. The include path for
Expand All @@ -34,7 +39,6 @@ target_sources(RNBOApp
PRIVATE
src/Main.cpp
src/MainComponent.cpp
src/CustomAudioEditor.cpp
src/CustomAudioProcessor.cpp

${RNBO_CLASS_FILE}
Expand All @@ -45,6 +49,12 @@ target_sources(RNBOApp
${RNBO_CPP_DIR}/adapters/juce/RNBO_JuceAudioProcessor.cpp
)

if(RNBO_EDITOR_MODE STREQUAL "NATIVE")
target_sources(RNBOApp PRIVATE src/CustomAudioEditor.cpp)
elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
target_sources(RNBOApp PRIVATE src/WebBrowserAudioEditor.cpp)
endif()

if (EXISTS ${RNBO_BINARY_DATA_FILE})
target_sources(RNBOApp PRIVATE ${RNBO_BINARY_DATA_FILE})
endif()
Expand All @@ -61,17 +71,23 @@ target_include_directories(RNBOApp

target_compile_definitions(RNBOApp
PRIVATE
# JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them.
JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_gui_app` call
JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_gui_app` call
JUCE_APPLICATION_NAME_STRING="$<TARGET_PROPERTY:RNBOApp,JUCE_PRODUCT_NAME>"
JUCE_APPLICATION_VERSION_STRING="$<TARGET_PROPERTY:RNBOApp,JUCE_VERSION>")
JUCE_APPLICATION_VERSION_STRING="$<TARGET_PROPERTY:RNBOApp,JUCE_VERSION>"
RNBO_JUCE_PARAM_DEFAULT_NOTIFY=$<BOOL:${PLUGIN_PARAM_DEFAULT_NOTIFY}>)

# `target_link_libraries` links libraries and JUCE modules to other libraries or executables. Here,
# we're linking our executable target to the `juce::juce_gui_extra` module. Inter-module
# dependencies are resolved automatically, so `juce_core`, `juce_events` and so on will also be
# linked automatically. If we'd generated a binary data target above, we would need to link to it
# here too. This is a standard CMake command.
if(RNBO_EDITOR_MODE STREQUAL "NATIVE")
target_compile_definitions(RNBOApp PRIVATE RNBO_EDITOR_NATIVE)
elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
target_compile_definitions(RNBOApp PRIVATE RNBO_EDITOR_WEBVIEW JUCE_WEB_BROWSER=1)
target_link_libraries(RNBOApp PRIVATE RNBOUIData)
endif()

target_link_libraries(RNBOApp
PRIVATE
juce::juce_gui_extra
Expand Down
50 changes: 48 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.22) #JUCE 8 requires CMake 3.22+

# On M1 Macs, uncomment to enable universal binaries
# set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
Expand All @@ -7,7 +7,7 @@ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are:

project(RNBO_JUCE_EXAMPLE VERSION 2.0.0)

set(CMAKE_CXX_STANDARD 14) #JUCE requires 14
set(CMAKE_CXX_STANDARD 17) #JUCE 8 requires 17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
Expand All @@ -25,6 +25,13 @@ set(RNBO_BINARY_DATA_FILE "${RNBO_EXPORT_DIR}/${RNBO_CLASS_NAME}_binary.cpp")
set(RNBO_BINARY_DATA_STORAGE_NAME "${RNBO_CLASS_NAME}_binary")
set(PLUGIN_PARAM_DEFAULT_NOTIFY ON CACHE BOOL "Should parameter changes from inside your rnbo patch send output by default?")

# Choose which editor is shown when the plugin/app opens.
# DEFAULT — the generic editor provided by RNBO::JuceAudioProcessor
# NATIVE — native JUCE controls (src/CustomAudioEditor)
# WEBVIEW — WebBrowserComponent UI (src/WebBrowserAudioEditor)
set(RNBO_EDITOR_MODE "DEFAULT" CACHE STRING "UI editor: DEFAULT (Generic JUCE controls), NATIVE (Custom JUCE controls), WEBVIEW (WebBrowserComponent)")
set_property(CACHE RNBO_EDITOR_MODE PROPERTY STRINGS DEFAULT NATIVE WEBVIEW)

#write description header file if description.json exists, sets RNBO_INCLUDE_DESCRIPTION_FILE if the file exists
include(${RNBO_CPP_DIR}/cmake/RNBODescriptionHeader.cmake)
set(DESCRIPTION_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
Expand All @@ -42,6 +49,45 @@ add_subdirectory(
EXCLUDE_FROM_ALL #don't build examples etc, also don't install
)

# Compile web UI files into the binary — only needed for the WEBVIEW editor.
if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
set(WEBUI_DIR "${CMAKE_CURRENT_LIST_DIR}/src/webui")
set(WEBUI_DIST_HTML "${WEBUI_DIR}/dist/index.html")
set(WEBUI_DIST_JS "${WEBUI_DIR}/dist/index.js")

# List source files so the build reruns when they change.
set(WEBUI_SOURCES
"${WEBUI_DIR}/index.html"
"${WEBUI_DIR}/main.js"
"${WEBUI_DIR}/vite.config.js"
"${WEBUI_DIR}/package.json"
)

find_program(NPM_EXECUTABLE npm REQUIRED)

add_custom_command(
OUTPUT ${WEBUI_DIST_HTML} ${WEBUI_DIST_JS}
COMMAND ${NPM_EXECUTABLE} install
COMMAND ${NPM_EXECUTABLE} run build
WORKING_DIRECTORY ${WEBUI_DIR}
DEPENDS ${WEBUI_SOURCES}
COMMENT "Building web UI (npm run build)"
VERBATIM
)

add_custom_target(RNBOWebUIBuild
DEPENDS ${WEBUI_DIST_HTML} ${WEBUI_DIST_JS}
)

juce_add_binary_data(RNBOUIData
NAMESPACE RNBOUIData
SOURCES
${WEBUI_DIST_HTML}
${WEBUI_DIST_JS}
)
add_dependencies(RNBOUIData RNBOWebUIBuild)
endif()

# Or, instead, use Conan to get JUCE, should speed up clean builds
# include(${RNBO_CPP_DIR}/cmake/RNBOJuce.cmake)

Expand Down
Loading