Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ros2/eigen3_cmake_module
Adds a custom find module for Eigen3
https://github.com/ros2/eigen3_cmake_module
Last synced: about 2 months ago
JSON representation
Adds a custom find module for Eigen3
- Host: GitHub
- URL: https://github.com/ros2/eigen3_cmake_module
- Owner: ros2
- License: apache-2.0
- Created: 2019-07-24T23:21:26.000Z (over 5 years ago)
- Default Branch: rolling
- Last Pushed: 2024-04-26T15:16:12.000Z (9 months ago)
- Last Synced: 2024-04-26T16:36:43.171Z (9 months ago)
- Language: CMake
- Size: 18.6 KB
- Stars: 10
- Watchers: 18
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# eigen3_cmake_module
On Ubuntu Bionic, the `Eigen3` CMake package offers exported targets and non-standard CMake variables.
This is a problem for packages using [ament_cmake](https://github.com/ament/ament_cmake).Targets using `ament_target_dependencies(my_target Eigen3)` will fail to find `Eigen3` headers at compile time.
Downstream packages will also fail to find `Eigen3` headers at compile time, even if your package uses `ament_export_dependencies(Eigen3)`.This package adds a [CMake find module](https://cmake.org/cmake/help/v3.14/manual/cmake-developer.7.html#find-modulesjj) for [Eigen3](https://eigen.tuxfamily.org/dox/) that sets [standard CMake variables](https://cmake.org/cmake/help/v3.5/manual/cmake-developer.7.html#standard-variable-names).
ROS 2 packages using `Eigen3` should use this package to avoid these problems.## Using this package
### Edit your CMakeLists.txt
In your `CMakeLists.txt`, call `find_package()` on this package using `REQUIRED`.
Afterwards, find `Eigen3` with or without `REQUIRED` as appropriate for your package.```CMake
find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3)
```#### Using with ament_cmake
If your package uses [ament_cmake](https://github.com/ament/ament_cmake), then use `ament_target_dependencies()` to give your library or executable targets access to the `Eigen3` headers.```CMake
# add_library(my_thing ...)
# # OR
# add_executable(my_thing ...)
# ...
ament_target_dependencies(my_thing Eigen3)
```If `Eigen3` appears in headers installed by your package, then downstream packages will need the `Eigen3` headers too.
Call `ament_export_dependencies()` on this package, and afterwards do the same for `Eigen3`.```CMake
ament_export_dependencies(eigen3_cmake_module)
ament_export_dependencies(Eigen3)
```#### Using without ament_cmake
If your package does not use `ament_cmake`, then use `target_include_directories()` to give your targets access to the `Eigen3` headers.
```CMake
target_include_directories(my_target PUBLIC "${Eigen3_INCLUDE_DIRS}")
```If `Eigen3` is used in headers installed by your package, then your `-config.cmake` must find both this package and `Eigen3`.
Afterwards the `Eigen3` headers should be added to your package's include variable.```CMake
find_package(eigen3_cmake_module)
if (NOT eigen3_cmake_module_FOUND)
set(your_package_name_FOUND 0)
return()
endif()find_package(Eigen3)
if (NOT Eigen3_FOUND)
set(your_package_name_FOUND 0)
return()
endif()list(APPEND your_package_name_INCLUDE_DIRS ${Eigen3_INCLUDE_DIRS})
```### Edit your package.xml
Add a buildtool dependency to this package, and a build dependency to `Eigen3` to your `package.xml`.
```xml
eigen3_cmake_module
eigen
```If your package uses `Eigen3` in public headers, then **also add** these tags so downstream packages also depend on this package and `Eigen3`.
```xml
eigen3_cmake_module
eigen
````` is not necessary because `Eigen3` is a header only library.