The project needs to unpack the Eigen archive and set the include directories for the target accordingly:
- Let us first declare a C++11 project:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-01 LANGUAGES CXX)set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
- We add a custom target to our build system. The custom target will extract the archive inside the build directory:
add_custom_target(unpack-eigen ALL COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/eigen-eigen-5a0156e40feb.tar.gz COMMAND ${CMAKE_COMMAND} -E rename eigen-eigen-5a0156e40feb eigen-3.3.4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Unpacking Eigen3 in ${CMAKE_CURRENT_BINARY_DIR}/eigen-3.3.4" ...