use-eigen-with-cmake
use-eigen-with-cmake copied to clipboard
Usage of Eigen library with CMake.
trafficstars
How to use Eigen3 with CMake
instllation of Eigen3 library
- Download it from Eigen;
- Unzip it and create the
builddirectory in the folder of the source folder; - Run cmake with
cmake -G "MinGW Makefiles" ../ -DCMAKE_INSTALL_PREFIX=/path/to/installation/folder; - Run make with
make install; - Locate the headers of
Eigenand thecmakeconfiguration files located at the installation folder.
Usage the Eigen library with cmake
- Create a folder of
cmakeat the root directory of your source code; - Copy the configuration files of
Eigento the directory so-calledcmake;./ ./main.cpp ./CMakeLists.txt ./cmake/ ./cmake/Eigen3Config.cmake ./cmake/Eigen3ConfigVersion.cmake ./cmake/Eigen3Targets.cmake ./cmake/UseEigen3.cmake - Configure your
CMakeLists.txt;cmake_minimum_required (VERSION 3.0) project (Name_Of_Your_Project) # important setting for accessing the eigen library list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") find_package(Eigen3 REQUIRED) include_directories(${EIGEN3_INCLUDE_DIR}) message("${CMAKE_MODULE_PATH}") message("${EIGEN3_INCLUDE_DIR}") add_executable (executable main.cpp) target_link_libraries(executable PUBLIC Eigen ) - Make a build directory namely
buildand change the working directory into that folder; - Run the
cmakewithcmake -G "MinGW Makefiles" ../ -DCMAKE_PREFIX_PATH=/path/to/installation/folder; Note It is worthy of noting that theCMAKE_PREFIX_PATHis the same as that of-DCMAKE_INSTALL_PREFIX. - Run
makewithmake -j2.