CMakeLists.txt文件中的配置特征

问题描述 投票:0回答:1

当我如下配置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)

有人可以帮我吗?不知道这里出了什么问题。非常感谢。

c++ cmake eigen
1个回答
0
投票
您使用

两种方式在相同时间包括3d-party项目(Eigen):

  1. add_subdirectory()
  2. find_package()

这是错误的。采取单一方式:

  1. 仅具有add_subdirectory

    add_subdirectory(deps/eigen) # ... target_link_libraries(hello eigen)

  2. 仅具有find_package()

    find_package(Eigen3 3.3 REQUIRED NO_MODULE) target_link_libraries(hello eigen)

© www.soinside.com 2019 - 2024. All rights reserved.