5.3. Creating C/C++ Systems

Creating a C/C++ system is a bit more complex than creating a system for other languages. First we need to select or create a compiler definition. Then we need to define the required include directories for each module as well as the macro definitions required for conditional compilation. Sometimes it is also necessary to exclude certain compilation units from modules. The "Create New C/C++ System..." wizard gives you maximum flexibility to specify all that. But if you use CMake or Visual Studio you can also import the system more conveniently.

The first page of each C/C++ system creation wizard will allow you to select an existing compiler definition or create a new one. If you decide to create a new compiler definition the next wizard pages will guide you through this process step by step.

If you use the "Create New C/C++ System..." wizard please make sure to select the root directory of your system as the storage location for the Sonargraph folder. Only source files located directly or indirectly under this directory can be added to the system. The wizard will scan all files under this directory for "#include" statements and will try to locate the referenced include files. The scanner does NOT consider conditional compilation, so you might see lots of irrelevant unresolved include references that you can ignore safely. By adding additional include folders you can make sure that all relevant include references can be resolved.

Here are the other wizards to create new C/C++ systems:

  • System based on C/C++ CMake JSON command file: Allows to create a system out of a generated compile command JSON file.

    Name your new system and choose a directory to store it. In the next wizard page you need to choose the location of your JSON command file. To generate such a file you need to run cmake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON.

    The next wizard page presents the root directories found in the JSON file and allows you to fine tune those directories and sub-directories you want marked as root directories or excluded in the resulting system. You need to mark at least one root directory:

    Marking root directories from JSON file
    Figure 5.1. Marking root directories from JSON file


    The final page of the wizard allows to give a name to each one of the modules that will be created out of the root directories marked in the previous step. Sonargraph will try to guess a module name out of the root folder name. You are able to change that name if it should not fit.

    Naming modules for root directories from JSON file
    Figure 5.2. Naming modules for root directories from JSON file


  • System based on C/C++ Makefile command capturing files: Allows to create a system using make generated capturing files. See Section 6.2.2, “ Importing C++ Modules Using Make Command Capturing Files ”

  • System based on Sotograph command capturing file: Allows to create a system using a Sotograph command capturing file.

  • System based on C/C++ Visual Studio 2010 (or newer) Solution file: See Section 6.2.1, “ Importing C++ Modules from Visual Studio Files ”

Most wizards are similar whether you create a new system or add modules to an existing system.