Issue
I was wondering what the 'correct' way of including libraries is in a project. Im trying to integrate llvm core with my project and I noticed the source has numerous cmake files. If I want to integrate this with my project (a compiler frontend based on kaleidoscope tutorial), should I convert my project to cmake? If so, how do I include the library in my build? Are there any 'valid' alternatives?
Solution
Generally, the correct way is not to do it. The reason for this is because it makes it easier for people with dependencies installed to install and integrate your package in their system.
You ought to use a tool like pkg-config
or such to find your dependencies from the running system.
The Meson build system has excellent support for this, pkg.m4
provides macros for autoconf
that you can use, and CMake provides FindPkgConfig
.
Some packages do not use pkg-config
, but instead provide similar -config
style scripts. IIRC, LLVM is one of these. They usually also provide macros you can use with your build system but, if not, they're fairly easy to invoke correctly.
Meson also has support for the LLVM dependency: https://mesonbuild.com/Dependencies.html#llvm
IIRC, the LLVM project also provides a FindLLVM.cmake file you can use if you end up opting for CMake (but, IMO, CMake is a big downgrade from most build systems).
Answered By - Arsenović Arsen Answer Checked By - David Marino (WPSolving Volunteer)