CLion 在 macOS 上找不到 Eigen3

CLion is unable to find Eigen3 on macOS

我知道过去有过类似的问题。但是,到目前为止,none 的解决方案对我有用。只是一些细节:我在 macOS 13.13.6 上使用 CLion 2020.1 和 Eigen 3.3.7。只是我到目前为止所做的概述:

  1. 我下载了 Eigen 3.3.7 并解压了文件。之后我将文件从 "eigen-3.3.7" 重命名为 "Eigen3".
  2. 我将其移至 "usr/local/" 目录。
  3. 在 "Eigen3" 中,在 "cmake" 文件夹中,有一个名为 "Eigen3Config.cmake.in" 的文件。我想知道为什么它有额外的“.in”扩展名。
  4. 我打开了 CLion。这就是我编辑 CMakeLists.txt 文件的样子。

    cmake_minimum_required(VERSION 3.16)
    project(Project_1)
    
    set(CMAKE_CXX_STANDARD 17)
    
    find_package(Eigen3 3.3 REQUIRED NO_MODULE)
    
    add_executable(Project_1 main.cpp)
    target_link_libraries(Project_1 Eigen3::Eigen)
    

这是我得到的错误:

CMake Error at CMakeLists.txt:6 (find_package):
Could not find a package configuration file provided by "Eigen3" (requested
version 3.3) with any of the following names:

Eigen3Config.cmake
eigen3-config.cmake

Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
"Eigen3_DIR" to a directory containing one of the above files.  If "Eigen3"
provides a separate development package or SDK, be sure it has been
installed.

之后,我继续将文件名从 "Eigen3Config.cmake.in" 更改为 "Eigen3Config.cmake"。这是我得到的错误:

CMake Error at CMakeLists.txt:6 (find_package):
Could not find a configuration file for package "Eigen3" that is compatible
with requested version "3.3".

The following configuration files were considered but not accepted:

/usr/local/Eigen3/cmake/Eigen3Config.cmake, version: unknown

接下来我可以尝试什么?

我认为下一个解决方案应该对这里有所帮助。

I downloaded Eigen 3.3.7 and unzipped the file. After that I renamed the file from "eigen-3.3.7" to "Eigen3". I moved this to the "usr/local/" directory.

请尝试通过brew 安装eigen3.3.7。就做 brew install eigen。而已。 find_package 会正确找到它。