问题
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