当我使用 CMake FetchContent 导入 OpenCV 时,它工作正常:
include(FetchContent)
# Fetch OpenCV
FetchContent_Declare(
opencv
GIT_REPOSITORY https://gitee.com/aiproach/opencv.git
GIT_TAG 4.4.0
)
FetchContent_MakeAvailable(opencv)
set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR})
find_package(OpenCV REQUIRED)
Run Code Online (Sandbox Code Playgroud)
但在我添加特征之后:
# Fetch Eigen
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.3.9
)
FetchContent_MakeAvailable(eigen)
find_package(eigen3 REQUIRED)
Run Code Online (Sandbox Code Playgroud)
它会发出错误:
include(FetchContent)
# Fetch OpenCV
FetchContent_Declare(
opencv
GIT_REPOSITORY https://gitee.com/aiproach/opencv.git
GIT_TAG 4.4.0
)
FetchContent_MakeAvailable(opencv)
set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR})
find_package(OpenCV REQUIRED)
Run Code Online (Sandbox Code Playgroud)
有人告诉我这是由命名空间冲突引起的,但我不知道如何解决该问题。我在 GitHub 上搜索了“FetchContent”,但似乎每个人都和我一样使用它。是否有一种通用方法可以使用 FetchContent 获取所有内容,只需插入项目名称和 URL?