Local install Eigen in CMAKE not finding target

梦想的初衷 提交于 2021-02-11 15:14:12

问题


I'm trying to build and use a local version of Eigen that I've downloaded directly from the CMake file of my project. I have those line to build it:

include(FetchContent)
FetchContent_Declare(
        eigen
        URL ${CMAKE_CURRENT_SOURCE_DIR}/external/eigen-3.3.8.tar.gz
)
FetchContent_MakeAvailable(eigen)
set(EIGEN3_INCLUDE_DIR ${eigen_SOURCE_DIR})

But then I got errors like

 Target "XXX_LIBRARIES" links to target "Eigen3::Eigen" but the target was
 not found.  Perhaps a find_package() call is missing for an IMPORTED
 target, or an ALIAS target is missing?

I'm linhking eigen as such

target_link_libraries(XXX_LIBRARIES EXTERNAL_LIBRARIES Eigen3::Eigen)

What is surprising to me is that with this code instead everything worked fine:

include(FetchContent)
FetchContent_Declare(
        eigen
        GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
)
FetchContent_MakeAvailable(eigen)
set(EIGEN3_INCLUDE_DIR ${eigen_SOURCE_DIR})

But the only difference is that I'm downloading the library then. Why is the version with the local copy not working?

来源:https://stackoverflow.com/questions/65080150/local-install-eigen-in-cmake-not-finding-target

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