CLion 2019.2 Help

Manage Project Files

Included files

When you include header or source files located under the project root into any project file, CLion treats them as project files as well. You do not need to list such includes in CMakeLists.txt directly to get full code insight and refactoring functionality for them. Note that standard or third-party libraries located outside of the project root are not affected.

Non-project files

When a source or header file is not included in any of the project files or CMake targets, and is not located under the source or library roots, CLion notifies you about it:

cl fileWIldMessage

You need to specify that file as a project one explicitly. Use one of the following approaches:

  1. When the source files that don't belong to any target are located under the project root, add them to a target using add_executable() or add_library() command depending on the target type.

    For example, the above screenshot illustrates the situation when add executable() contains only the main.cpp Header1.h Header2.h files and knows nothing about add.cpp. In this case, add.cpp can be added to the list of sources as follows:

    add_executable (TestProject main.cpp Header1.h Header2.cpp add.cpp)

  2. If the directory that contains non-project sources is located under the project root, you can mark it as library: in the Project tool window, right-click the directory and select Mark Directory As | Library Files from the context menu.

  3. For library files located outside the project root, specify the header search paths so that CLion can index the required directories and provide code completion and navigation facilities on #include statements:

    include_directories( ${MY_EXTERNAL_SOURCE__DIR})

    For more details, refer to our Quick CMake Tutorial.

Upon any of these actions, CLion will prompt you to reload CMake project if automatic reload is not enabled.

Last modified: 22 August 2019