CLion 2018.2 Help

Managing Included Files

In CLion, it is unnecessary for an included file to be presented in CMakeList.txt, compile_commands.json, or build.gradle, to be recognized as a project file. This means you don't need to explicitly add such included header or source files to get the full code insight that CLion provides.

The only limitation here is for the files you include to be located under the project root (and therefore visible in the Project Tool Window).

CLion treats these included files similarly regardless of the project format (CMake, compilation database, or Gradle). See Managing CMake Project Files for a Cmake example, or find the corresponding compilation database example below:

  • Suppose the project consists of one source file main.cpp and two header files Header1.h and Header2.h. The compile_command.json therefore includes only one command entry for main.cpp.

    main.cpp also includes another source file IncludeCPP.cpp. As you can see, this file is added to the project tree (marked with a clion icons FileType cpp icon) and is treated by CLion as a regular project file:

    cl noncompdb includes
Last modified: 10 August 2018