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 macros for generating pybind11 bindings #400

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Bi0T1N
Copy link
Contributor

@Bi0T1N Bi0T1N commented Dec 22, 2023

🎉 New feature

Closes #215

Summary

This adds CMake macros to remove code duplication for creating pybind11 bindings.

The only problem that occurs is that it destroys the used structure in CMakeLists.txt (e.g. for gz-math):

#============================================================================
# Set project-specific options
#============================================================================

option(SKIP_SWIG
      "Skip generating ruby bindings via Swig"
      OFF)


include(GzPython) <-- here we don't only set project-specific options - we search for Python
gz_add_pybind_project_settings()

The other two macros are fine:

########################################
# Python bindings
gz_search_for_pybind()

src/CMakeLists.txt:

# Bindings subdirectories
gz_add_pybind_directory(python_pybind11)

Test it

  1. Compile packages up to gz-math7 to /ws/install
  2. In gz-cmake project, run mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/ws/install/
  3. Run make -j && make install
  4. Open a new terminal and change directory to gz-math
  5. Run source /ws/install/setup.bash, change CMakeLists.txt to use gz-cmake4 and the new macros
  6. Run mkdir build && cd build && cmake .. && make -j

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

@azeey
Copy link
Contributor

azeey commented Jan 2, 2024

LGTM! but I'll hold off merging so @j-rivero can take a look since he commented on #215.

cmake/GzPython.cmake Outdated Show resolved Hide resolved
cmake/GzPython.cmake Outdated Show resolved Hide resolved
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@azeey
Copy link
Contributor

azeey commented Aug 12, 2024

To focus our efforts on the Ionic release, I'll go ahead and remove the beta label from this. I don't think this is a breaking change, so we can merge it after Ionic.

@azeey azeey removed the beta Targeting beta release of upcoming collection label Aug 12, 2024
@Bi0T1N Bi0T1N requested a review from scpeters August 23, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants