How to find installed packages
Alright, let's say that you have decided to up your game with network communication or storing data at rest. Plaintext files, JSON, or even good old XML won't do. You want to serialize your data straight to binary format, preferably with a library known very well in the industry – say, protocol buffers (Protobuf) from Google. You find the documentation, install the dependencies in the system, and now what? How do we actually tell CMake to find and use this external dependency you're introducing? Luckily, there's a find_package()
command. It works like a charm in most cases.
Let's rewind and start by setting the scene – we have to install the dependencies we want to use because find_package()
, as the name suggests, is only about discovering packages in a system. We're assuming that dependencies are already installed or that users of our solution know how to install specific, necessary dependencies when prompted...