CMake moduleΒΆ

Listfiles located in directories specified by CMAKE_MODULE_PATH and having extension .cmake called modules. They can be loaded by include command. Unlike add_subdirectory command include(<modulename>) doesn’t create new node in a source/binary tree hierarchies and doesn’t introduce new scope for variables.


In general by include you can load file with any name, not only *.cmake. For example:

include(some/file/ # file with extension '.tt'
include(another/file/XYZ) # file without extension

Or even CMakeLists.txt:


Though it is confusing, doesn’t make sense and should be avoided.

CMake documentation