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

CMake Install Destination #660

Merged
merged 2 commits into from
Jan 7, 2021
Merged

CMake Install Destination #660

merged 2 commits into from
Jan 7, 2021

Conversation

varunagrawal
Copy link
Collaborator

Use an older form of CMake install so that it works with older CMake versions as well

@varunagrawal varunagrawal added the cmake Related to CMake and build system label Jan 6, 2021
@varunagrawal varunagrawal self-assigned this Jan 6, 2021

# Install pybind11 directory to `CMAKE_INSTALL_PREFIX/lib/pybind11` This will
# allow the gtwrapConfig.cmake file to load it later.
install(DIRECTORY pybind11 TYPE LIB)
install(DIRECTORY pybind11
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR, Varun.

A quick question to get me up to speed:

  1. Can you remind me why we need the wrap lib and can't use pybind11 out of the box?

Could you also explain a little more here about what the DESTINATION vs. TYPE argument does and why one is preferred?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. We use wrap to convert the gtsam.i file into a Pybind11 friendly file that can then be generated into a python package. So it's basically a transpiler for convenience and backwards compatibility.
  2. TYPE is the new form where specifying what type of object it is will let CMake decide where to install it to (e.g. type BIN will install in to /usr/local/bin). DESTINATION on the other hand is an explicit argument specifying where to install the object to, taking that decision away from CMake.

Copy link
Contributor

@johnwlambert johnwlambert Jan 7, 2021

Choose a reason for hiding this comment

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

I see, thanks, so wrap and the .i file are used so that we don't have to embed code like this into every .h or .cpp file?

PYBIND11_MODULE(example, m) {
    m.doc() = "pybind11 example plugin"; // optional module docstring

    m.def("add", &add, "A function which adds two numbers");
}

Could you add a small bit of documentation explaining why DESTINATION is preferred here and why we are not using BIN?

And can we also add a unit test or change the CI environment so that these kind of breaking changes are caught next time? Maybe this will take a bit of discussion, but along the principles of there should be a unit test that was broken before, and is fixed now with the PR etcc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Yes exactly. The wrap package lets us define a simple .i file with specific semantics which then gets wrapped into Python, MATLAB etc. Wrap allows us to support multiple languages simultaneously rather than be Pybind11 specific.
  2. BIN is actually preferred in the new CMake versions, but DESTINATION is the older API. Added the documentation.
  3. This would involve a lot more work than I have the bandwidth for: We'd have to set up a docker container with the specific virtual environment and toolchain, have that be available on the BorgLab docker registry, and then modify the CI to use the new container as our CI environment. Alternatively, we could install an older version of CMake directly, but that's going to increase the CI time (breaking development flow due to longer wait times) and potentially cause inconsistencies with the default environment depending on what other tools are installed (do they depend on the CMake 3.19 API specifically?). I am already spread too thin to take up all of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Ok, I'm approving for now, but I do feel that an easier fix is just to force users to use cmake 3.19 instead of >3.9. I think people could do the upgrade.

@varunagrawal varunagrawal merged commit 5a480c8 into develop Jan 7, 2021
@varunagrawal varunagrawal deleted the fix/wrap-install branch January 7, 2021 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Related to CMake and build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants