Search code examples
c++cmakeexternal-project

CMake linking to external project


I am new to cmake and want to use the following external project in my program. (https://github.com/mfontanini/cppkafka) The idea is to download from git and build using cmake, which I have managed already. At the end of it, I am left with a .so file which I then have to link back to the main project. Any ideas on how I can achieve this ? Also, would like some suggestion on how to manage dependencies in a project with cmake that would possibly be carried forward to production.


Solution

  • Use ADD_SUBDIRECTORY to add the external project to your project. Then you can use the named tragets from this project while linking with TARGET_LINK_LIBRARIES.