CMake — сборка исполняемого файла и зависимостей в плоской иерархииC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 CMake — сборка исполняемого файла и зависимостей в плоской иерархии

Сообщение Anonymous »


Я изучаю CMake и пытаюсь понять, как можно связать статические библиотеки, которые являются отдельными проектами, с исполняемым файлом, а затем настроить корневой проект для правильного сбора зависимостей для всех целевых исполняемых файлов и сборки всех исполняемых файлов.
>
Моя иерархия такая:

Код: Выделить всё

.
├── app
│   ├── CMakeLists.txt
│   ├── build
│   ├── include
│   └── src
│       └── main.cpp
├── square
│   ├── CMakeLists.txt
│   ├── build
│   ├── include
│   │   └── lolerji_square.h
│   └── src
│       └── lolerji_square.cpp
└── CMakeLists.txt
Now, my goal is to have several different apps in this hierarchy similar as to and many static libs such as . Each app may reference any static libs in this hierarchy. However, I have no clue how I might configure

Код: Выделить всё

CMakeLists.txt
files.
The goal is, to allow each dependency to be separately maintained, while when building the executables, each dependency is compiled from the source if necessary. I want to achieve this with the most modern approach as possible. Specifically, I want to avoid using

Код: Выделить всё

add_subdirectory()
and

Код: Выделить всё

include_directories()
if possible, as from what I understood they might introduce shenanigans I'd rather avoid.
I am fairly new at CMake, and my approach to this might be wrong. Even so, I would be happy to know if this is achievable, if so how, and if it is not the recommended approach to this kind of problem, what would be the best approach.


Источник: https://stackoverflow.com/questions/781 ... -hierarchy
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»