How to do it

This is a C project and we will use the C99 standard. We will build the CMakeLists.txt file step by step:

  1. We declare a C project and enforce compliance with the C99 standard:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)  project(recipe-10 LANGUAGES C)set(CMAKE_C_STANDARD 99)set(CMAKE_C_EXTENSIONS OFF)set(CMAKE_C_STANDARD_REQUIRED ON)
  1. We append the current source directory, CMAKE_CURRENT_SOURCE_DIR, to the list of paths where CMake will look for modules, CMAKE_MODULE_PATH. This is where our own FindZeroMQ.cmake module is located:
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
  1. We will discuss FindZeroMQ.cmake later, but now that the FindZeroMQ.cmake module is available, we search for the library. This is a required ...

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.