Skip to content

vvvar/juce-conan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUCE 7 Unofficial Conan 2.0 Recipe

This repository contains a recipe that makes JUCE 7 available as Conan 2.0 Package.

Pre-requisites

Install:

Read:

How to use

  1. Create JUCE Conan Package with desired options(see all available options in How to configure chapter):
$ conan create . --options build_extras=True
  1. 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()
  1. 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)
  1. Build as a normal Conan project:
$ conan install . && conan build .

How to configure

All options of this recipe are just proxies for already existing JUCE CMake Build Options:

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.

How does it work

  1. Get the tagged version of JUCE that matches with version of this recipe
  2. Translate Conan Options into JUCE CMake Options
  3. Disable Conan's XXXConfig.cmake generation feature and force it to use the original JUCEConfig.cmake generated by JUCE
  4. Build it and store it in the cache

Versioning

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.

Tips & Troubleshooting

How can I change the CMake generator?

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"

I'm receiving Missing prebuilt package while building my project

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 .

About

Unofficial Conan 2.0 recipe for JUCE Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages