Eigen cmake library wrapper, because official cmake is 💩
# ⬇️ Download project from Github
git clone https://github.com/Naostage/eigen.cmake
cd eigen.cmake
# 🔧 Configure project
cmake -E make_directory build
cmake \
-DEIGEN_ENABLE_EXAMPLES=ON `# 🚀 Enable Examples (eigen_example)` \
-DEIGEN_ENABLE_INSTALL=ON `# 📦️ Enable Install` \
-DEIGEN_ENABLE_FIND_PACKAGE=ON `# Enable find_package before cpm` \
-B build -S .
# 🔨 Build:
cmake --build build --target eigen_example --config Release -j12
# 📦️ Install library (You can control installation path with -DCMAKE_INSTALL_PREFIX=mypath)
cmake --build . --target install
CPM_SOURCE_CACHE
: Share CPM download with multiple build. More info.CPM_USE_LOCAL_PACKAGES
: ForceCPMAddPackage
to first try tofind_package
EIGEN_ENABLE_FIND_PACKAGE
: Enablefind_package
beforeCPMAddPackage
. Off By DefaultCMAKE_INSTALL_PREFIX
: Select where installation should happen. More info
When using CPM, adding eigen.cmake
to your project is as simple as:
CPMAddPackage(
NAME eigen.cmake
GIT_REPOSITORY "https://github.com/Naostage/eigen.cmake"
GIT_TAG "v3.4.0"
)
target_link_libraries(mytarget PRIVATE Eigen3::Eigen)
One the library is installed you can simply:
find_package(Eigen3 REQUIRED)
target_link_libraries(mytarget PRIVATE Eigen3::Eigen)
Complete example can be found in examples/install.
- clang-format : format cpp
- cmake-format : format cmake