Menu

develop-cmake

Pedro Lopez-Cabanillas

Developing VMPK with CMake

In addition to the qmake based buildsystem, you may also use CMake with QtCreator or standalone from the command line shell. The first step is to download and build Drumstick with CMake, You may optionally install Drumstick, but you don't need to. Drumstick build directory may be used directly by the VMPK CMake buildsystem. The following examples assume that you are working on Linux.

Download Drumstick and VMPK

Let's suppose that you use the following directory structure for your projects, in your $HOME directory:

projects/
├── drumstick
└── vmpk

Then you need to download or checkout the source code from both projects in your projects directory

$ cd projects
$ git clone git://git.code.sf.net/p/drumstick/git drumstick
$ git clone git://git.code.sf.net/p/vmpk/git vmpk

Build Drumstick

First, create a build directory inside (or outside) the project directory. There is already one in the Git repository.

$ cd ~/projects
$ cd drumstick
$ mkdir build
$ cd build

Second, call CMake with the arguments you prefer. For instance, if you have Qt 5.15.10 installed at your home directory (~/Qt/5.15.10/gcc_64):

$ pwd
/home/username/projects/drumstick/build
$ cmake .. -DCMAKE_PREFIX_PATH=~/Qt/5.15.10/gcc_64 -DCMAKE_BUILD_TYPE=Debug
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/username/projects/drumstick/build

Finally, if the configuration is satisfactory and without errors, you may proceed to compile the libraries, execute the unitary tests, and (optionally) if everything went well, to install it:

$ make
...
[100%] Built target manpages

$ make test

Running tests...
Test project /home/username/projects/drumstick/build
    Start 1: alsaTest1
1/4 Test #1: alsaTest1 ........................   Passed    0.00 sec
    Start 2: alsaTest2
2/4 Test #2: alsaTest2 ........................   Passed    1.03 sec
    Start 3: fileTest
3/4 Test #3: fileTest .........................   Passed    0.00 sec
    Start 4: rtTest
4/4 Test #4: rtTest ...........................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   1.04 sec

$ sudo make install

Building and running VMPK

First, create a build directory like the other one:

$ cd ~/projects
$ cd vmpk
$ mkdir build
$ cd build

Second, invoke cmake providing the Qt5 and Drumstick directories (unless you have installed Drusmtick in your system).

$ pwd
/home/username/projects/vmpk/build
$ cmake .. -DCMAKE_PREFIX_PATH=~/Qt/5.15.10/gcc_64 -DCMAKE_BUILD_TYPE=Debug -DDrumstick_DIR=~/projects/drumstick/build
-- The CXX compiler identification is GNU 7.4.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- VMPK v0.7.3.99
     install prefix: /usr/local
     Build configuration: Debug
     Processor: x86_64
     Qt5: 5.15.10
     D-Bus support: ON
     Drumstick: 2.8.0
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Program pkg-config v0.29.2 found (/usr/bin/pkg-config)
-- Checking for module 'xcb'
--   Found xcb, version 1.13
-- Found XCB development libs v1.13
-- XSLTPROC Found: /usr/bin/xsltproc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pedro/projects/vmpk/build

The argument -DDrumstick_DIR=~/projects/drumstick/build is taking the Drumstick libraries directly from their build directory. You can build VMPK now using the make command and you are done. To execute VMPK before installing, you only need to define an environment variable with the location of the Drumstick plugins:

$ export DRUMSTICKRT=~/projects/drumstick/build/lib/drumstick
$ src/vmpk

Note: translations and other data files won't work until you install the program on your system.

That's all. Happy hacking!


Related

Wiki: develop

MongoDB Logo MongoDB