Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made CMakeLists.txt CPM-compatible #254

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
22 changes: 16 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "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)
Expand Down Expand Up @@ -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 "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()
48 changes: 45 additions & 3 deletions docs/guides/Getting_Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,51 @@ 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 [email protected]:nick-thompson/react-juce.git
Expand Down