How to do it

Let us start from the root CMakeLists.txt. This file puts together the whole superbuild process:

  1. We declare a C99 project:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-03 LANGUAGES C)set(CMAKE_C_STANDARD 99)set(CMAKE_C_EXTENSIONS OFF)set(CMAKE_C_STANDARD_REQUIRED ON)
  1. As in the previous recipe, we set the EP_BASE directory property and the staging installation prefix:
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects)set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)message(STATUS "${PROJECT_NAME} staged install: ${STAGED_INSTALL_PREFIX}")
  1. The dependency on FFTW is checked in the external/upstream subdirectory and we proceed to add this subdirectory to the build system:
add_subdirectory(external/upstream) ...

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.