Whenever I wanted to include a directory that was outside of my project with Clion, I would use the -I somedir flag. However, this time I want the hierarchy to be like this:
/project CMakeLists.txt /src /Graph Graph.h Graph.cpp /Dijkstra Dijkstra.h Dijstra.cpp
I need my code in the /src directory. And not only that, but, for example, inside the Dijkstra.h file, I want to include Graph.h as follows: #include "Graph/Graph.h and not so: #include "../Graph/Graph.h .
If I add only the -I src flag, then if I am inside the Dijkstra.h file, and I would like to include Graph.h , I would have to write #include "../Graph/Graph.h , which is not what I want .
So I also tried adding INCLUDE_DIRECTORIES(src) . This fixed the problem above, however when I tried to compile I got a linker error of undefined reference to...
So, I tried to add the files one by one as follows:
set(SOURCE_FILES src/Dijkstra/Dijkstra.h src/Dijkstra/Dijkstra.cpp src/Graph/Graph.h src/Graph/Graph.cpp) add_executable(someprojectname ${SOURCE_FILES})
and this led to a previous problem when I had to include the following files: #include "../Graph/Graph.h" .
How can I do it right to get the behavior I want?
source share