Search code examples
cmakeclion

CLion / CMake Multiple include directories issue


I'm trying to build multiple executable with some source in common. My source tree looks like this :

root
 - CMakeLists.txt
 - 00 - common
   - CMakeLists.txt
   - include
     - Window.h
   - sources
     - Window.cpp
 - 01 - sample
   - CMakeLists.txt
   - include
   - sources
... and so on

In my root CMakeLists.txt I do add_subdirectory to include common and all the samples, the common part is built as a static library.

The compilation works fine in command line and also on CLion. The problem is that CLion don't understand the structure, when I include Window.h inside Window.cpp of the "common" folder, CLion don't know it, but it offer to use "../include/Window.h" using the auto-completion.

enter image description here

In the CMakeLists.txt of "common" folder I do:

add_library(common STATIC ${sources})
target_include_directories(common PUBLIC "include")

I also tried to use the standard method with include_directories() without success.

What I did wrong ?


Solution

  • Ok after trying to reproduce the problem, I figured out that the folder name accept space but not dashes

    Removed the dashes from folder names fixed the problem