How to do it

Our CMakeLists.txt will have to contain a custom command to extract the sources for the linear algebra wrapper library. Let us look at it in detail:

  1. We start with a familiar definition of the minimum CMake version, project name, and supported language:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-03 LANGUAGES CXX Fortran)
  1. We pick the C++11 standard, as usual:
set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. It is then time to look for the BLAS and LAPACK libraries on our system:
find_package(BLAS REQUIRED)find_package(LAPACK REQUIRED)
  1. We declare a variable, wrap_BLAS_LAPACK_sources, to hold the names of the source files contained in the wrap_BLAS_LAPACK.tar.gz ...

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.