2

I have a large pre-compiled c++ code base organized like so:

Project0/
   libA/
      include/
      libA.so
      libADependencies.txt     -> depends on libB
   libB/
      include/
      libB.so
      libBDependencies.txt     -> depends on libC
Project1/
   libC/
      include/
      libC.so
      libCDependencies.txt     
...

None of these projects are built using cmake.

I am writing a new piece of code built with cmake, that depends on some of these libraries.

I know my dependencies (let's assume libA here), and each dependency also knows its own dependencies (e.g. libA depends on libB, libB depends on libC). Note that there are no external dependencies. Everything is here, in these folders.

I was thinking about writing a bunch of FindProjectX.cmake scripts, that would create a cmake package per project, containing one imported target per library. I would end up with imported targets like Project0::libA, Project0::libB, Project1::libC, etc.

That's all well and good, but I am not sure how to handle the dependencies of my dependencies in my FindProjectX.cmake files. Can I just call find_package(Project1 REQUIRED COMPONENTS libC) from FindProject0.cmake?

Note that I have many such libraries and projects. I intend to write a python script to auto-generate these FindProjectX.cmake scripts.

Touloudou
  • 2,079
  • 1
  • 17
  • 28
  • 1
    "Can I just call find_package(Project1 REQUIRED COMPONENTS libC) from FindProject0.cmake?" - Yes, many Find scripts do that. – Tsyvarev Jan 31 '20 at 11:45

0 Answers0