Can I call cmake from my module build phase for a sub project?

Hi!

So I haven’t updated Surge since 1.7 in the rack world. There’s a lot we’ve added to surge proper since (loads of new FX, loads of new filters, etc…) and I’m wanting to sort of spend a bit of time to revisit our rack modules as we release our new version this fall.

The primary reason I haven’t updated since 1.7 is, with our later versions our build configuration got a bit more complicated and is all handled by cmake. Replicating that in the rack makefiles was just painful. But I sort of don’t have to if I can call cmake on a dep at build time. Surge builds all of its DSP code into a single shared library on all platforms rack supports easily with a single command.

So my question is: If I change my rack modules makefile from ‘building surge’ to ‘having a dep phase where it runs cmake’ will that

  1. Cause me to get bumped from the community library
  2. Break anything for your processes
  3. Generally be frowned upon

or am I on reasonable grounds with my surge-rack package treating rack as a dep which happens to build with cmake rather than enumerating sources or configure?

And if so, anyone have an example of doing this that has worked for them?

No rush. I wouldn’t turn to this until later in our current cycle. But was wondering just today.

Thanks so much!

Try it n the official build system? You can get it here: GitHub - VCVRack/rack-plugin-toolchain

It should work if you build Surge with CMake, then producing a static or shared library, then linking this library with the main VCV plugin. I don’t have any examples, but it should be matter of adding the corresponding build and link flags in the plugin Makefile.

The make dep phase could call cmake (in a subdirectory of the build directory) and compile and install the surge libraries in a know location. Ideally, the only extra requirement would be having CMake installed, which I don’t think is a big issue.

You can use Cmake for dependencies in your Rack plugin Makefile. Rack’s Makefile system has explicit Cmake support, and you should use the $(CMAKE) command instead of cmake. Example:

# Define the path of the built static library
libsurge := surge/build/libsurge.a
# Build the static library into your plugin.dll/dylib/so
OBJECTS += $(libsurge)
# Trigger the static library to be built when running `make dep`
DEPS += $(libsurge)

$(libsurge):
	# Out-of-source build dir
	cd surge && mkdir -p build
	cd surge/build && $(CMAKE) ..
	# Install to dep/
	cd surge/build && $(MAKE) install

We can add other build tools to rack-plugin-toolchain if they are reasonably needed, to allow any external C/C++ library to be used in your Rack plugin.

1 Like