This repository contains a recipe that makes JUCE 7 available as Conan 2.0 Package.
Install:
Read:
- Create JUCE Conan Package with desired options(see all available options in How to configure chapter):
$ conan create . --options build_extras=True
- Add it as a requirement in your Conan project:
# conanfile.py
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
class MyProject(ConanFile):
name = "MyPlugin"
version = "0.4.2"
user = "octocat"
channel = "testing"
settings = "os", "arch", "compiler", "build_type"
requires = "juce/7.0.5@juce/release" # Require JUCE
default_options = { # Configure it
"juce/*:build_extras": True
}
def layout(self):
cmake_layout(self)
def generate(self):
toolchain = CMakeToolchain(self)
toolchain.generate()
dependencies = CMakeDeps(self)
dependencies.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
- Add it to your
CMakeList.txt
. Similar to the find package approach:
# CMakeList.txt
project(MyPlugin)
# Place it early, after `project()`
find_package(JUCE CONFIG REQUIRED)
# You can use standard JUCE CMake functions
juce_add_plugin(MyPlugin
PLUGIN_MANUFACTURER_CODE Ocat
PLUGIN_CODE Ocode
LV2URI "https://example.com"
FORMATS AU VST3 LV2 Standalone
VST3_CATEGORIES Fx Distortion Dynamics
AU_MAIN_TYPE kAudioUnitType_Effect
COMPANY_NAME "octocompany"
PRODUCT_NAME "MyPlugin"
# Just as normal JUCE CMake project
target_sources(MyPlugin
PRIVATE
Source/PluginEditor.cpp
Source/PluginProcessor.cpp)
# And link with JUCE libraries
target_link_libraries(MyPlugin
PRIVATE
juce::juce_dsp
juce::juce_audio_utils
juce::juce_audio_plugin_client
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
- Build as a normal Conan project:
$ conan install . && conan build .
All options of this recipe are just proxies for already existing JUCE CMake Build Options:
build_extras
corresponds toJUCE_BUILD_EXTRAS
build_examples
corresponds toJUCE_BUILD_EXAMPLES
enable_module_source_groups
corresponds toJUCE_BUILD_EXAMPLES
copy_plugin_after_build
corresponds toJUCE_COPY_PLUGIN_AFTER_BUILD
All defaults follow the same rules as in JUCE. For example, if you haven't provided build_extras
then Conan will set it to False
, just as JUCE does.
- Get the tagged version of JUCE that matches with version of this recipe
- Translate Conan Options into JUCE CMake Options
- Disable Conan's
XXXConfig.cmake
generation feature and force it to use the originalJUCEConfig.cmake
generated by JUCE - Build it and store it in the cache
This recipe follows the same versioning scheme as JUCE. This means that 7.0.5
version of this recipe corresponds to 7.0.5 version of JUCE
.
By default, Conan will ask CMake to use Unix Makefiles
generator. You can change that by configuring CMakeToolchain
in your conanfile.py
. For example, if you want to use Visual Studio 17 2022
for Windows and Ninja
for everything else, then you need to modify your def generate(self)
:` as follows:
def generate(self):
toolchain = CMakeToolchain(self)
if self.settings.os == "Windows":
toolchain.generator = "Visual Studio 17 2022"
else:
toolchain.generator = "Ninja"
If you're receiving this error:
ERROR: Missing prebuilt package for 'juce/7.0.5@juce/release'
then it means that you haven't built JUCE Conan Package with the correct options/settings.
For example, you've built it with build_extras=False
:
$ conan create . --options build_extras=False
but in your project, it is required with build_extras=True
:
# conanfile.py
requires = "juce/7.0.5@juce/release"
default_options = {
"juce/*:build_extras": True # <-- Here, should match
}
Therefore, Conan would not be able to find a pre-build JUCE Conan Package in your cache because settings/options in your cache and your requirements should 1-1 match(see the detailed explanation from Conan Docs). Thus, you should either create JUCE Conan Package with the correct options/settings:
$ conan create . --options build_extras=True
or, in your project, explicitly state that you'd like to build missing dependencies from the sources:
$ conan install . --build=missing && conan build .