From 729bf012cb4e041d23765d475f477f5dfe6faeb2 Mon Sep 17 00:00:00 2001 From: Santiago de Leon Date: Thu, 25 Mar 2021 14:18:31 -0300 Subject: [PATCH 1/4] Made CMakeLists more CPM-friendly --- CMakeLists.txt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40dd3579..4663ed4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,17 @@ project(reactjuce VERSION 0.1.0) # (practical to debug the plugin processor directly from your IDE) option(JUCE_BUILD_EXTRAS "Build JUCE Extras" OFF) - # Change this option to set the JS Interpreter/Engine you wish to run React-JUCE against. -set(REACTJUCE_JS_LIBRARY DUKTAPE CACHE STRING "The JS Engine to use: either HERMES or DUKTAPE") +if (NOT DEFINED REACTJUCE_JS_LIBRARY) + set(REACTJUCE_JS_LIBRARY DUKTAPE CACHE STRING "The JS Engine to use: either HERMES or DUKTAPE") +endif() +# Set this to OFF in your CPMAddPackage if you're including this as a library. +option(REACTJUCE_INCLUDE_JUCE "" ON) -add_subdirectory(ext/juce) +if (REACTJUCE_INCLUDE_JUCE) + add_subdirectory(ext/juce) +endif() # Adding any custom modules you might have: juce_add_module(react_juce) @@ -49,6 +54,11 @@ elseif (REACTJUCE_JS_LIBRARY STREQUAL "DUKTAPE") ) endif() -# If you want to create new projects, you can init them in the examples folder -# and add them here with the add_subdirectory command -add_subdirectory(examples/GainPlugin) +# Set this to OFF in your CPMAddPackage if you're including this as a library. +option(REACTJUCE_BUILD_EXAMPLES ON) + +if (REACTJUCE_BUILD_EXAMPLES) + # If you want to create new projects, you can init them in the examples folder + # and add them here with the add_subdirectory command + add_subdirectory(examples/GainPlugin) +endif() From 84f228b038e89db229baa7f7e9c2d4c921133939 Mon Sep 17 00:00:00 2001 From: Santiago de Leon Date: Wed, 7 Apr 2021 11:59:54 -0300 Subject: [PATCH 2/4] Added docs about how to use CPM in the getting started guide --- docs/guides/Getting_Started.md | 49 +++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/docs/guides/Getting_Started.md b/docs/guides/Getting_Started.md index 48de5a1a..0552c9d4 100644 --- a/docs/guides/Getting_Started.md +++ b/docs/guides/Getting_Started.md @@ -12,9 +12,52 @@ To get started with React-JUCE, you'll first need to install a few dependencies: - Xcode10.2+ (MacOS) - Visual Studio 2017+ (Windows) -Once you have the dependencies installed, we need to clone the React-JUCE repository -itself. React-JUCE's git repository contains necessary submodules, so we'll need to -collect those as well, which we can do one of two ways: +## Including react-juce as a library with CPM + +If you want to use react-juce as a library in your CMake project, you can include it +automatically with CPM. + +``` +# Set js library to "DUKTAPE" or "HERMES +set(REACTJUCE_JS_LIBRARY "HERMES") +CPMAddPackage( + NAME react_juce + GITHUB_REPOSITORY nick-thompson/react-juce + GIT_TAG origin/master + OPTIONS + "REACTJUCE_INCLUDE_JUCE OFF" "REACTJUCE_BUILD_EXAMPLES OFF" +) +``` + +Then you'll want to add `react_juce` to the `target_link_libraries` call for your +plugin or app, like so: + +``` +target_link_libraries(${TargetName} PRIVATE + # Other dependencies here + # ... + react_juce) +``` + +After that, you'll want to include the react-juce headers in the source file where +you intend to inject some react-juce behavior. + +``` +#include "react_juce.h" +``` + +After that, the `reactjuce` namespace will be available, so you can use classes like +`reactjuce::GenericEditor`. The gain plugin included in this repo has some example +code that should help you understand how to plug some react code into your plugin or +app. + + +## Building this repo + +If you need to build this repo yourself or want to run the examples, you'll need to +clone the React-JUCE repository itself. React-JUCE's git repository contains +necessary submodules, so you'll need to collect those as well, which we can do one +of two ways: ```bash $ git clone --recurse-submodules git@github.com:nick-thompson/react-juce.git From 19380aeae32a3e90b17bce54ef4cc7e119d19acf Mon Sep 17 00:00:00 2001 From: Santiago de Leon Date: Wed, 7 Apr 2021 12:08:40 -0300 Subject: [PATCH 3/4] Added labels so that options are usable with CMake GUI --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4663ed4e..c36feaf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ if (NOT DEFINED REACTJUCE_JS_LIBRARY) endif() # Set this to OFF in your CPMAddPackage if you're including this as a library. -option(REACTJUCE_INCLUDE_JUCE "" ON) +option(REACTJUCE_INCLUDE_JUCE "Include JUCE" ON) if (REACTJUCE_INCLUDE_JUCE) add_subdirectory(ext/juce) @@ -55,7 +55,7 @@ elseif (REACTJUCE_JS_LIBRARY STREQUAL "DUKTAPE") endif() # Set this to OFF in your CPMAddPackage if you're including this as a library. -option(REACTJUCE_BUILD_EXAMPLES ON) +option(REACTJUCE_BUILD_EXAMPLES "Build examples" ON) if (REACTJUCE_BUILD_EXAMPLES) # If you want to create new projects, you can init them in the examples folder From 346a24fc089fecbe16c8482cb0fff912645c1656 Mon Sep 17 00:00:00 2001 From: Santiago de Leon Date: Wed, 7 Apr 2021 14:19:06 -0300 Subject: [PATCH 4/4] Fixed linting --- docs/guides/Getting_Started.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/guides/Getting_Started.md b/docs/guides/Getting_Started.md index 0552c9d4..8c740f24 100644 --- a/docs/guides/Getting_Started.md +++ b/docs/guides/Getting_Started.md @@ -24,7 +24,7 @@ CPMAddPackage( NAME react_juce GITHUB_REPOSITORY nick-thompson/react-juce GIT_TAG origin/master - OPTIONS + OPTIONS "REACTJUCE_INCLUDE_JUCE OFF" "REACTJUCE_BUILD_EXAMPLES OFF" ) ``` @@ -51,7 +51,6 @@ After that, the `reactjuce` namespace will be available, so you can use classes code that should help you understand how to plug some react code into your plugin or app. - ## Building this repo If you need to build this repo yourself or want to run the examples, you'll need to