CMake packaging essentials

CMake can create relocatable installer or archive packages with CPack. CPack creates an archive or installer from a CMake project. C and C++ programs generally use header files (.h or .hpp) that must be part of an installed package. Fortran programs likewise use module files (.mod) that must be installed.

A basic structure for a CMake project that can create a CMake config-file package is shown in cmake-package-install. The boilerplate code under cmake/ directory is only slightly modified between projects. For example, see h5fortran for more advanced example in cmake/install.cmake and cmake/