-3

I'm trying to set up a chat app project and it looks like this:

project hierarchy

I've found some tutorials, but I cant find out how to set up this How would the CMakeLists.txt files look?

P.S. Maybe I'm not doing the project folder hierarchy correctly. Could you then tell me how to do it better?

  • 1
    Textual descriptions are often better than "look at this picture and hopefully you'll see the same thing I do". Try describing your problem in words so we can focus on exactly the problem you are currently experiencing. – JaMiT Jul 03 '21 at 18:35

1 Answers1

-1

To he honest, I haven't got you structure well but answering you question - this is how you make your files executable in CMakeList.txt enter image description here

What about including headers in source files, you can do it 2 ways:

  1. Include header by relative path, e.g. #include "../../include/client/client.h" What doesn't look good
  2. Include header by absolute path adding include directories in CMakeList.txt include_directories(./include/client) and include_directories(./include/server)

Note that you can write only 1 path in include_directories() unlike you could write multiple paths in add_executable().

After performing such action you can simple include your header into source files by #include "client.h" in client.cpp and #include "server.h" respectively.

See more in Quick CMake tutorial chapter 5.

Also you should know the difference between " " and <>. I'd refer to this question

qwezxc789
  • 124
  • 1
  • 8
  • Hey, thank u for your answer. It is work for me. But, i need write it: #include "../../include/client/client.h" to include file. Can i fix it? Or i should do it library? – trytobecomebetter Jul 03 '21 at 19:10
  • 1
    Please note, that Stack Overflow **discourages** using **images of code** both in a question and in an answer. – Tsyvarev Jul 03 '21 at 19:47
  • @trytobecomebetter you can write relative path, exactly as you mentioned before but there is other way (seems better to me) - adding include directories. I will edit my answer with screenshot – qwezxc789 Jul 03 '21 at 19:49