Update: meson and CLion

In a previous blogpost I walked you through a quick setup of using meson in combination with CLion. Shortly afterwards I stumbled across a cool project which promised to bring all the nice integrations CLion offers over to any meson project.

Sadly the project itself seemed to be abandoned, and no updates happened for some time. meson in the meanwhile did receive some updates, and so the inevitable breakage happened. For example

Traceback (most recent call last):
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/bin/mcw", line 10, in <module>
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/main.py", line 6, in main
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/cmake.py", line 66, in run
    raise e
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/cmake.py", line 59, in run
    getattr(self, self.command + '_cmd')()
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/cmake.py", line 182, in generate_cmd
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/cmake.py", line 466, in gen_codeblocks_project
    output = os.path.join(self.meson.build_dir, self.meson.get_target_filename(target))
  File "/home/sunqi/.pyenv/versions/anaconda3-5.2.0/lib/python3.6/site-packages/mcw/meson.py", line 232, in get_target_filename
    return target['filename'][0]
IndexError: string index out of range

Luckily a fork which fixed this issue already existed. I then forked to fork to fix some more issues that cropped up in the meanwhile.


To install you need a recent version of python (which you should anyways if you are running meson).

$ pip3 install --user git+https://gitlab.com/WanzenBug/meson-cmake-wrapper.git

This will install a command mcw, which can be used as a drop-in replcement for cmake. If a meson.build file is present, mcw will do its magic, if not it will fall back to using the system cmake command.

To configure CLion to use it, you need to update your toolchain settings:

  1. Head to your Settings -> Build, Execution, Deployment -> Toolchains
  2. Set the cmake version from "Bundled" to custom and add the path to mcw And that's it.