Issue
I might be googling wrongly, but I'm unable to find what's the purpose of .cmake files.
I've just stumbled across the CMake tool for a project I've to work with and I'm having a hard time to understand how it works. I do understand that running the CMake command in a directory containing a CMakeLists.txt
executes the commands in that file (along with the commands in the CMakeLists.txt
contained in the sub-directories) but the purpose of .cmake files is a lot more fuzzy.
It seems that they are used to define functions/set variables that are thereafter used in the CMakeLists.txt
but I'm not sure. How are they used by the CMake tool ?
Solution
You can include it with the include command. Similar to how other languages allow you to split source files into modules or header files, they can contain function definitions, macros which can then be reused across multiple CmakeLists.
See https://cmake.org/cmake/help/v3.0/command/include.html
Note that you can actually include any file, but a .cmake extension is commonly used.
Answered By - André