I just recently learning cmake and trying to use eigen library in my project. I included eigen headers directly under my src folder. Then I tried to cmake, but it failed. I learned that if we want to build target against Eigen, we need the Eigen3Config.cmake file. But for the eigen folder under src, it does not have it. So how can I write the CMakeList.txt?
I checked following answers, but those are all talking Eigen installed in the system:
CMake find eigen incorrect results
Find package Eigen3 for CMake
What I want to implement is NOT depending on Eigen installed in system but just the Eigen in my src.
The following is my current CMakeList.txt and project structure
project(eigen_test)
cmake_minimum_required (VERSION 3.1)
add_definitions(-std=c++11)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
set(sources src/main.cpp src/other.cpp)
add_executable(eigen_test ${sources})
target_link_libraries (eigen_test Eigen3::Eigen)
Project Structure:
project_folder
|--CMakeLists.txt
|--src/
|---- Eigen/
|---- main.cpp
|---- other.cpp
Thank you!