0

I have a lot folders from sources which contents .cpp and .h files. Each folder contains CMakeLists.txt file except folders which contents .h headers files. I see the several ways.

  1. The first way is consist from take advantage of add_library(myLib1 STATIC /link/to/sources/somefile.cpp /link/to/sources/interfaces/somefile.h). But in this way I will have a lot strings when is't good way, I think. Because I have very more files, which are interconnected.

  2. The same way, with that exception when use set(HEADERS /link1 /link2 ....) and set(SOURCES /link3 ...) and than add_library(myLib ${HEADERS} ${SOURCES}).

I think than both the ways is't do properly. I don't know how I can connect the folder with library into my project, because if include this using the above methods it's will take a long time and is't beautiful

Mizux
  • 8,222
  • 7
  • 32
  • 48
Vando
  • 11
  • 2
  • You don't have to list headers. – arrowd Apr 02 '21 at 18:33
  • Do you ask about the way to specify **all files** in a given directory as **source** files for the library? If yes, then see that question: https://stackoverflow.com/questions/3201154/automatically-add-all-files-in-a-folder-to-a-target-using-cmake. – Tsyvarev Apr 02 '21 at 18:45

0 Answers0