Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a FindEigen.cmake module #11

Merged
merged 3 commits into from
Feb 5, 2014
Merged

adding a FindEigen.cmake module #11

merged 3 commits into from
Feb 5, 2014

Conversation

wjwwood
Copy link
Member

@wjwwood wjwwood commented Feb 4, 2014

@dirk-thomas @adolfo-rt can I get a review of this if you have time?


find_package(PkgConfig)
pkg_check_modules(PC_EIGEN eigen3)
set(EIGEN_DEFINITIONS ${PC_EIGEN_CFLAGS_OTHER})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we getting the include dirs from the pc file as well?. In my installation (libeigen3-dev 3.0.5-1), /usr/share/pkgconfig/eigen3.pc looks like this:

Name: Eigen3
Description: A C++ template library for linear algebra: vectors, matrices, and related algorithms
Requires:
Version: 3.0.5
Libs:
Cflags: -I/usr/include/eigen3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was copied over from catkin, I'll look at improving this to use pc for everything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible that the pc file doesn't work correctly on Windows? That is the only reason to search instead, but that seems unlikely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh the other problem is that pkg-config only gives you the cflags, I would have to split and extract the include paths so that CMake can use them. I'm not sure which is better, but since the current implementation is in use already I would lean towards it.

@adolfo-rt
Copy link
Contributor

I'd like to bring your attention to the fact that there currently exist multiple scripts for finding Eigen, each of which has its own set of variables and capitalization policy. On the one hand, the Eigen project already provides:

  • A pkgconfig file, which gets installed.
  • A FindEigen3.cmake script that is not part of the install target. It generates variables like EIGEN3_FOUND (note the 3, all caps).
  • A few months back a pull request got merged with Eigen3Config.cmake and UseEigen3.cmake files that do get installed. It generates variables like EIGEN_FOUND (Note no 3, all caps). These files are in the default branch, and have not yet been released as of 3.2.

This PR proposes yet another script/ set of variables, but offers consistent naming between what gets passed to find_package(Eigen) and the variables that result (i.e., Eigen_FOUND).

# Cache variables (not intended to be used in CMakeLists.txt files)
#
# - Eigen_INCLUDE_DIR: Absolute path to package headers.
# - Eigen_LIBRARY: Absolute path to the library.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed, as the variable does not exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this was a copy-paste-edit of the TinyXML documentation.

@wjwwood
Copy link
Member Author

wjwwood commented Feb 4, 2014

I basically copied over the find-eigen.cmake from catkin (ros/catkin#492), which people are currently using, my intent was to provide something that worked with that, but I'll try to address the comments you brought up.

@wjwwood
Copy link
Member Author

wjwwood commented Feb 4, 2014

I am using Eigen 3.2.0 on my machine and I still do not have the Eigen3Config.cmake or the UseEigen3.cmake files, so I don't think we can rely on those.

I suppose we could use the FindEigen3.cmake you linked to, but I don't see any advantages over just moving the catkin one here and redoing the documentation.

Thoughts?

@adolfo-rt
Copy link
Contributor

I am using Eigen 3.2.0 on my machine and I still do not have the Eigen3Config.cmake or the UseEigen3.cmake files, so I don't think we can rely on those.

The feature was added post-3.2, so we can't really use it as of now. It's only in the default branch.

I suppose we could use the FindEigen3.cmake you linked to, but I don't see any advantages over just moving the catkin one here and redoing the documentation.

I don't see the advantage either, especially because the variable names are significantly different. The script is looking good now.

@wjwwood
Copy link
Member Author

wjwwood commented Feb 5, 2014

@adolfo-rt thanks for the review.

wjwwood added a commit that referenced this pull request Feb 5, 2014
adding a FindEigen.cmake module
@wjwwood wjwwood merged commit 3fb1be1 into master Feb 5, 2014
@wjwwood wjwwood deleted the add_find_eigen branch February 5, 2014 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants