Я изучаю CMake и пытаюсь понять, как можно связать статические библиотеки, которые являются отдельными проектами, с исполняемым файлом, а затем настроить корневой проект для правильного сбора зависимостей для всех целевых исполняемых файлов и сборки всех исполняемых файлов.
>
Моя иерархия такая:
Код: Выделить всё
.
├── app
│ ├── CMakeLists.txt
│ ├── build
│ ├── include
│ └── src
│ └── main.cpp
├── square
│ ├── CMakeLists.txt
│ ├── build
│ ├── include
│ │ └── lolerji_square.h
│ └── src
│ └── lolerji_square.cpp
└── CMakeLists.txt
Код: Выделить всё
appКод: Выделить всё
squareКод: Выделить всё
CMakeLists.txtThe 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()Код: Выделить всё
include_directories()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
Мобильная версия