Compiling with Cmake and using a header only library

白昼怎懂夜的黑 提交于 2019-12-13 02:19:13

问题


The question is a continuation/repeated one to a previous question, which didn't resolve the issue i'm running into.

Using Eigen with Cmake

Compiling Eigen with make file is one step task. But in Cmake, how do you add a header only library (basically i am using only the Eigen folder from the extracted archive folder in the Eigen website, and disregarding the rest.) Note: Eigen folder has its own CMakeLists.txt


回答1:


You can use the FindEigen3.cmake. Put it into cmake/Modules folder and add the following lines to your CmakeLists.txt

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

You can find FindEigen3.cmake in the source of the Eigen library in cmake/FindEigen3.cmake

https://bitbucket.org/eigen/eigen/src/971445a0e8ec311b4b663242b1f0ac668a9753ca/cmake/FindEigen3.cmake?at=default



来源:https://stackoverflow.com/questions/28306704/compiling-with-cmake-and-using-a-header-only-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!