[CMakeLists] Include .h for completion

Answered

Hello, 

I'm trying to create a CMakeLists, i'm working in C and that's my project architecture:

|

\/

CMakelist

|__src

    |__core

        |__ .c files

    |__tools

        |__ .c files

    |__others things...

        |__ .c files

    |__main.c

|__Include

    |__my_lib

       |__ .h files

|__lib

      |__ my_lib.a

      |__ .c lib files

 

I use a MakeFile to compile my project and i use the flag "-I ./include" to include my .h files like that in my .c files project "my_lib/file.h" and not like that "../../include/my_lib/file.h" but i don't know how to create my CmakeLists to get the completion in my .c files in my src folder.

 

Thanks for your help 

0
1 comment

Hello!

To figure out available preprocessor definitions CLion uses CMake targets, so in order to get files properly highlighted etc. you need to add them to some CMake target.

You have two ways to fix it:
• Explicitly add header files to some CMake target (which is not needed by CMake itself, but doesn't do any harm);
• Right-click on the containing folder and choose "Mark Directory As | Project Sources and Headers" (you might do it for the root directory if your project doesn't have 3rd-party components inside).

0

Please sign in to leave a comment.