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 Conan and CMake build setup for the Fundamental Plugin (not yet published)
  • added Azure CI pipeline setup for automated building of VCVRack on Azure for Linux, MacOS and Windows with Conan and CMake

The work is based on the current v1 branch development.
I created a Pull Request in my own repository https://github.com/qno/Rack/pull/5 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 ../Rack - under Windows please call activate_run.bat and cmake -G "MinGW Makefiles"..\Rack
  • Build VCVRack with cmake --build .

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 please copy the following files into the directory containing the Rack executable:

  • the VCVRack res folder
  • template.vcv
  • Core.json
    Under Windows please copy also the following files (should be located under C:\.conan\data\mingw_installer\1.0\conan\stable\package\172e8aacd31e5c3838e00a3ed4fe3ef6c53f3122\bin):`
    • libgcc_s_seh-1.dll
    • libstdc++-6.dll
    • libwinpthread-1.dll

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

When I build VCVRack with the above steps I still have some troubles running VCVRack under Windows 10 and Linux (Ubuntu 19.04). The first issue I have is that somehow letters in the UI are not rendered correct or are just missing at all.
The Fundamental Scope Plugin (v1 branch) is always crashing and the Debugger tells me it happens if it tries to calculate the “statistics”.
I don’t know if it also happens with the normal build and it is just an development issue (it probably should).

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 manually

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

  • cd into the Rack source directory
  • Execute conan create . qno/testing - under Windows please use conan create . qno/testing --profile mingw
  • Clone the Fundamental Plugin git clone https://github.com/VCVRack/Fundamental.git and switch to the v1 branch git checkout v1
  • Add the following conanfile.txt to the checked out Fundamental source directory:
[requires]
VCVRackSDK/latest@qno/testing
libsamplerate/latest@qno/testing

[generators]
cmake
virtualrunenv

[options]

[imports]
  • Add the following CMakeLists.txt to the checked out Fundamental source directory:
cmake_minimum_required(VERSION 3.5)

project(VCVRackFundamentalPlugin)

set(CMAKE_CXX_STANDARD 14)

# Do not change the LIB_NAME!
set(LIB_NAME plugin)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

file(GLOB_RECURSE SOURCES src/*.cpp src/*.c)
file(GLOB_RECURSE HEADERS include/*.hpp include/*.h)
source_group("Header Files" FILES ${HEADERS})

# https://cmake.org/cmake/help/latest/command/add_library.html
add_library(${LIB_NAME} MODULE ${SOURCES})

if (MSVC)
   target_compile_definitions(${LIB_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS _USE_MATH_DEFINES ARCH_WIN)
endif ()

target_link_libraries(${LIB_NAME} ${CONAN_LIBS})

set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
  • Create a build directory and cd into it
  • Execute conan install ../Fundamental - under Windows please use conan install ..\Fundamental --profile mingw
  • Execute CMake cmake ../Fundamental - under Windows please call activate_run.bat and cmake -G "MinGW Makefiles"..\Fundamental
  • Build Fundamental Plugin cmake --build .
  • create the Fundamental Plugin (Fundamental.zip) dist and place it in the dir of the Rack executable
    • create somewhere a directory called Fundamental copy the following files into it
    • plugin.[dll|so|dylib]
    • the res folder
    • the plugin.json file
    • create a zip file of the created Fundamental folder
  • run the Rack executable

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.