How to do it

Let us look at the packaging directives that need to be added to this project. We will collect them in CMakeCPack.cmake, which is included at the end of CMakeLists.txt using include(CMakeCPack.cmake):

  1. We declare the name of the package. This is the same as the name of the project and hence we use the PROJECT_NAME CMake variable:
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
  1. We declare the package vendor:
set(CPACK_PACKAGE_VENDOR "CMake Cookbook")
  1. The packaged sources will include a description file. This is the plain-text file with the installation instructions:
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/INSTALL.md")
  1. We also add a brief summary of the package:
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "message: ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.