O'Reilly logo

CMake Cookbook by Roberto Di Remigio, Radovan Bast

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required