What is a CMake module?
A CMake module is a logical entity that contains CMake code, functions, and macros that are put together to serve a particular purpose. A module can provide functions and macros for other CMake code and execute CMake commands when included. CMake is shipped with many pre-made modules by default. These modules provide extra utility to consume CMake code and allow the discovery of third-party tools and dependencies (Find*.cmake
modules). A list of the modules that CMake provides by default is available at https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html. The official CMake documentation categorizes modules in the following two main categories:
- Utility modules
- Find modules
As their name suggests, utility modules provide utility, whereas find modules are designed to search for third-party software in a system. As you will recall, we covered find modules thoroughly in Chapter 4, Packaging, Deploying, and Installing a CMake Project...