You can see the results of this process in the Build tool window. Otherwise you can open the compile_commands.json file directly and select Open as Project:Īfter that CLion will automatically create a project from this file and import all its contents. To do so, simply open the directory that contains the file in CLion. Now that you have a compile_commands.json file, you can use it to create a CLion project. Note: If you accidentally deleted the compile_commands.json file, it can be regenerated by invoking Meson reconfiguration ( meson -reconfigure ). In this command, -t compdb instructs Ninja to generate compile_commands.json instead of building the project and -x tells Ninja to expand response files ( rspfile) during database generation (available since version 1.9), while c_COMPILER and cpp_COMPILER are the names of Ninja rules generated by Meson. Ninja -t compdb -x c_COMPILER cpp_COMPILER > compile_commands.json. If, for some reason, Meson doesn’t generate compile_commands.json, you can use Ninja. Compilation database generation is provided by Ninja, rather than by Meson itself. Meson will automatically place compile_commands.json inside the generated build directory. You don’t need to perform any additional steps to generate the compilation database from a Meson project. Other backends (Visual Studio and Xcode ) do not support compilation database generation. Note: compile_commands.json can only be generated if Ninja is used as the backend build system. Many build systems offer the ability to generate compilation database files ( compile_commands.json), and Meson is one of them. CLion has natively supported compilation database projects since version 2018.2. However, it has gained popularity in general C/C++ tools as a simple yet powerful way to describe project files. It was originally introduced as a part of Clang tooling. What are compilation databasesĬompilation database is a simple JSON file format for associating compilation flags with files in a project. However, as always there are some important details to discuss. Generate a compile_commands.json file from your project. To open a Meson project in CLion, you just need to perform two simple steps: Steps described here can be reproduced on Windows (including all available toolchains), Linux, and macOS. Note: In this post we will use the DPDK project as an example. However, in this blog post we’ll describe how you can use compilation databases to set up your Meson project in CLion in just a couple of simple steps. CLion currently does not natively support Meson projects. Recently Meson has started to gain popularity among C++ developers. It converts build scripts written in a Python-like language into one of the backend build systems: Ninja (the default and recommended one), Visual Studio, or Xcode. Meson is a relatively new build system that strives to be fast yet simple to use. For this we will use compilation database support in CLion. Today we are going to show you how you can already use Meson-based projects in CLion. During the recent Q&A session on Reddit, we got a surprising number of questions about our plans for Meson support.
0 Comments
Leave a Reply. |