CLion 2024.1 Help

Meson projects

In CLion, you can create, open, build, and run/debug Meson projects. Meson support works on all platforms and for all local and remote toolchains, including WSL and Docker.

Install Meson

  1. Follow the official installation guide to install Meson on your system.

Create a Meson project

  1. Select File | New | Project from the main menu or click New Project on the Welcome screen.

  2. In the left-hand pane, select Meson.

  3. Specify the project name and type, and select the language standard:

    Meson project wizard
  4. Click Create.

    CLion will generate a simple project containing main.cpp and meson.build:

    A new Meson project

Open a Meson project

  1. Select File | Open from the main menu or click Open on the Welcome screen.

  2. Point CLion to the directory containing meson.build and click Open.

    CLion will load the Meson project structure and show the results in the Build tool window:

    Meson project loaded

Meson tool window

To open the Meson tool window, click on the right-hand toolbar or select View | Tool Windows | Meson from the main menu.

In this window, you can find the list of build targets, and useful commands, like clean, install, test, configure, and others:

Meson tool window

Double-click on a command or target to run it. The tooptip on hover will show the exact command that will be applied:

Meson tool window tooltips

Use the toolbar to perform project actions and quickly access the project settings:

Meson window toolbar

    Meson project settings

    1. Go to Settings | Build, Execution, Deployment | Meson or click in the Meson tool window.

    2. Use this dialog to configure the following:

      • Toolchain — select one the configured toolchains.

      • Meson executable — specify a custom Meson executable, if required.

      • Setup options — use this field for additional Meson commands, such as --native-file.

      • Build directory — check or change the build directory.

      • Build options — provide additional build options, if required.

      Meson settings

    Edit meson.build with assistance

    • CLion highlights the code in meson.build scripts. To adjust the color scheme, go to Settings | Editor | Color Scheme | Meson.

      Highlighting in meson.build
    • You can use the Structure view to navigate to targets, dependencies, and option commands in meson.build and meson_options.txt.

      Press Alt+7 to open the Structure tool window or Ctrl+F12 to open the Structure popup.

      Meson.build file structure

    Reload the project

    • When you make changes in meson.build, CLion shows an icon suggesting to reload the project:

      Reload project icon

      Click the icon or press the shortcut.

    • Alternatively, click in the Meson tool window.

      Another option is to use the Tools | Meson menu:

      Meson menu actions

      Select Wipe and reload Meson Project to perform a wipe before reload.

    Run/debug configurations for Meson

    • CLion detects the project build targets and creates the Native Application configurations for them:

      Meson project configurations
    • In the main menu, go to Run | Edit Configurations to set up additional parameters if required:

      Native Application configurations for Meson

    Build, run, and debug

    • Use the actions in the Build menu to build the project or the selected configuration.

      The Build menu
    • To run or debug your program, you can use the configuration widget (click or ), the Run menu, or the gutter icons next to the program's entry point:

      Gutter icon for run/debug

      Refer to Run applications and Debug for more information.

    Last modified: 22 April 2024