Let me try and be clearer, you might end up more confused though! lol
My application consists of a load of shared libraries and plugins. The main application is nothing more than a plugin loader, it loads the plugins in the right order so that dependencies are recolsved.
So I have a folder structure that is like
src
src/lib
stc/lin/shared lib 1
…
stc/lin/shared lib n
src/application
src/components
src/compoentts/shared library 4
…
src/components/shaed library 5
The components are a shared library with a metadata stub inside them which provides the dependencies
The lib folder consists of a load of libraries which are both mine and third party.
There’s cmake include file which contains a lot of macros to hide away the complexity, it is basically a meta language.
Now I have this library I want to use, it does not have a CMakeLists.txt, so I have been trying to find a way to populate arc/the lib/libinquestion, following the suggestion above I used the FetchContent module to download this libraries tar ball and copy over my CMakeLists.txt.
The first issue I had was that the tarball is in has a root folder of coollibrary-1.2.3, this is no good for me, I need it to be in the folder.
Now the suggestion above, worked, I was able to exact the library archive to coollibrary and inside that is a src folder, so I now can just tell my CMakeLists.txt file for this library which source files need to be compiled. That again works with the solution presented above.
The issue I have now, is that as the CMakeLists.txt nest, they expose certain variables to each level of the script, these are important for me because of the architecture of the application, it builds to a bin/x86_64 and creates subdirectories any places the libraries and components in the correct place so that the application will run,
what I can’t seem to do is pass variables that have been defined up the build tree into this module. Lets say the CMakeLists.txt in src/lib addds the subdirectories by adds a variable called SHARED_LIB_FOLDER which code further down the tree can use.
This works perfectly in the general sense, but as soon as I use the FetchContent none of the variables are inherited and now I don’t know where to put files.
What I need is a way to adding libraries to my src/libs in such a way that variables get passed to it.