Search code examples
c++buildcmakelibunwind

Add library to Cmake project


Perhaps I simply can't find it, but I want to add some code to a project of mine (libunwind found here http://www.nongnu.org/libunwind/download.html)
This library does not come with a CMakeLists.txt file and when I try to include it cmake complains about this fact. Right now I've simply added the libunwind directory to my external code and added a reference in my main CMakeLists.txt

Any input would be great.


Solution

  • If you want to build it each time along with your project, the easiest way would be to:

    • Add the source code somewhere into your project tree
    • Add a custom CMake target which should run before the compilation starts
    • In that custom target, run whatever is needed to compile the library (in your case it's ./configure -> make -> make install.

    However that is rarely needed and most of the times you should just build the library once and link it as any other external library.