8.4.3. Local Analyses with CMake and Eclipse

8.4.3.1. Background

Your project is built using cmake and you are using the IDE Eclipse with the Axivion Eclipse Plugin.

8.4.3.2. What can be configured?

You can setup

  • analysis of your project on your local development machine, in contrast to the analysis on the CI server

  • analysis of a single file and display of warnings in Eclipse

8.4.3.3. What needs to be done?

The recommend approach to set Local Build and Single File Analysis is:

  1. Using CMake, setup a separate out-of-source build tree with one of the generators for GNU make or for ninja. See CMake for details.

    Specify -DCMAKE_EXPORT_COMPILE_COMMANDS=1 when calling CMake (or put set(CMAKE_EXPORT_COMPILE_COMMANDS Yes) inside your CMake conguration files) to have it generate a file compile_commands.json that can be used to re-run the compilation of a single unit.

  2. Install the Axivion Eclipse Plugin (follow instructions in Eclipse Plugin). Make sure to configure BAUHAUS_CONFIG in the project settings to point to your project configuration. This will select the compiler profile and the set of stylechecks to be run.

  3. Follow the instructions for the Eclipse Plugin’s Makefile Integration to setup the single-file analysis

    1. Enable the “Make Command for Single File” (using the check box on the right).

    2. “Build Working Directory”: set to the same directory as the option /Project/directory configured in axivion_config.

      (Note: use Eclipse variables to specify this relative to e.g. the root directory of the Eclipse project like ${project_loc}/..).

    3. “Source Basepath”: use the same value as for “Build Working Directory”.

    4. Configure “Make Command for Single File” to:

      build_compile_commands --single_file ${axivion_ir_file}.${axivion_src_ext} <path-to-build-tree>/compile_commands.json

      using the CMake-generated out-of-source build directory as <path-to-build-tree> (can be relative to “Build Working Directory”).