mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Extend the range of supported CMake package config versions
Modified to be backward-compatible with Eigen 3.4.0, in that the following
will still accept 3.4.1:
```
find_package(Eigen3 3.3)
```
(cherry picked from commit 027dc5bc8d)
This commit is contained in:
committed by
Antonio Sanchez
parent
b66188b5df
commit
79488684e1
@@ -7,16 +7,16 @@ namespace Eigen {
|
||||
%Eigen provides native CMake support which allows the library to be easily
|
||||
used in CMake projects.
|
||||
|
||||
\note %CMake 3.0 (or later) is required to enable this functionality.
|
||||
\note %CMake 3.5 (or later) is required to enable this functionality.
|
||||
|
||||
%Eigen exports a CMake target called `Eigen3::Eigen` which can be imported
|
||||
using the `find_package` CMake command and used by calling
|
||||
`target_link_libraries` as in the following example:
|
||||
\code{.cmake}
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
cmake_minimum_required (VERSION 3.5)
|
||||
project (myproject)
|
||||
|
||||
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
|
||||
find_package (Eigen3 REQUIRED NO_MODULE)
|
||||
|
||||
add_executable (example example.cpp)
|
||||
target_link_libraries (example Eigen3::Eigen)
|
||||
@@ -27,10 +27,19 @@ The above code snippet must be placed in a file called `CMakeLists.txt` alongsid
|
||||
\code{.sh}
|
||||
$ cmake path-to-example-directory
|
||||
\endcode
|
||||
CMake will produce project files that generate an executable called `example`
|
||||
which requires at least version 3.3 of %Eigen. Here, `path-to-example-directory`
|
||||
is the path to the directory that contains both `CMakeLists.txt` and
|
||||
`example.cpp`.
|
||||
CMake will produce project files that generate an executable called `example`.
|
||||
Here, `path-to-example-directory` is the path to the directory that contains
|
||||
both `CMakeLists.txt` and `example.cpp`. Note that if you have multiple
|
||||
instances of %Eigen installed, `find_package` will use the first one
|
||||
encountered. To request a specific version of %Eigen, use the `<version>`
|
||||
option in `find_package`:
|
||||
```
|
||||
find_package(Eigen3 3.4 REQUIRED NO_MODULE)
|
||||
```
|
||||
or to support a range of versions:
|
||||
```
|
||||
find_package(Eigen3 3.3...5 REQUIRED NO_MODULE) # Any version >=3.3.0 but <6.0.0.
|
||||
```
|
||||
|
||||
Do not forget to set the <a href="https://cmake.org/cmake/help/v3.7/variable/CMAKE_PREFIX_PATH.html">\c CMAKE_PREFIX_PATH </a> variable if Eigen is not installed in a default location or if you want to pick a specific version. For instance:
|
||||
\code{.sh}
|
||||
@@ -44,7 +53,7 @@ $ cmake path-to-example-directory -DEigen3_DIR=$HOME/mypackages/share/eigen3/cma
|
||||
If the `REQUIRED` option is omitted when locating %Eigen using
|
||||
`find_package`, one can check whether the package was found as follows:
|
||||
\code{.cmake}
|
||||
find_package (Eigen3 3.3 NO_MODULE)
|
||||
find_package (Eigen3 NO_MODULE)
|
||||
|
||||
if (TARGET Eigen3::Eigen)
|
||||
# Use the imported target
|
||||
|
||||
Reference in New Issue
Block a user