The question now becomes, how do we create such library? Let's go over writing CMakeLists.txt for the Minisat library we were using in the first part of this post.
Creating librariesĪs we have seen, using libraries from CMake can be downright pleasant, as long as the library supports this usage properly.
Alternatively, you can look for one online, or write your own. it provides FindBoost.cmake or FindThreads.cmake for you out of the box. If you go with 2) and the library you want to use is common enough, there is a good chance that it will work out of the box, because CMake comes with some Find*.cmake scripts preinstalled, e.g.
This post shows how to create and consume simple libraries using modern CMake. In practice, very few projects are fully self-contained, as they either depend on external libraries or are themselves libraries that other projects depend on. My previous post about CMake provided a simple CMakeLists.txt for a small, self-contained, project. ← The Coding Nest Basic CMake, part 2: librariesīy Martin Hořeňovský Jun 2nd 2018 Tags: CMake, Tutorial, C++