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

Add absl to CMake and Bazel builds. #1301

Merged
merged 12 commits into from Jul 26, 2018
Merged

Conversation

pifon2a
Copy link
Contributor

@pifon2a pifon2a commented Jul 19, 2018

Having to support both CMake and Bazel builds, we are adding it as a copy in third_party/ directory.

@sebastianklose
Copy link
Contributor

Is there a reason why this is only a subset of whole abseil? For example I don't see the memory or synchronization subfolders which will probably be most interesting for us.

Copy link
Contributor

@sebastianklose sebastianklose left a comment

Choose a reason for hiding this comment

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

I think you pulled the wrong rev? This is only including the first three subfolders of absl.

NVM - seems to be an UI issue ...

@wohe
Copy link
Member

wohe commented Jul 19, 2018

@CodeArno FYI

@CodeArno
Copy link
Contributor

(sorry about my previous comment if you got an email about it, I got confused about the repositories).
This looks great! :)

@wohe
Copy link
Member

wohe commented Jul 19, 2018

Following up on @CodeArno's previous comment. Do we need to copy Abseil here for CMake to work? Or what is the reasoning? Should this rationale be added to the PR description?

@pifon2a
Copy link
Contributor Author

pifon2a commented Jul 19, 2018

@wohe We can either copy it or add it as a sub-module. In the latter case, the users will have to call git submodule.

@ojura
Copy link
Contributor

ojura commented Jul 19, 2018

@pifon2a there is a third option which is a lot like this one (pasting a copy of the 3rd party repo inside your repo), and that is using git subtree. I would recommend git subtree add ... --squash. This keeps the whole third party repo as a single squashed commit in some folder (the subtree), while maintaining metadata (original upstream commit ID) in the commit description so you can easily pull from upstream using git subtree pull.

@gaschler
Copy link
Contributor

@pifon2a Since absl already depends on cmake 3.1, we can also use cmake's externalproject_add, which I find better than git submodules, especially for an external dependency that we rarely update.

@ojura
Copy link
Contributor

ojura commented Jul 19, 2018

I dimly remember wanting to smash something every time I tried using externalproject_add.

@pifon2a pifon2a force-pushed the absl branch 2 times, most recently from 6d2fcdc to 9e18129 Compare July 23, 2018 23:43
CMakeLists.txt Outdated

find_package(Eigen3)
if(NOT EIGEN3_FOUND)
set(EIGEN3_INCLUDE_DIRS ${/usr/include/eigen3})
Copy link

Choose a reason for hiding this comment

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

is this unrelated to absl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I install cmake 3.x in trusty/jessie, Cartographer complains that it cannot find FindEigen3.cmake, although Ceres was compiled just prior to that. I do not know whether it is a good solution or not. @gaschler PTAL, because CMake scares and confuses me.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is unrelated to abseil and should be a separate PR where only the cmake version is bumped.
(It's hard to say why a newer cmake makes the package search stricter.)

So, no change here, please. (Setting an include path manually is not portable and wouldn't be part of a cmake style guide.)
A proper solution would be to add a FindEigen3.cmake to cmake/modules similar to (but much shorter than) what ceres does: https://github.com/ceres-solver/ceres-solver/blob/master/cmake/FindEigen.cmake

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, when bumping cmake, it would be good to bump cmake_minimum_required in this file and update the install instructions in the documentation.

@pifon2a pifon2a requested a review from gaschler July 24, 2018 04:47
Copy link
Contributor

@gaschler gaschler left a comment

Choose a reason for hiding this comment

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

Thank you.
Do you have a plan to verify (and update if necessary)

  1. Catkin build of cartographer_ros/_fetch,
  2. the ROS release build https://github.com/ros-gbp/cartographer-release/
  3. manual install instructions following documentation?

sudo apt-get install python-software-properties apt-file -y
sudo apt-file update
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:george-edison55/cmake-3.x
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to install personal (untrusted) packages,
just install cmake3 https://packages.ubuntu.com/en/trusty/cmake3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, thanks, done

# See the License for the specific language governing permissions and
# limitations under the License.

# DO NOT SUBMIT, would break on CMake versions.
Copy link
Contributor

Choose a reason for hiding this comment

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

drop this comment (after bumping cmake)

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

CMakeLists.txt Outdated

find_package(Eigen3)
if(NOT EIGEN3_FOUND)
set(EIGEN3_INCLUDE_DIRS ${/usr/include/eigen3})
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, when bumping cmake, it would be good to bump cmake_minimum_required in this file and update the install instructions in the documentation.

"${ABSEIL_PROJECT_BUILD_DIR}/absl/numeric/libabsl_numeric.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/strings/libabsl_strings.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_bad_any_cast.a"
"${ABSEIL_PROJECT_BUILD_DIR}/absl/types/libabsl_any.a"
Copy link
Contributor

Choose a reason for hiding this comment

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

sort alphabetically

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

set(ABSEIL_INCLUDE_DIRS ${ABSEIL_PROJECT_SRC_DIR})
set(ABSEIL_LIBRARY_PATH
"${ABSEIL_PROJECT_BUILD_DIR}/absl/synchronization/${CMAKE_STATIC_LIBRARY_PREFIX}absl_synchronization${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(dependent_libraries
Copy link
Contributor

Choose a reason for hiding this comment

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

style: rename to ABSEIL_DEPENDENT_LIBRARIES

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

${CMAKE_CURRENT_BINARY_DIR}/${ABSEIL_PROJECT_NAME}/src/${ABSEIL_PROJECT_NAME}-build)
set(ABSEIL_INCLUDE_DIRS ${ABSEIL_PROJECT_SRC_DIR})
set(ABSEIL_LIBRARY_PATH
"${ABSEIL_PROJECT_BUILD_DIR}/absl/synchronization/${CMAKE_STATIC_LIBRARY_PREFIX}absl_synchronization${CMAKE_STATIC_LIBRARY_SUFFIX}")
Copy link
Contributor

Choose a reason for hiding this comment

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

drop the prefix and suffix (for consistency with dependent_libraries), this isn't portable anyways

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

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

PROPERTIES IMPORTED_LOCATION
${ABSEIL_LIBRARY_PATH}
INTERFACE_LINK_LIBRARIES
"${dependent_libraries}"
Copy link
Contributor

Choose a reason for hiding this comment

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

@hauke76 Is there a cleaner way to glob all static libraries into one target?
ABSEIL_LIBRARY_PATH=synchronization/libabsl_synchronization.a was an arbitrary choice only because this is the first one we will use.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, this is fine.

@pifon2a pifon2a changed the title Add absl to third_party. Add absl to CMake and Bazel builds. Jul 25, 2018
@pifon2a pifon2a merged commit e3a7f39 into cartographer-project:master Jul 26, 2018
@pifon2a pifon2a deleted the absl branch July 26, 2018 04:49
@gaschler gaschler mentioned this pull request Jul 26, 2018
@ojura ojura mentioned this pull request Jul 28, 2018
akshay-prsd pushed a commit to BossaNova/cartographer that referenced this pull request Jul 18, 2019
schayapathy pushed a commit to schayapathy/cartographer that referenced this pull request Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants