Problem
How can I distribute a c library as source code along with the source code of libcurl and let the consumer of the library handle building it as needed?
Context
I have a C library that I distribute as source and let the clients handle building it along with their code.
The repo includes the source for a dependency as well, tinyxml, which is built along with the library itself thus becoming completely transparent for the clients.
It has worked fine up to now but clearly does not scale well for more complex dependencies, such as libcurl.
Things I've considered as an alternative to bundling libcurl's source
- have pre-compiled libraries of libcurl. But I don't know which platforms/flags the consumer is going to use
- have libcurl installed on the build machine. It would require extra setup steps for the consumer, it won't be just pulling the code and using
CodePudding user response:
You didn't mention which build system are you using.
If you are using cmake
, you can make use of ExternalProject_Add
to download/build/install the dependent library.
See examples: https://cmake.org/cmake/help/git-stage/module/ExternalProject.html#examples
CodePudding user response:
If I understand you correctly you need that any client who obtains source code of your library would be able to also obtain corresponding source code of libcurl
and tinyxml
libraries.
Personally I would use cmake
for that purpose as @brokenfoot has already suggested. But instead of ExternalProject_Add
it seems that in your case FetchContent
would be enough and less complicated: https://cmake.org/cmake/help/latest/module/FetchContent.html