0

I'm trying to compile a C++ project which depends on a 3rd party library, called Foo for example. I'm using the ExternalProject_Add() command in a CMakeLists.txt file for this purpose. However, this library has a dependency, called Bar for example, which must be built first. The source files of the Bar library are located in a subdirectory of the source directory of the Foo library. So, here's my question: how can I compile the Bar library and then, the Foo library with the ExternalProject_Add() command? Thank you very much for your help.

Update: I forgot to say that the Foo and Bar libraries are both CMake projects which require a configure step before the build step.

Erwan
  • 41
  • 6
  • [ExternalProject_Add documentation](https://cmake.org/cmake/help/latest/module/ExternalProject.html) says you can specify arbitrary number of build steps: `Any of the other ..._COMMAND options can have additional commands appended to them by following them with as many COMMAND ... options as needed` followed by multi-step `BUILD_COMMAND` example. – dewaffled May 20 '21 at 22:20
  • Thank you for your reply. However, if the *Bar* library needs a configure step, maybe I need an extra ```ExternalProject_Add()``` command to manage the *Bar* dependency, no? – Erwan May 21 '21 at 09:11
  • 1
    `are both CMake projects` then why not use `add_subdirectory`? – KamilCuk May 21 '21 at 09:19
  • or FetchContent ? ref: https://cmake.org/cmake/help/latest/module/FetchContent.html – Mizux May 21 '21 at 13:54

0 Answers0