0

How can I do it in a good practice. This is the repo structure:

~/workspace$ tree -L 3
.
├── my_program
│   ├── src
│   │   ├── module1
│   │   ├── module2
│   │   ├── CMakeLists.txt
│   │   └── ...
├── needed_library
│   ├── src
│   │   ├── module3
│   │   ├── module4
│   │   ├── CMakeLists.txt
│   │   ├── README.md
│   │   └── ...

For needed_library, I learned from the README that I can build it manually by:

mkdir build
cd build
cmake ../src
make
make install

And needed library and headers will be installed.

How can I integrate this process into my own program's CMakelists.txt? And link the desired library and header to my program?

foodtooth
  • 146
  • 8
  • Possible duplicate of [CMake link to external library](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library) At least the answers would be the same. – usr1234567 Feb 25 '19 at 08:57
  • @usr1234567 Hi, none of the answers mentioned about building third_party library in my own program and linking. They just include a directory and link the library. – foodtooth Feb 25 '19 at 09:08
  • While the third-party library uses CMake, its usage depends also on other aspects. I agree, that revealing these aspects (for include them into the question post) would be not so easy: one need to know **what exactly** is needed to be checked. And if you are able to find these things, then you rarely would ask such questions. I would suggest to look into other Stack Overflow questions: https://stackoverflow.com/questions/1485674/third-party-libraries-in-cmake, https://stackoverflow.com/questions/51564251/correct-way-to-use-third-party-libraries-in-cmake-project. – Tsyvarev Feb 25 '19 at 09:09
  • 1
    Or ExternalProject_Add – Matthieu Brucher Feb 25 '19 at 09:24
  • Thanks a lot, the links are helpful. I will try using execute_process() or ExternalProject_Add, and update my question – foodtooth Feb 25 '19 at 09:46

0 Answers0