How to do it

The process of setting up a superbuild should by now feel familiar. Let us once again look at the necessary steps, starting with the root CMakeLists.txt:

  1. We declare a C++11 project with a same default build type:
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)project(recipe-05 LANGUAGES CXX)set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")  set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)endif()message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}")
  1. The EP_BASE directory property is set. This will fix the layout for all subprojects managed by ExternalProject:
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects) ...

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.