当我如下配置CMakeLists.txt文件中的特征库时:
cmake_minimum_required(VERSION 3.14)
project(helloworld)
add_subdirectory(tests)
add_subdirectory(deps/eigen)
set(SRC_LIST main.cpp)
add_executable(hello ${SRC_LIST})
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
target_link_libraries(hello eigen)
我收到了cmake错误,
CMake Error at build/deps/eigen/Eigen3Config.cmake:20 (include):
The file
/Users/joe/codecplus/build/deps/eigen/Eigen3Targets.cmake
was generated by the export() command. It may not be used as the argument
to the include() command. Use ALIAS targets instead to refer to targets by
alternative names.
Call Stack (most recent call first):
CMakeLists.txt:9 (find_package)
有人可以帮我吗?不知道这里出了什么问题。非常感谢。
两种方式在相同时间包括3d-party项目(Eigen):
add_subdirectory()
find_package()
这是错误的。采取单一方式:
add_subdirectory
:add_subdirectory(deps/eigen)
# ...
target_link_libraries(hello eigen)
find_package()
:find_package(Eigen3 3.3 REQUIRED NO_MODULE)
target_link_libraries(hello eigen)