Build VCVRack with Conan and CMake + add CI

Hello,

I like VCVRack and because of beeing also a software developer, I once looked into the sources to see what is going on under the hood. But somehow I didn’t like the provided build setup/instructions and therefore I never built VCVRack this way. I was aware of the Conan C/C++ Package Manager and intended for some time to adopt Conan for C++ development. So I was thinking to give it a try with VCVRack.

Now I want to present/discuss here the current state I have so far.

In case you don’t know Conan, I suggest to read the Get Started documentation or watch the Conan Webinar(s).

As a short overview I have done so far the following steps:

  • determining the VCVRack build dependencies
  • searched for existing Conan packages and in case packages were missing I created and published these packages by myself
  • created conanfile.py recipe to manage dependencies for VCVRack
  • Translated build instructions from Makefiles into CMakeLists.txt to build VCVRack with CMake for
    • Linux (Gcc and Clang)
    • MacOS (Clang)
    • Windows (MinGW Gcc)
  • added Azure CI pipeline setup for automated building of VCVRack on Azure for Linux, MacOS and Windows with Conan and CMake
  • added Conan and CMake build + Azure CI setup for public available plugins

The work is based on the current v1 branch development. I created a Pull Request in my own repository Feature/add conan by qno · Pull Request #5 · qno/Rack · GitHub so you can take a look at the current state.

For now I don’t want to go into too much details, but it will have the following advantages:

  • No more messing up with dependencies handled via git submodules (they could just be removed)
  • No more Makefiles nedded anymore
  • No complicated setup of build environment anymore
  • CMake based build (so you can also generate a project for your favourite IDE)
  • No need to build VCVRack anymore before beeing able to build a Plugin
  • Faster builds, as prebuilt binary artifacts of dependencies will be downloaded (and cached) by Conan
  • Native Windows build with MSVC compiler should be possible (will requires some changes VCVRack code through use of platform abstraction), all dependencies can already be build with MSVC

So here is what you basically need to do:

  • Install Build Environment (Git, Cmake, Compiler) (for Windows no MinGW installation is required anymore :wink:).
  • Under Linux you also don’t need to install any required dependecies with the package manager anymore.
  • Install the Conan Package Manager for your development Platform.
  • Setup Conan repositories for retrieving artifacts:
    • conan remote add conan-community https://api.bintray.com/conan/conan-community/conan
    • conan remote add qno https://api.bintray.com/conan/qno/conan-public
    • conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
  • For Windows create a Conan MinGW profile under your USER directory in .conan\profiles, called e.g. mingw with the following content:
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.exception=seh
compiler.libcxx=libstdc++11
compiler.threads=posix
build_type=Release
[options]
[build_requires]
mingw_installer/1.0@conan/stable
msys2_installer/latest@bincrafters/stable
[env]
  • If you are under Windows also add the following change under your USER directory to the .conan/conan.conf file to avoid trouble with spaces in path names:
[storage]
# This is the default path, but you can write your own. It must be an absolute path or a
# path beginning with "~" (if the environment var CONAN_USER_HOME is specified, this directory, even
# with "~/", will be relative to the conan user home, not to the system user home)
path = C:\.conan/data
  • Clone repository git clone https://github.com/qno/Rack.git and switch to feature branch git checkout feature/add_conan
  • Create a build directory and cd into it
  • Execute conan install ../Rack - under Windows please use conan install ..\Rack --profile mingw
  • Execute cmake -DCMAKE_BUILD_TYPE=Release ../Rack - under Windows please call activate_run.bat and cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..\Rack
  • Build VCVRack with cmake --build . -j

Thats it! In case the Conan build fails - just add --build=missing to the conan command, as it is possible that prebuilt binary artifacts are missing.

These steps are also reflected in the CI pipeline setup, so you can take a look there.

To test and run the VCVRack executable run the Rack executable in the bin directory.

Still open points are:

  • add missing deploy steps for VCVRack inside Conan (package VCVRack, create installer packages etc.)
  • automated upload of Azure build artifacts (to github pages for nightly builds for example, etc.)
  • create some kind of Conan VCVRack SDK package to ease Plugin development (I have it already but yet not published)
  • improve Plugin building with Conan and CMake
  • native Windows build with MS Visual Studio Compiler

If someone is interested in the work, feel free to check out the branch to test it and give some feedback here. But please keep in mind - it is still work in progress and I would really like to get some feedback about the current state.

Build the VCVRack Fundamental Plugin

As without Plugins you basically can’t do anything useful with VCVRack, here is what you need to do for now to build it.

Build the VCVRackSDK and publish it to your local Conan cache:

  • cd into the Rack source directory
  • Execute conan create . qno/testing - under Windows please use conan create . qno/testing --profile mingw

Build the Plugin: Note - The CMAKE_INSTALL_PREFIX points here to the default Rack Plugin folder, so the Plugin is published during the build process.

  • Clone the Fundamental Plugin git clone https://github.com/VCVRack/Fundamental.git and switch to the feature/add_conan_cmake branch git checkout feature/add_conan_cmake
  • Create a build directory and cd into it
  • Execute conan install ../Fundamental - under Windows please use conan install ..\Fundamental --profile mingw
  • Execute CMake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.Rack/plugins-v1 ../Fundamental - under Windows please call activate_run.bat and cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Documents\Rack\plugins-v1" ..\Fundamental
  • Build Fundamental Plugin cmake --build . -j --target install
  • run the Rack executable and select Plugins from the Plugin Manager

The following Plugins were also adapted, so you can build them exactly as the Fundamental Plugin (just replace in the above steps the name of the Plugin):

  • Befaco Plugin - https://github.com/qno/Befaco
  • ESeries Plugin - https://github.com/qno/ESeries
  • AudibleInstruments Plugin - https://github.com/qno/AudibleInstruments
  • HetrickCV Plugin - https://github.com/qno/hetrickcv
  • JW-Modules Plugin - https://github.com/qno/JW-Modules
  • Bacon Music Plugin - https://github.com/qno/BaconPlugs

They work under Windows and Linux, for MacOS I couldn’t build and test, as I don’t have a Mac.

Download Build artifacts from Github

For demonstration purpose I created a special Github repository which contains all uploaded Azure CI build artifacts (Rack and Plugins)

Rack and Plugin binaries can be downloaded from VCVRack-Release-Demo/releases and tested. The artifacts are updated automatically after CI builds.

This is how the UI issue looks like for me

probably you are building against an obsolete Rack code v1
do a git pull and rebuild Rack

No, sources and dependencies are up-to-date.

Hm, OK - I just realised that a modified fork of oui-blendish is used. I’ll try to use the fork as dependency and create a Conan package for this.

But using this fork doesn’t fix anything in UI.

I have updated the first post and added more information.

Now I figured out the cause of the UI issue. Somehow the Font for the Scope Plugin res/sudo/Sudo.ttf got corrupted on my machine. Now everything works perfect.

After improving the CMake build configuration, I have updated the first post again.
All changes are now published to the Github repositories, so the manual steps aren’t necessary anymore.
I also adapted the build process for the Befaco, ESeries and AudibleInstruments Plugins.

I added the HetrickCV Plugin.

I added JW-Modules and Bacon Music Plugins.

After further improvements and fixes, I updated the first post with information about downloading CI build artifacts from VCVRack-Release-Demo/releases.

1 Like

Is this the latest version of the conan build instructions? I’m trying to replicate your work on my Windows 10 development VM, and so far so good until I try to generate a VS solution.

Here is my $HOME\.conan\profiles\mingw:

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.exception=seh
compiler.libcxx=libstdc++11
compiler.threads=posix
build_type=Release
[options]
[build_requires]
mingw_installer/1.0@conan/stable
msys2_installer/latest@bincrafters/stable
[env]

Here’s the commands I run:

conan install .. --profile mingw --build=missing
cmake -G "Visual Studio 16 2019" ..

and here’s the output I get:

-- The CXX compiler identification is MSVC 19.22.27905.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: C:/Users/wwinfrey/scoop/shims/git.exe (found version "2.23.0.windows.1")
-- build Rack version '1.dev.47ae701'
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Library rtaudiod not found in package, might be system one
-- Library dsound not found in package, might be system one
-- Library ole32 not found in package, might be system one
-- Library ksuser not found in package, might be system one
-- Library mfplat not found in package, might be system one
-- Library mfuuid not found in package, might be system one
-- Library wmcodecdspuuid not found in package, might be system one
-- Library rtmidid not found in package, might be system one
-- Library winmm not found in package, might be system one
-- Library rtaudio not found in package, might be system one
-- Library dsound not found in package, might be system one
-- Library ole32 not found in package, might be system one
-- Library ksuser not found in package, might be system one
-- Library mfplat not found in package, might be system one
-- Library mfuuid not found in package, might be system one
-- Library wmcodecdspuuid not found in package, might be system one
-- Library rtmidi not found in package, might be system one
-- Library winmm not found in package, might be system one
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: C:/Users/wwinfrey/Documents/Development/VCVRack/Rack/build
CMake Error at build/conanbuildinfo.cmake:1847 (message):
  Incorrect 'gcc', is not the one detected by CMake: 'MSVC'
Call Stack (most recent call first):
  build/conanbuildinfo.cmake:1483 (conan_check_compiler)
  CMakeLists.txt:31 (conan_basic_setup)


-- Configuring incomplete, errors occurred!
See also "C:/Users/wwinfrey/Documents/Development/VCVRack/Rack/build/CMakeFiles/CMakeOutput.log".

Seems like it’s not finding gcc for some reason. I don’t have any experience with conan, but from the build_requires config section it would appear that the gcc installation is handled by conan?

Hello,

you can’t generate a Visual Studio project with gcc compiler, so you have to call CMake like this cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release .. after your conan install. Also don’t forget to execute activate_run.bat before the CMake call.

You can also take a look into the azure-pipelines CI definition to see how it is done for all platforms.

It would also be possible to generate a Visual Studio project. Just call the conan install without the --profile mingw (Visual Studio must be installed on your machine). Than you can generate a Visual Studio project with CMake like you alreay did. But it will not compile to the end, as VCVRack is developed as only POSIX compatible application. For making VCVRack compileable with Visual Studio compiler, there must be added a system abstraction layer, e.g. using Poco library for this. All dependent libraries of VCVRack can already be compiled with Visual Studio compiler.

I added v1 version of 21kHz Plugins from netboy3/21kHz-rack-plugins. (binaries)

I added Meander module (PS-PurrSoftware plugin). (binaries here)