Clion Cmake

Clion uses CMake as its default build system. It has an integrated plugin with OpenOCD so we can download / run / debug our code on STM32 microcontrollers. Clion integrates with CMake nicely and I have used it here for the cross compiling. I assume you already have a CMake project and have some CMakeLists files etc. Create a new directory for the cmake toolchain file or put it in the root directory. Call this file anything you like with a.cmake extension.

  1. Clion Use Latest Cmake
  2. Cmakelists Example
  3. Clion Cmake Install
  4. Clion Cmake Options

For CMake projects in CLion, a toolchain is a set of all the necessary tools required for building and running your application: the working environment, the CMake executable, the make tool and compilers, and the debugger.

Clion cmake x64

Clion Use Latest Cmake

When you start working with CLion, you already have a default toolchain available. Although you can use it in development, you may also want to adjust the set of tools for the needs of your project (for example, change the working environment or switch to another compiler).

You can always have multiple toolchains for one project and switch between them when needed.


Cmakelists Example

Clion linux cmakeClion Cmake

Clion Cmake Install


Create a new toolchain

Clion Cmake Options

  1. Go to Settings / Preferences Build, Execution, Deployment Toolchains and click to add a new toolchain.

  2. On Windows, choose your working Environment: MinGW, Cygwin, Visual Studio, WSL, or Remote Host. For more details on how to configure CLion on Windows, take a look at our tutorial.

    On Linux or macOS, choose the type of your toolchain - System for local projects or Remote Host for Full remote mode.

  3. Select the preferred CMake installation, either the bundled one or a custom version of your choice.

  4. The CMake executable that you set up on the previous step attempts to detect the make utility and the C/C++ compilers. These installations are not defaults, but the ones that CMake detects considering all the packages installed on your system at the moment.

    If you prefer to use custom make and compilers instead of the detected ones, use the fields Make, C Compiler, and C++ Compiler to provide the paths. See Switching compilers.

    If you are using the GNU ARM toolchain, make sure it's presented in your system PATHDrobo plex. (see Embedded development: toolchains and compilers ).

    For the IAR toolchain, specify the compilers as described in IAR toolchain.

  5. Finally, specify the Debugger. On Windows, you can choose between the bundled or custom GDB. On macOS and Linux, CLion also includes the LLDB debugger (default for macOS). See the currently supported versions.

  6. CLion verifies your choices and notifies you if any of the tools or packages are missing.

  7. When the configuration is completed, click OK to save it. Now you have one more toolchain to use when creating a CMake profile.