Getting Started with CMake: Helpful Resources

When I first started learning CMake, I was surprised at how few tutorials and good references exist on the internet. Here’s a list of resources that I have found to be helpful.

Note: Since we originally published this article, we also created a course that teaches you modern CMake, as well as a course for intermediate and advanced users on creating a reusable CMake project skeleton.

Table of Contents:

  1. Learning CMake
  2. Videos
  3. Cheat Sheets
  4. Documentation
  5. Project Skeletons
  6. List of Global Variables

Learning CMake

Video

Audio

  • CPPCast: Professional CMake – Rob and Jason are joined by Craig Scott. They first discuss a recent blog post from PVS-Studio analyzing some bugs in CMake. Then Craig talks about how he got involved in CMake development, and his e-book ‘Professional CMake: A Practical Guide.’

Cheat Sheets

Documentation

Dependency Management

Packaging

Project Skeletons

List of Global Variables

  • CMAKE_BINARY_DIR
    • Same as CMAKE_SOURCE_DIR for in-source builds
    • Otherwise, top-level directory of your build tree
  • CMAKE_SOURCE_DIR
    • Top-level source directory
  • EXECUTABLE_OUTPUT_PATH
    • Set this variable to specify where executables should be placed (instead of CMAKE_CURRENT_BINARY_DIR)
    • SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
  • LIBRARY_OUTPUT_PATH
    • Set this variable to specify where libraries should be placed (instead of CMAKE_CURRENT_BINARY_DIR)
    • SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
  • PROJECT_NAME
    • The name of the project set by the project() command
  • PROJECT_SOURCE_DIR
    • Full path to the root of your project source directory (nearest directory where CMakeLists.txt contains the project() command

Share Your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.