I'm wondering how to manage dependencies of an external project. Let's say I have three projects, each one in a different repository:
Each project with its CMakeLists.txt. Using find_package and defining paths on CMake I can build each project without problems and install it (I followed this tuto to build .cmake files for libraries)
Now I'm trying to make this process as easy as possible and I'm introducing the ExternalProject_Add macro, this way people will only have to clone Executable repository and with the help of CMake files Lib1 and Core are also downloaded, compiled and linked.
The problem is that Executable and Lib1 depends on Core but I want it to be cloned (and compiled) only once. Here is the problem:
I don't know if there is a documented way to work with this kind of project tree or shall I write some kind of workaround when Core is included as dependency of an external project in order to avoid the use of core-targets.cmake file.
Thanks!
Solution
I realized that when using ExternalProject_Add it downloads, builds and INSTALL the project so, in the install-folder, I already have all the files needed to compile its dependants.
So I can manage this issue following these steps (also for build order):
I would add two convenience projects to Executable, which would be contained in subfolders and make use of ExternalProject_Add
.
add_subdirectory( CoreWrapper ) # Use ExternalProject_Add here
add_subdirectory( Lib1Wrapper ) # Use ExternalProject_Add here
Now you can either add dependencies to Executable, so that everything gets installed before Executable is build or you work directly with the binaries contained in the build folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With