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

Use eigen3 config.cmake #1304

Merged
merged 2 commits into from
Oct 25, 2022
Merged

Conversation

OznOg
Copy link
Contributor

@OznOg OznOg commented Oct 7, 2022

This fixes bug #1297

set(GTSAM_EIGEN_INCLUDE_FOR_INSTALL "${EIGEN3_INCLUDE_DIR}")
# The actual include directory (for BUILD cmake target interface):
# Node Eigen cmake is completelly broken on some version,
# EIGEN3_INCLUDE_DIR is just unusable as it points to some random location.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean there is no guarantee this will work everywhere and for everyone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means it is really ugly, and should not be necessary on some versions. This works since eigen 3.3.0. Prior Eigen will not, but is not supported anyway AFAIK.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we should probably replace the text with a comment stating that it will work for Eigen 3.3.0 onwards but may not for prior versions. Basically what you said in your comment. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also in the commit message, but I'll update the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@OznOg OznOg requested review from varunagrawal and removed request for ProfFan, jlblancoc and varunagrawal October 8, 2022 09:44
Since Eigen 3.3.0, a Config.cmake file is provided, thus no need to rely
on a custom one.

Moreover, the FindEigen3.cmake used in gtsam was erroneously forcing an
include directory when using system version of eigen.

This fixes bug borglab#1297
@OznOg OznOg force-pushed the UseEigen3Config.cmake branch from bbb7d93 to 774cfd2 Compare October 8, 2022 16:05
@varunagrawal
Copy link
Collaborator

@OznOg this PR is great. I just need to test it out with the Matlab wrapper (we don't have a CI for it) and if that works, I'll approve and merge. :)

@OznOg
Copy link
Contributor Author

OznOg commented Oct 8, 2022

@OznOg this PR is great. I just need to test it out with the Matlab wrapper (we don't have a CI for it) and if that works, I'll approve and merge. :)

Ok, good news

@ProfFan ProfFan linked an issue Oct 9, 2022 that may be closed by this pull request
@OznOg
Copy link
Contributor Author

OznOg commented Oct 21, 2022

Did you have time to test with matlab? any issue?

@varunagrawal
Copy link
Collaborator

@OznOg I've been having issues with my Matlab machine which should be resolved by this weekend. Apologies for the delay, this is my fault.

@dellaert
Copy link
Member

Letting @varunagrawal continue the review, but one question I had: there are two Eigen versions people can use: the one included with GTSAM, and system. Will this PR work with both? I know both options are being used. Not sure whether our CI is good at testing both :-/

@varunagrawal
Copy link
Collaborator

Letting @varunagrawal continue the review, but one question I had: there are two Eigen versions people can use: the one included with GTSAM, and system. Will this PR work with both? I know both options are being used. Not sure whether our CI is good at testing both :-/

@dellaert yes the CI tests for System Eigen as well. It's in build-special.yml under the ubuntu-system-libs workflow. 🙂

@varunagrawal
Copy link
Collaborator

Matlab tests pass! Approving.

Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

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

LGTM

@varunagrawal varunagrawal merged commit 3d4236e into borglab:develop Oct 25, 2022
@dellaert
Copy link
Member

Uhm, now can't compile anymore:

In file included from /Users/dellaert/git/github/gtsam/base/Matrix.h:28:
/Users/dellaert/git/github/gtsam/base/Vector.h:74:1: error: static_assert failed due to requirement '3 == 3 && 3 == 4' "Error: GTSAM was built against a different version of Eigen"
static_assert(

What's the fix?

@jlblancoc
Copy link
Member

Hi Frank! Was it building the gtsam lib itself, or an example/app?
Have you tried checking what's the directory shown by cd BuildDir && grep Eigen CMakeCache.txt?

(Note: I've not tested the merged version yet!)

@jlblancoc
Copy link
Member

@OznOg @varunagrawal : Is there any reason to leave a copy of Eigen3 under gtsam/3rdparty? I think it's useless "as is" right now, because it must be processed by cmake first to produce a usable EigenConfig.cmake file... Perhaps it could be removed and installation instructions updated to remember Eigen is a mandatory prerequisite, just like Boost?

@varunagrawal
Copy link
Collaborator

varunagrawal commented Oct 25, 2022

Seems like CMake is picking up a different version of Eigen (3.4 rather than the provided 3.3). Are you on a M1 Mac?

@varunagrawal
Copy link
Collaborator

@OznOg @varunagrawal : Is there any reason to leave a copy of Eigen3 under gtsam/3rdparty? I think it's useless "as is" right now, because it must be processed by cmake first to produce a usable EigenConfig.cmake file... Perhaps it could be removed and installation instructions updated to remember Eigen is a mandatory prerequisite, just like Boost?

I believe the idea is that by including Eigen under 3rdparty, we can compile out of the box and have some control over the Eigen version. @dellaert prefers this approach since it requires no wasted effort in integration.

@varunagrawal
Copy link
Collaborator

@dellaert FWIW I compiled (and cleaned and compiled) the latest develop on my M1 mac and I don't seem to have this problem. You may want to do a full rebuild?

@varunagrawal
Copy link
Collaborator

I think I found the issue. Line 5 in HandleEigen.cmake sets USE_SYSTEM_EIGEN_INITIAL_VALUE to ON which tells Cmake to use the system Eigen. Looks like @OznOg's PR unearthed a bug in the cmake. 🙂

@dellaert you should be able to compile by setting the GTSAM_USE_SYSTEM_EIGEN flag to false.

@dellaert
Copy link
Member

I think I found the issue. Line 5 in HandleEigen.cmake sets USE_SYSTEM_EIGEN_INITIAL_VALUE to ON which tells Cmake to use the system Eigen. Looks like @OznOg's PR unearthed a bug in the cmake. 🙂

@dellaert you should be able to compile by setting the GTSAM_USE_SYSTEM_EIGEN flag to false.

That does not work, but #1314 does fix it for me. I'll approve and merge that one...

@OznOg
Copy link
Contributor Author

OznOg commented Oct 26, 2022

Hi guys, is there something I can/need to do to help, or is everything ok now?

@OznOg OznOg deleted the UseEigen3Config.cmake branch October 26, 2022 18:44
@varunagrawal
Copy link
Collaborator

Everything has been figured out. Thanks for following up. :)

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.

gtsam should use eigen cmake config file
4 participants