How to do it

We will start with the main CMakeLists.txt and later move to deps/CMakeLists.txt:

  1. As before, we declare a C++11 project:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)  project(recipe-04 LANGUAGES CXX Fortran)set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. At this point, we move on to deps/CMakeLists.txt. This is achieved with the add_subdirectory command:
add_subdirectory(deps)
  1. Inside deps/CMakeLists.txt, we first locate the necessary libraries (BLAS and LAPACK):
find_package(BLAS REQUIRED)find_package(LAPACK REQUIRED)
  1. Then, we collect the contents of the tarball archive into a variable, MATH_SRCS:
set(MATH_SRCS  ${CMAKE_CURRENT_BINARY_DIR}/wrap_BLAS_LAPACK/CxxBLAS.cpp ${CMAKE_CURRENT_BINARY_DIR}/wrap_BLAS_LAPACK/CxxLAPACK.cpp ...

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.