If your team uses cmake to build your projects, you can use it to generate your Understand project. It will add all of the files, setup the correct macro definitions for each file, and setup the correct include files for each file in the project. The advantage of creating an Understand project like this is that the project will be much more accurate than can be created by hand, allowing you to have easier access to all the features of our new strict parser. 

In order to use this, 

  1. Navigate to your build directory
  2. Edit CMakeLists.txt and set CMAKE_EXPORT_COMPILE_COMMANDS to ON.
  3. Run cmake again, you’ll see a file called compile_commands.json in your build directory.
  4. You can now import that json file to create an Understand project:
  5.  To import into an understand project run the following from the command line (skip “create -languages C++” for existing projects):
und -db path/to/db.udb create -languages C++ add path/to/build/dir/compile_commands.json                 settings  -c++AddFoundFilesToProject on analyze                                                                              

Update – On Windows you must use the NMake Makefiles generator. For example: 

    cmake -G “NMake Makefiles” -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                           

For a visual walkthrough of creating an Understand project from your CMake project, watch this short video: