Clion Vs Eclipse

Posted : admin On 1/25/2022

Apart from being a standalone tool, clang-tidy is integrated intovarious IDEs, code analyzers, and editors. We recommend using clangd whichintegrates clang-tidy and is available in most major editorsthrough plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more).

Features Eclipse IntelliJ IDEA CLion Visual Studio VS Code What's New Install SonarLint in your IDE SonarLint is a free IDE extension and is available directly from your favourite IDE marketplace. Microsoft Visual Studio. Microsoft Visual Studio is an integrated development environment (IDE).

The following table shows the most well-known clang-tidyintegrations in detail.

Feature
ToolOn-the-fly inspectionCheck list configuration (GUI)Options to checks (GUI)Configuration via .clang-tidy filesCustom clang-tidy binary
A.L.E. for Vim+---+
Clang Power Tools for Visual Studio-+-+-
Clangd+--+-
CLion IDE+++++
CodeChecker----+
CPPCheck-----
CPPDepend-----
Flycheck for Emacs+--++
KDevelop IDE-++++
Qt Creator IDE++-++
ReSharper C++ for Visual Studio++-++
Syntastic for Vim+---+
Visual Assist for Visual Studio++---

IDEs

CLion 2017.2 and later integrates clang-tidy as an extension to thebuilt-in code analyzer. Starting from 2018.2 EAP, CLion allows usingclang-tidy via Clangd. Inspections and applicable quick-fixes areperformed on the fly, and checks can be configured in standard command lineformat. In this integration, you can switch to the clang-tidybinary different from the bundled one, pass the configuration in.clang-tidy files instead of using the IDE settings, and configureoptions for particular checks.

KDevelop with the kdev-clang-tidy plugin, starting from version 5.1, performsstatic analysis using clang-tidy. The plugin launches theclang-tidy binary from the specified location and parses itsoutput to provide a list of issues.

QtCreator 4.6 integrates clang-tidy warnings into the editordiagnostics under the Clang Code Model. To employ clang-tidyinspection in QtCreator, you need to create a copy of one of the presets andchoose the checks to be performed. Since QtCreator 4.7 project-wide analysis ispossible with the Clang Tools analyzer.

MS Visual Studio has a native clang-tidy-vs plugin and also can integrateclang-tidy by means of three other tools. The ReSharper C++extension, version 2017.3 and later, provides seamless clang-tidyintegration: checks and quick-fixes run alongside native inspections. Apartfrom that, ReSharper C++ incorporates clang-tidy as a separatestep of its code clean-up process. Visual Assist build 2210 includes asubset of clang-tidy checklist to inspect the code as you edit.Another way to bring clang-tidy functionality to Visual Studio isthe Clang Power Tools plugin, which includes most of theclang-tidy checks and runs them during compilation or as a separatestep of code analysis.

Editors

Clion Vs Eclipse Vs

EclipseClion vs eclipse tires

Emacs24, when expanded with the Flycheck plugin, incorporates theclang-tidy inspection into the syntax analyzer. For Vim, you canuse Syntastic, which includes clang-tidy, or A.L.E.,a lint engine that applies clang-tidy along with other linters.

Analyzers

clang-tidy is integrated in CPPDepend starting from version 2018.1and CPPCheck 1.82. CPPCheck integration lets you import Visual Studiosolutions and run the clang-tidy inspection on them. TheCodeChecker application of version 5.3 or later, which also comes as a pluginfor Eclipse, supports clang-tidy as a static analysis instrument andallows to use a custom clang-tidy binary.

Open a project

To open an existing CMake project in CLion, do one of the following:

Eclipse
  • Select File Open and locate the project directory. This directory should contain a CMakeLists.txt file.

  • Select File Open and point CLion to the top-level CMakeLists.txt file, then choose Open as Project.

  • Select File Open and locate the CMakeCache.txt file, then choose Open as Project.

Create a new project

  1. If no project is currently opened in CLion, click New Project on the Welcome screen. Otherwise, select File New Project on the main menu.

  2. In the New Project dialog that opens, select the target type of your project (executable or library), and the language to be used (pure C or C++). CLion will generate the top-level CMakeLists.txt file based on the provided settings.

As an example, let's create a simple shared library assuming the C++14 standard.

  1. Click New Project from the Welcome screen or the File menu.

  2. In the left pane, choose C++ Library.

  3. In the right pane, set the location and the name of your project. You can type the path in the text field or click to browse for the desired folder.

  4. Click the Language standard control and select the standard from the drop down list (C++14 in our example).

  5. Use the Library type control to select the library type (shared in our example).

  6. Click Create to create a project and generate the corresponding CMakeLists.txt file:

You can set up a CMake profile to be used for all new projects by default (File New Projects Settings Settings for New Projects Build, Execution, Deployment CMake ).

Create a CMake project from sources

To work with non-CMake sources in CLion, you can convert them into a CMake project structure.

Clion Vs Eclipse

  1. On the main menu, choose File Open and select the project root folder.

  2. Open a source file in the editor.

  3. If there is no top-level CMakeLists.txt file, CLion will suggest creating it:

    The Create CMakeLists.txt action appears only when there is no CMakeLists.txt under the project root, disregarding the subfolders' CMakeLists.txt files.

    If there is a CMakeLists.txt file under the root, the only available action will be Select CMakeLists.txt.

  4. In the Create CMakeLists.txt dialog, specify the following:

    • Select project files- select the files to be imported as project files. Use the subdirectories checkboxes to import their entire contents or clear the checkboxes to import the contents selectively.

    • User Include Directories- select the directories to be included in the project and specified in the CMake include_directories command. CLion includes a directory automatically when it contains at least one header file, if it is named include, or when it has subdirectories that contain header files only.

      Note that directories not selected in the Select Project Files pane are not presented in the User Include Directories list - select them first, and then the available include directories will appear in the list.

Work with a monorepo

Clion Vs Eclipse Tires

Monorepos are repositories that combine multiple projects, usually without a top-level CMake script. Instructions below describe how to work with a monorepo in CLion using LLVM Project as an example.

  1. Call File Open and point CLion to CMakeLists.txt in the required subdirectory. For the case of LLVM, select llvm-project/llvm/CMakeLists.txt.

    In the dialog that opens, click Open as Project.

  2. Go to Settings/Preferences Build, Execution, Deployment CMake and use the CMake options field to add the sub-projects that you want to build additionally.

    For example, to add clang and clang-tools-extra, specify -DLLVM_ENABLE_PROJECTS=“clang;clang-tools-extra”:

    Project reload should perform successfully at this point.

  3. To be able to view the entire repository in the Project tree, change the project root: call Tools CMake Change Project Root from the main menu and select the top-level repository folder, llvm-project.

  4. We also recommend that you build the project. This way, resolve will work on the entire codebase, including the parts generated at build time.