I am working on configuring the build environment for a C++ project that uses multiple libraries. These libraries are independent of each other, but they all depend on the same 3rd party library (GTest) for testing. I am having some trouble determining where I should put this 3rd party library so I will have the most flexibility and modularity in my project.
The general project structure looks like this:
+---------------+ | Main Project | +-+-----+-----+-+ | | | +----+ | +----+ | | | +---v---+ +---v---+ +---v---+ | lib1 | | lib2 | | lib3 | +---+---+ +---+---+ +---+---+ | | | +----+ | +----+ | | | +-v-----v-----v-+ | GTest | +---------------+
The way I see it, I have 3 options:
Build and install GTest somewhere on my system and have all 3 libraries link to the same GTest library.
The advantage of this is I only have one copy of GTest, and the libraries don't need to know anything about each-other or about the main project.
The disadvantage is there is no standard place to put it and anyone else who wants to use any of these libraries will have to know how to install GTest themselves and where they need to install it.
Add GTest as a dependency on the Main project (maybe in an "3rdparty" folder) and link all of the libraries to the main project copy of GTest
The advantage of this is I only have one copy of GTest and it is not installed in some arbitrary location
The disadvantage is now all of the libraries have to know about the main project and would not be able to be used without the main project present. (and I would prefer to have them completely independent and usable by themselves)
Add GTest as a dependency on each individual library (each library would have a "3rdparty" folder that contains GTest)
The advantage of this is that each library is independent of the others and they all contain their GTest dependency so users of the library wouldn't need to know how to install it themselves.
The disadvantage is that I would now have 3 separate copies of GTest, one for each library. This also adds some complexity overall.
Which of these approaches is the most preferable, if any? Are there any other better approaches I simply have not considered yet?